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 <CoreWLAN/CoreWLAN.h> 16 #import <ImageCaptureCore/ImageCaptureCore.h> 17 #import <IOBluetooth/IOBluetooth.h> 18 19 #include "base/base_export.h" 20 21 #if !defined(MAC_OS_X_VERSION_10_7) || \ 22 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 23 24 enum { 25 NSEventPhaseNone = 0, // event not associated with a phase. 26 NSEventPhaseBegan = 0x1 << 0, 27 NSEventPhaseStationary = 0x1 << 1, 28 NSEventPhaseChanged = 0x1 << 2, 29 NSEventPhaseEnded = 0x1 << 3, 30 NSEventPhaseCancelled = 0x1 << 4 31 }; 32 typedef NSUInteger NSEventPhase; 33 34 enum { 35 NSFullScreenWindowMask = 1 << 14, 36 }; 37 38 enum { 39 NSApplicationPresentationFullScreen = 1 << 10, 40 }; 41 42 enum { 43 NSWindowCollectionBehaviorFullScreenPrimary = 1 << 7, 44 NSWindowCollectionBehaviorFullScreenAuxiliary = 1 << 8, 45 }; 46 47 enum { 48 NSEventSwipeTrackingLockDirection = 0x1 << 0, 49 NSEventSwipeTrackingClampGestureAmount = 0x1 << 1, 50 }; 51 typedef NSUInteger NSEventSwipeTrackingOptions; 52 53 enum { 54 NSWindowAnimationBehaviorDefault = 0, 55 NSWindowAnimationBehaviorNone = 2, 56 NSWindowAnimationBehaviorDocumentWindow = 3, 57 NSWindowAnimationBehaviorUtilityWindow = 4, 58 NSWindowAnimationBehaviorAlertPanel = 5 59 }; 60 typedef NSInteger NSWindowAnimationBehavior; 61 62 enum { 63 NSWindowDocumentVersionsButton = 6, 64 NSWindowFullScreenButton, 65 }; 66 typedef NSUInteger NSWindowButton; 67 68 @interface NSEvent (LionSDK) 69 + (BOOL)isSwipeTrackingFromScrollEventsEnabled; 70 71 - (NSEventPhase)momentumPhase; 72 - (NSEventPhase)phase; 73 - (BOOL)hasPreciseScrollingDeltas; 74 - (CGFloat)scrollingDeltaX; 75 - (CGFloat)scrollingDeltaY; 76 - (void)trackSwipeEventWithOptions:(NSEventSwipeTrackingOptions)options 77 dampenAmountThresholdMin:(CGFloat)minDampenThreshold 78 max:(CGFloat)maxDampenThreshold 79 usingHandler:(void (^)(CGFloat gestureAmount, 80 NSEventPhase phase, 81 BOOL isComplete, 82 BOOL *stop))trackingHandler; 83 84 - (BOOL)isDirectionInvertedFromDevice; 85 86 @end 87 88 @interface NSApplication (LionSDK) 89 - (void)disableRelaunchOnLogin; 90 @end 91 92 @interface CALayer (LionSDK) 93 - (CGFloat)contentsScale; 94 - (void)setContentsScale:(CGFloat)contentsScale; 95 @end 96 97 @interface NSScreen (LionSDK) 98 - (CGFloat)backingScaleFactor; 99 - (NSRect)convertRectToBacking:(NSRect)aRect; 100 @end 101 102 @interface NSWindow (LionSDK) 103 - (CGFloat)backingScaleFactor; 104 - (NSWindowAnimationBehavior)animationBehavior; 105 - (void)setAnimationBehavior:(NSWindowAnimationBehavior)newAnimationBehavior; 106 - (void)toggleFullScreen:(id)sender; 107 - (void)setRestorable:(BOOL)flag; 108 @end 109 110 @interface NSCursor (LionSDKDeclarations) 111 + (NSCursor*)IBeamCursorForVerticalLayout; 112 @end 113 114 @interface NSAnimationContext (LionSDK) 115 + (void)runAnimationGroup:(void (^)(NSAnimationContext *context))changes 116 completionHandler:(void (^)(void))completionHandler; 117 @property(copy) void(^completionHandler)(void); 118 @end 119 120 @interface NSView (LionSDK) 121 - (NSSize)convertSizeFromBacking:(NSSize)size; 122 - (void)setWantsBestResolutionOpenGLSurface:(BOOL)flag; 123 @end 124 125 @interface NSObject (ICCameraDeviceDelegateLionSDK) 126 - (void)deviceDidBecomeReadyWithCompleteContentCatalog:(ICDevice*)device; 127 - (void)didDownloadFile:(ICCameraFile*)file 128 error:(NSError*)error 129 options:(NSDictionary*)options 130 contextInfo:(void*)contextInfo; 131 @end 132 133 @interface NSScroller (LionSDK) 134 + (NSInteger)preferredScrollerStyle; 135 @end 136 137 @interface CWInterface (LionSDK) 138 - (BOOL)associateToNetwork:(CWNetwork*)network 139 password:(NSString*)password 140 error:(NSError**)error; 141 - (NSSet*)scanForNetworksWithName:(NSString*)networkName 142 error:(NSError**)error; 143 @end 144 145 enum CWChannelBand { 146 kCWChannelBandUnknown = 0, 147 kCWChannelBand2GHz = 1, 148 kCWChannelBand5GHz = 2, 149 }; 150 151 @interface CWChannel : NSObject 152 @property(readonly) CWChannelBand channelBand; 153 @end 154 155 enum { 156 kCWSecurityNone = 0, 157 kCWSecurityWEP = 1, 158 kCWSecurityWPAPersonal = 2, 159 kCWSecurityWPAPersonalMixed = 3, 160 kCWSecurityWPA2Personal = 4, 161 kCWSecurityPersonal = 5, 162 kCWSecurityDynamicWEP = 6, 163 kCWSecurityWPAEnterprise = 7, 164 kCWSecurityWPAEnterpriseMixed = 8, 165 kCWSecurityWPA2Enterprise = 9, 166 kCWSecurityEnterprise = 10, 167 kCWSecurityUnknown = NSIntegerMax, 168 }; 169 170 typedef NSInteger CWSecurity; 171 172 @interface CWNetwork (LionSDK) 173 @property(readonly) CWChannel* wlanChannel; 174 @property(readonly) NSInteger rssiValue; 175 - (BOOL)supportsSecurity:(CWSecurity)security; 176 @end 177 178 @interface IOBluetoothHostController (LionSDK) 179 - (NSString*)nameAsString; 180 - (BluetoothHCIPowerState)powerState; 181 @end 182 183 enum { 184 kBluetoothFeatureLESupportedController = (1 << 6L), 185 }; 186 187 @protocol IOBluetoothDeviceInquiryDelegate 188 - (void)deviceInquiryStarted:(IOBluetoothDeviceInquiry*)sender; 189 - (void)deviceInquiryDeviceFound:(IOBluetoothDeviceInquiry*)sender 190 device:(IOBluetoothDevice*)device; 191 - (void)deviceInquiryComplete:(IOBluetoothDeviceInquiry*)sender 192 error:(IOReturn)error 193 aborted:(BOOL)aborted; 194 @end 195 196 @interface IOBluetoothL2CAPChannel (LionSDK) 197 @property(readonly) BluetoothL2CAPMTU outgoingMTU; 198 @end 199 200 @interface IOBluetoothDevice (LionSDK) 201 - (NSString*)addressString; 202 - (unsigned int)classOfDevice; 203 - (BluetoothConnectionHandle)connectionHandle; 204 - (BluetoothHCIRSSIValue)rawRSSI; 205 - (NSArray*)services; 206 - (IOReturn)performSDPQuery:(id)target uuids:(NSArray*)uuids; 207 @end 208 209 BASE_EXPORT extern "C" NSString* const NSWindowWillEnterFullScreenNotification; 210 211 #endif // MAC_OS_X_VERSION_10_7 212 213 #if !defined(MAC_OS_X_VERSION_10_8) || \ 214 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_8 215 216 enum { 217 NSEventPhaseMayBegin = 0x1 << 5 218 }; 219 220 @interface NSColor (MountainLionSDK) 221 - (CGColorRef)CGColor; 222 @end 223 224 #endif // MAC_OS_X_VERSION_10_8 225 226 227 #if !defined(MAC_OS_X_VERSION_10_9) || \ 228 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_9 229 230 // NSProgress is public API in 10.9, but a version of it exists and is usable 231 // in 10.8. 232 233 @interface NSProgress : NSObject 234 235 - (instancetype)initWithParent:(NSProgress*)parentProgressOrNil 236 userInfo:(NSDictionary*)userInfoOrNil; 237 @property (copy) NSString* kind; 238 239 @property int64_t totalUnitCount; 240 @property int64_t completedUnitCount; 241 242 @property (getter=isCancellable) BOOL cancellable; 243 @property (getter=isPausable) BOOL pausable; 244 @property (readonly, getter=isCancelled) BOOL cancelled; 245 @property (readonly, getter=isPaused) BOOL paused; 246 @property (copy) void (^cancellationHandler)(void); 247 @property (copy) void (^pausingHandler)(void); 248 - (void)cancel; 249 - (void)pause; 250 251 - (void)setUserInfoObject:(id)objectOrNil forKey:(NSString*)key; 252 - (NSDictionary*)userInfo; 253 254 @property (readonly, getter=isIndeterminate) BOOL indeterminate; 255 @property (readonly) double fractionCompleted; 256 257 - (void)publish; 258 - (void)unpublish; 259 260 @end 261 262 @interface NSScreen (MavericksSDK) 263 + (BOOL)screensHaveSeparateSpaces; 264 @end 265 266 // NSAppearance is a new class in the 10.9 SDK. New classes cannot be 267 // forward-declared because they also require an @implementation, which would 268 // produce conflicting linkage. Instead, just declare the necessary pieces of 269 // the interface as a protocol, and treat objects of this type as id. 270 @protocol CrNSAppearance<NSObject> 271 + (id<NSObject>)appearanceNamed:(NSString*)name; 272 @end 273 274 @interface NSView (MavericksSDK) 275 - (void)setCanDrawSubviewsIntoLayer:(BOOL)flag; 276 - (id<CrNSAppearance>)effectiveAppearance; 277 @end 278 279 enum { 280 NSWindowOcclusionStateVisible = 1UL << 1, 281 }; 282 typedef NSUInteger NSWindowOcclusionState; 283 284 @interface NSWindow (MavericksSDK) 285 - (NSWindowOcclusionState)occlusionState; 286 @end 287 288 #else // !MAC_OS_X_VERSION_10_9 289 290 typedef enum { 291 kCWSecurityModeOpen = 0, 292 kCWSecurityModeWEP, 293 kCWSecurityModeWPA_PSK, 294 kCWSecurityModeWPA2_PSK, 295 kCWSecurityModeWPA_Enterprise, 296 kCWSecurityModeWPA2_Enterprise, 297 kCWSecurityModeWPS, 298 kCWSecurityModeDynamicWEP 299 } CWSecurityMode; 300 301 @interface CWNetwork (SnowLeopardSDK) 302 @property(readonly) NSNumber* rssi; 303 @property(readonly) NSNumber* securityMode; 304 @end 305 306 BASE_EXPORT extern "C" NSString* const kCWSSIDDidChangeNotification; 307 308 #endif // MAC_OS_X_VERSION_10_9 309 310 #if !defined(MAC_OS_X_VERSION_10_10) || \ 311 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_10 312 313 @interface NSUserActivity : NSObject 314 315 @property (readonly, copy) NSString* activityType; 316 @property (copy) NSURL* webPageURL; 317 318 @end 319 320 BASE_EXPORT extern "C" NSString* const NSUserActivityTypeBrowsingWeb; 321 322 BASE_EXPORT extern "C" NSString* const NSAppearanceNameVibrantDark; 323 324 #endif // MAC_OS_X_VERSION_10_10 325 326 #endif // BASE_MAC_SDK_FORWARD_DECLARATIONS_H_ 327