Home | History | Annotate | Download | only in mac
      1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 // This file contains forward declarations for items in later SDKs than the
      6 // default one with which Chromium is built (currently 10.6).
      7 // If you call any function from this header, be sure to check at runtime for
      8 // respondsToSelector: before calling these functions (else your code will crash
      9 // on older OS X versions that chrome still supports).
     10 
     11 #ifndef BASE_MAC_SDK_FORWARD_DECLARATIONS_H_
     12 #define BASE_MAC_SDK_FORWARD_DECLARATIONS_H_
     13 
     14 #import <AppKit/AppKit.h>
     15 #import <CoreBluetooth/CoreBluetooth.h>
     16 #import <CoreWLAN/CoreWLAN.h>
     17 #import <ImageCaptureCore/ImageCaptureCore.h>
     18 #import <IOBluetooth/IOBluetooth.h>
     19 #include <stdint.h>
     20 
     21 #include "base/base_export.h"
     22 
     23 // ----------------------------------------------------------------------------
     24 // Either define or forward declare classes only available in OSX 10.7+.
     25 // ----------------------------------------------------------------------------
     26 
     27 #if !defined(MAC_OS_X_VERSION_10_7) || \
     28     MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
     29 
     30 @interface CWChannel : NSObject
     31 @end
     32 
     33 @interface CBPeripheral : NSObject
     34 @end
     35 
     36 @interface CBCentralManager : NSObject
     37 @end
     38 
     39 @interface CBUUID : NSObject
     40 @end
     41 
     42 #else
     43 
     44 @class CWChannel;
     45 @class CBPeripheral;
     46 @class CBCentralManager;
     47 @class CBUUID;
     48 
     49 #endif  // MAC_OS_X_VERSION_10_7
     50 
     51 #if !defined(MAC_OS_X_VERSION_10_8) || \
     52     MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_8
     53 
     54 @interface NSUUID : NSObject
     55 @end
     56 
     57 #else
     58 
     59 @class NSUUID;
     60 
     61 #endif  // MAC_OS_X_VERSION_10_8
     62 
     63 #if !defined(MAC_OS_X_VERSION_10_9) || \
     64     MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_9
     65 
     66 // NSProgress is public API in 10.9, but a version of it exists and is usable
     67 // in 10.8.
     68 @interface NSProgress : NSObject
     69 @end
     70 
     71 @interface NSAppearance : NSObject
     72 @end
     73 
     74 #else
     75 
     76 @class NSProgress;
     77 @class NSAppearance;
     78 
     79 #endif  // MAC_OS_X_VERSION_10_9
     80 
     81 // ----------------------------------------------------------------------------
     82 // Define typedefs, enums, and protocols not available in the version of the
     83 // OSX SDK being compiled against.
     84 // ----------------------------------------------------------------------------
     85 
     86 #if !defined(MAC_OS_X_VERSION_10_7) || \
     87     MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
     88 
     89 enum {
     90   NSEventPhaseNone = 0,  // event not associated with a phase.
     91   NSEventPhaseBegan = 0x1 << 0,
     92   NSEventPhaseStationary = 0x1 << 1,
     93   NSEventPhaseChanged = 0x1 << 2,
     94   NSEventPhaseEnded = 0x1 << 3,
     95   NSEventPhaseCancelled = 0x1 << 4
     96 };
     97 typedef NSUInteger NSEventPhase;
     98 
     99 enum {
    100   NSFullScreenWindowMask = 1 << 14,
    101 };
    102 
    103 enum {
    104   NSApplicationPresentationFullScreen = 1 << 10,
    105 };
    106 
    107 enum {
    108   NSWindowCollectionBehaviorFullScreenPrimary = 1 << 7,
    109   NSWindowCollectionBehaviorFullScreenAuxiliary = 1 << 8,
    110 };
    111 
    112 enum {
    113   NSEventSwipeTrackingLockDirection = 0x1 << 0,
    114   NSEventSwipeTrackingClampGestureAmount = 0x1 << 1,
    115 };
    116 typedef NSUInteger NSEventSwipeTrackingOptions;
    117 
    118 enum {
    119   NSWindowAnimationBehaviorDefault = 0,
    120   NSWindowAnimationBehaviorNone = 2,
    121   NSWindowAnimationBehaviorDocumentWindow = 3,
    122   NSWindowAnimationBehaviorUtilityWindow = 4,
    123   NSWindowAnimationBehaviorAlertPanel = 5
    124 };
    125 typedef NSInteger NSWindowAnimationBehavior;
    126 
    127 enum {
    128   NSWindowDocumentVersionsButton = 6,
    129   NSWindowFullScreenButton,
    130 };
    131 typedef NSUInteger NSWindowButton;
    132 
    133 enum CWChannelBand {
    134   kCWChannelBandUnknown = 0,
    135   kCWChannelBand2GHz = 1,
    136   kCWChannelBand5GHz = 2,
    137 };
    138 
    139 enum {
    140   kCWSecurityNone = 0,
    141   kCWSecurityWEP = 1,
    142   kCWSecurityWPAPersonal = 2,
    143   kCWSecurityWPAPersonalMixed = 3,
    144   kCWSecurityWPA2Personal = 4,
    145   kCWSecurityPersonal = 5,
    146   kCWSecurityDynamicWEP = 6,
    147   kCWSecurityWPAEnterprise = 7,
    148   kCWSecurityWPAEnterpriseMixed = 8,
    149   kCWSecurityWPA2Enterprise = 9,
    150   kCWSecurityEnterprise = 10,
    151   kCWSecurityUnknown = NSIntegerMax,
    152 };
    153 
    154 typedef NSInteger CWSecurity;
    155 
    156 enum {
    157   kBluetoothFeatureLESupportedController = (1 << 6L),
    158 };
    159 
    160 @protocol IOBluetoothDeviceInquiryDelegate
    161 - (void)deviceInquiryStarted:(IOBluetoothDeviceInquiry*)sender;
    162 - (void)deviceInquiryDeviceFound:(IOBluetoothDeviceInquiry*)sender
    163                           device:(IOBluetoothDevice*)device;
    164 - (void)deviceInquiryComplete:(IOBluetoothDeviceInquiry*)sender
    165                         error:(IOReturn)error
    166                       aborted:(BOOL)aborted;
    167 @end
    168 
    169 enum {
    170   CBPeripheralStateDisconnected = 0,
    171   CBPeripheralStateConnecting,
    172   CBPeripheralStateConnected,
    173 };
    174 typedef NSInteger CBPeripheralState;
    175 
    176 enum {
    177   CBCentralManagerStateUnknown = 0,
    178   CBCentralManagerStateResetting,
    179   CBCentralManagerStateUnsupported,
    180   CBCentralManagerStateUnauthorized,
    181   CBCentralManagerStatePoweredOff,
    182   CBCentralManagerStatePoweredOn,
    183 };
    184 typedef NSInteger CBCentralManagerState;
    185 
    186 @protocol CBCentralManagerDelegate;
    187 
    188 @protocol CBCentralManagerDelegate<NSObject>
    189 - (void)centralManagerDidUpdateState:(CBCentralManager*)central;
    190 - (void)centralManager:(CBCentralManager*)central
    191     didDiscoverPeripheral:(CBPeripheral*)peripheral
    192         advertisementData:(NSDictionary*)advertisementData
    193                      RSSI:(NSNumber*)RSSI;
    194 @end
    195 
    196 #endif  // MAC_OS_X_VERSION_10_7
    197 
    198 #if !defined(MAC_OS_X_VERSION_10_8) || \
    199     MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_8
    200 
    201 enum { NSEventPhaseMayBegin = 0x1 << 5 };
    202 
    203 #endif  // MAC_OS_X_VERSION_10_8
    204 
    205 #if !defined(MAC_OS_X_VERSION_10_9) || \
    206     MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_9
    207 
    208 enum {
    209   NSWindowOcclusionStateVisible = 1UL << 1,
    210 };
    211 typedef NSUInteger NSWindowOcclusionState;
    212 
    213 enum { NSWorkspaceLaunchWithErrorPresentation = 0x00000040 };
    214 
    215 #endif  // MAC_OS_X_VERSION_10_9
    216 
    217 #if !defined(MAC_OS_X_VERSION_10_11) || \
    218     MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_11
    219 
    220 enum {
    221   NSPressureBehaviorUnknown = -1,
    222   NSPressureBehaviorPrimaryDefault = 0,
    223   NSPressureBehaviorPrimaryClick = 1,
    224   NSPressureBehaviorPrimaryGeneric = 2,
    225   NSPressureBehaviorPrimaryAccelerator = 3,
    226   NSPressureBehaviorPrimaryDeepClick = 5,
    227   NSPressureBehaviorPrimaryDeepDrag = 6
    228 };
    229 typedef NSInteger NSPressureBehavior;
    230 
    231 @interface NSPressureConfiguration : NSObject
    232 - (instancetype)initWithPressureBehavior:(NSPressureBehavior)pressureBehavior;
    233 @end
    234 
    235 #endif // MAC_OS_X_VERSION_10_11
    236 
    237 // ----------------------------------------------------------------------------
    238 // Define NSStrings only available in newer versions of the OSX SDK to force
    239 // them to be statically linked.
    240 // ----------------------------------------------------------------------------
    241 
    242 extern "C" {
    243 #if !defined(MAC_OS_X_VERSION_10_7) || \
    244     MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_7
    245 BASE_EXPORT extern NSString* const NSWindowWillEnterFullScreenNotification;
    246 BASE_EXPORT extern NSString* const NSWindowWillExitFullScreenNotification;
    247 BASE_EXPORT extern NSString* const NSWindowDidEnterFullScreenNotification;
    248 BASE_EXPORT extern NSString* const NSWindowDidExitFullScreenNotification;
    249 BASE_EXPORT extern NSString* const
    250     NSWindowDidChangeBackingPropertiesNotification;
    251 BASE_EXPORT extern NSString* const CBAdvertisementDataServiceDataKey;
    252 BASE_EXPORT extern NSString* const CBAdvertisementDataServiceUUIDsKey;
    253 #endif  // MAC_OS_X_VERSION_10_7
    254 
    255 #if !defined(MAC_OS_X_VERSION_10_9) || \
    256     MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_9
    257 BASE_EXPORT extern NSString* const NSWindowDidChangeOcclusionStateNotification;
    258 BASE_EXPORT extern NSString* const CBAdvertisementDataOverflowServiceUUIDsKey;
    259 BASE_EXPORT extern NSString* const CBAdvertisementDataIsConnectable;
    260 #endif  // MAC_OS_X_VERSION_10_9
    261 
    262 #if !defined(MAC_OS_X_VERSION_10_10) || \
    263     MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_10
    264 BASE_EXPORT extern NSString* const NSUserActivityTypeBrowsingWeb;
    265 BASE_EXPORT extern NSString* const NSAppearanceNameVibrantDark;
    266 BASE_EXPORT extern NSString* const NSAppearanceNameVibrantLight;
    267 #endif  // MAC_OS_X_VERSION_10_10
    268 }  // extern "C"
    269 
    270 // ----------------------------------------------------------------------------
    271 // If compiling against an older version of the OSX SDK, declare functions that
    272 // are available in newer versions of the OSX SDK. If compiling against a newer
    273 // version of the OSX SDK, redeclare those same functions to suppress
    274 // -Wpartial-availability warnings.
    275 // ----------------------------------------------------------------------------
    276 
    277 // Once Chrome no longer supports OSX 10.6, everything within this preprocessor
    278 // block can be removed.
    279 #if !defined(MAC_OS_X_VERSION_10_7) || \
    280     MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_7
    281 
    282 @interface NSEvent (LionSDK)
    283 + (BOOL)isSwipeTrackingFromScrollEventsEnabled;
    284 - (NSEventPhase)momentumPhase;
    285 - (NSEventPhase)phase;
    286 - (BOOL)hasPreciseScrollingDeltas;
    287 - (CGFloat)scrollingDeltaX;
    288 - (CGFloat)scrollingDeltaY;
    289 - (void)trackSwipeEventWithOptions:(NSEventSwipeTrackingOptions)options
    290           dampenAmountThresholdMin:(CGFloat)minDampenThreshold
    291                                max:(CGFloat)maxDampenThreshold
    292                       usingHandler:(void (^)(CGFloat gestureAmount,
    293                                              NSEventPhase phase,
    294                                              BOOL isComplete,
    295                                              BOOL* stop))trackingHandler;
    296 - (BOOL)isDirectionInvertedFromDevice;
    297 @end
    298 
    299 @interface NSApplication (LionSDK)
    300 - (void)disableRelaunchOnLogin;
    301 @end
    302 
    303 @interface CALayer (LionSDK)
    304 - (CGFloat)contentsScale;
    305 - (void)setContentsScale:(CGFloat)contentsScale;
    306 @end
    307 
    308 @interface NSScreen (LionSDK)
    309 - (CGFloat)backingScaleFactor;
    310 - (NSRect)convertRectToBacking:(NSRect)aRect;
    311 @end
    312 
    313 @interface NSWindow (LionSDK)
    314 - (CGFloat)backingScaleFactor;
    315 - (NSWindowAnimationBehavior)animationBehavior;
    316 - (void)setAnimationBehavior:(NSWindowAnimationBehavior)newAnimationBehavior;
    317 - (void)toggleFullScreen:(id)sender;
    318 - (void)setRestorable:(BOOL)flag;
    319 - (NSRect)convertRectFromScreen:(NSRect)aRect;
    320 - (NSRect)convertRectToScreen:(NSRect)aRect;
    321 @end
    322 
    323 @interface NSCursor (LionSDKDeclarations)
    324 + (NSCursor*)IBeamCursorForVerticalLayout;
    325 @end
    326 
    327 @interface NSAnimationContext (LionSDK)
    328 + (void)runAnimationGroup:(void (^)(NSAnimationContext* context))changes
    329         completionHandler:(void (^)(void))completionHandler;
    330 @property(copy) void (^completionHandler)(void);
    331 @end
    332 
    333 @interface NSView (LionSDK)
    334 - (NSSize)convertSizeFromBacking:(NSSize)size;
    335 - (void)setWantsBestResolutionOpenGLSurface:(BOOL)flag;
    336 - (NSDraggingSession*)beginDraggingSessionWithItems:(NSArray*)items
    337                                               event:(NSEvent*)event
    338                                              source:
    339                                                  (id<NSDraggingSource>)source;
    340 @end
    341 
    342 @interface NSObject (ICCameraDeviceDelegateLionSDK)
    343 - (void)deviceDidBecomeReadyWithCompleteContentCatalog:(ICDevice*)device;
    344 - (void)didDownloadFile:(ICCameraFile*)file
    345                   error:(NSError*)error
    346                 options:(NSDictionary*)options
    347             contextInfo:(void*)contextInfo;
    348 @end
    349 
    350 @interface CWInterface (LionSDK)
    351 - (BOOL)associateToNetwork:(CWNetwork*)network
    352                   password:(NSString*)password
    353                      error:(NSError**)error;
    354 - (NSSet*)scanForNetworksWithName:(NSString*)networkName error:(NSError**)error;
    355 @end
    356 
    357 @interface CWChannel (LionSDK)
    358 @property(readonly) CWChannelBand channelBand;
    359 @end
    360 
    361 @interface CWNetwork (LionSDK)
    362 @property(readonly) CWChannel* wlanChannel;
    363 @property(readonly) NSInteger rssiValue;
    364 - (BOOL)supportsSecurity:(CWSecurity)security;
    365 @end
    366 
    367 @interface IOBluetoothHostController (LionSDK)
    368 - (NSString*)nameAsString;
    369 - (BluetoothHCIPowerState)powerState;
    370 @end
    371 
    372 @interface IOBluetoothL2CAPChannel (LionSDK)
    373 @property(readonly) BluetoothL2CAPMTU outgoingMTU;
    374 @end
    375 
    376 @interface IOBluetoothDevice (LionSDK)
    377 - (NSString*)addressString;
    378 - (unsigned int)classOfDevice;
    379 - (BluetoothConnectionHandle)connectionHandle;
    380 - (BluetoothHCIRSSIValue)rawRSSI;
    381 - (NSArray*)services;
    382 - (IOReturn)performSDPQuery:(id)target uuids:(NSArray*)uuids;
    383 @end
    384 
    385 @interface CBPeripheral (LionSDK)
    386 @property(readonly, nonatomic) CFUUIDRef UUID;
    387 @property(retain, readonly) NSString* name;
    388 @property(readonly) BOOL isConnected;
    389 @end
    390 
    391 @interface CBCentralManager (LionSDK)
    392 @property(readonly) CBCentralManagerState state;
    393 - (id)initWithDelegate:(id<CBCentralManagerDelegate>)delegate
    394                  queue:(dispatch_queue_t)queue;
    395 - (void)scanForPeripheralsWithServices:(NSArray*)serviceUUIDs
    396                                options:(NSDictionary*)options;
    397 - (void)stopScan;
    398 @end
    399 
    400 @interface CBUUID (LionSDK)
    401 @property(nonatomic, readonly) NSData* data;
    402 + (CBUUID*)UUIDWithString:(NSString*)theString;
    403 @end
    404 
    405 BASE_EXPORT extern "C" void NSAccessibilityPostNotificationWithUserInfo(
    406     id object,
    407     NSString* notification,
    408     NSDictionary* user_info);
    409 
    410 #endif  // MAC_OS_X_VERSION_10_7
    411 
    412 // Once Chrome no longer supports OSX 10.7, everything within this preprocessor
    413 // block can be removed.
    414 #if !defined(MAC_OS_X_VERSION_10_8) || \
    415     MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_8
    416 
    417 @interface NSColor (MountainLionSDK)
    418 - (CGColorRef)CGColor;
    419 @end
    420 
    421 @interface NSUUID (MountainLionSDK)
    422 - (NSString*)UUIDString;
    423 @end
    424 
    425 @interface NSControl (MountainLionSDK)
    426 @property BOOL allowsExpansionToolTips;
    427 @end
    428 
    429 #endif  // MAC_OS_X_VERSION_10_8
    430 
    431 // Once Chrome no longer supports OSX 10.8, everything within this preprocessor
    432 // block can be removed.
    433 #if !defined(MAC_OS_X_VERSION_10_9) || \
    434     MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_9
    435 
    436 @interface NSProgress (MavericksSDK)
    437 
    438 - (instancetype)initWithParent:(NSProgress*)parentProgressOrNil
    439                       userInfo:(NSDictionary*)userInfoOrNil;
    440 @property(copy) NSString* kind;
    441 
    442 @property int64_t totalUnitCount;
    443 @property int64_t completedUnitCount;
    444 
    445 @property(getter=isCancellable) BOOL cancellable;
    446 @property(getter=isPausable) BOOL pausable;
    447 @property(readonly, getter=isCancelled) BOOL cancelled;
    448 @property(readonly, getter=isPaused) BOOL paused;
    449 @property(copy) void (^cancellationHandler)(void);
    450 @property(copy) void (^pausingHandler)(void);
    451 - (void)cancel;
    452 - (void)pause;
    453 
    454 - (void)setUserInfoObject:(id)objectOrNil forKey:(NSString*)key;
    455 - (NSDictionary*)userInfo;
    456 
    457 @property(readonly, getter=isIndeterminate) BOOL indeterminate;
    458 @property(readonly) double fractionCompleted;
    459 
    460 - (void)publish;
    461 - (void)unpublish;
    462 
    463 @end
    464 
    465 @interface NSScreen (MavericksSDK)
    466 + (BOOL)screensHaveSeparateSpaces;
    467 @end
    468 
    469 @interface NSView (MavericksSDK)
    470 - (void)setCanDrawSubviewsIntoLayer:(BOOL)flag;
    471 - (void)setAppearance:(NSAppearance*)appearance;
    472 - (NSAppearance*)effectiveAppearance;
    473 @end
    474 
    475 @interface NSWindow (MavericksSDK)
    476 - (NSWindowOcclusionState)occlusionState;
    477 @end
    478 
    479 @interface NSAppearance (MavericksSDK)
    480 + (id<NSObject>)appearanceNamed:(NSString*)name;
    481 @end
    482 
    483 @interface CBPeripheral (MavericksSDK)
    484 @property(readonly, nonatomic) NSUUID* identifier;
    485 @end
    486 
    487 #endif  // MAC_OS_X_VERSION_10_9
    488 
    489 // Once Chrome no longer supports OSX 10.9, everything within this preprocessor
    490 // block can be removed.
    491 #if !defined(MAC_OS_X_VERSION_10_10) || \
    492     MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_10
    493 
    494 @interface CBUUID (YosemiteSDK)
    495 - (NSString*)UUIDString;
    496 @end
    497 
    498 @interface NSViewController (YosemiteSDK)
    499 - (void)viewDidLoad;
    500 @end
    501 
    502 @interface NSWindow (YosemiteSDK)
    503 - (void)setTitlebarAppearsTransparent:(BOOL)flag;
    504 @end
    505 
    506 #endif  // MAC_OS_X_VERSION_10_10
    507 
    508 // Once Chrome no longer supports OSX 10.10.2, everything within this
    509 // preprocessor block can be removed.
    510 #if !defined(MAC_OS_X_VERSION_10_10_3) || \
    511     MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_10_3
    512 
    513 @interface NSEvent (YosemiteSDK)
    514 @property(readonly) NSInteger stage;
    515 @end
    516 
    517 @interface NSView (YosemiteSDK)
    518 - (void)setPressureConfiguration:(NSPressureConfiguration*)aConfiguration;
    519 @end
    520 
    521 #endif  // MAC_OS_X_VERSION_10_10
    522 
    523 // ----------------------------------------------------------------------------
    524 // The symbol for kCWSSIDDidChangeNotification is available in the
    525 // CoreWLAN.framework for OSX versions 10.6 through 10.10. The symbol is not
    526 // declared in the OSX 10.9+ SDK, so when compiling against an OSX 10.9+ SDK,
    527 // declare the symbol.
    528 // ----------------------------------------------------------------------------
    529 #if defined(MAC_OS_X_VERSION_10_9) && \
    530     MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_9
    531 BASE_EXPORT extern "C" NSString* const kCWSSIDDidChangeNotification;
    532 #endif
    533 #endif  // BASE_MAC_SDK_FORWARD_DECLARATIONS_H_
    534