Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef UI_BASE_COCOA_TOUCH_BAR_FORWARD_DECLARATIONS_H_ | 5 #ifndef UI_BASE_COCOA_TOUCH_BAR_FORWARD_DECLARATIONS_H_ |
| 6 #define UI_BASE_COCOA_TOUCH_BAR_FORWARD_DECLARATIONS_H_ | 6 #define UI_BASE_COCOA_TOUCH_BAR_FORWARD_DECLARATIONS_H_ |
| 7 | 7 |
| 8 // Once Chrome no longer supports OSX 10.12.0, this file can be deleted. | 8 // Once Chrome no longer supports OSX 10.12.0, this file can be deleted. |
| 9 | 9 |
| 10 #import <Foundation/Foundation.h> | 10 #import <Foundation/Foundation.h> |
| 11 | 11 |
| 12 #if !defined(MAC_OS_X_VERSION_10_12_1) | 12 #if !defined(MAC_OS_X_VERSION_10_12_1) |
| 13 | 13 |
| 14 // The TouchBar classes do not exist at all without the 10.12.1 SDK. When | 14 #pragma clang assume_nonnull begin |
|
tapted
2016/11/30 23:29:27
I think this is OK since we're replicating a syste
| |
| 15 // compiling with older SDKs, pretend they are NSObject and add categories to | |
| 16 // NSObject to expose the methods. | |
| 17 // To alloc one of these classes, use -[NSClassFromString(@"..") alloc]. | |
| 18 | 15 |
| 19 // Incomplete. Add more as necessary. | 16 @class NSTouchBar, NSTouchBarItem; |
| 17 @protocol NSTouchBarDelegate; | |
| 20 | 18 |
| 21 typedef NSObject NSCustomTouchBarItem; | 19 typedef float NSTouchBarItemPriority; |
| 22 typedef NSObject NSGroupTouchBarItem; | 20 static const NSTouchBarItemPriority NSTouchBarItemPriorityHigh = 1000; |
| 23 typedef NSObject NSTouchBar; | 21 static const NSTouchBarItemPriority NSTouchBarItemPriorityNormal = 0; |
| 24 typedef NSObject NSTouchBarItem; | 22 static const NSTouchBarItemPriority NSTouchBarItemPriorityLow = -1000; |
| 23 | |
| 25 typedef NSString* NSTouchBarItemIdentifier; | 24 typedef NSString* NSTouchBarItemIdentifier; |
| 25 typedef NSString* NSTouchBarCustomizationIdentifier; | |
| 26 | 26 |
| 27 @protocol NSTouchBarDelegate<NSObject> | 27 @interface NSTouchBar : NSObject<NSCoding> |
| 28 | |
| 29 - (instancetype)init NS_DESIGNATED_INITIALIZER; | |
|
tapted
2016/11/30 23:29:27
Internet suggests NS_DESIGNATED_INITIALIZER is XCo
| |
| 30 - (nullable instancetype)initWithCoder:(NSCoder*)aDecoder | |
| 31 NS_DESIGNATED_INITIALIZER; | |
| 32 | |
| 33 @property(copy, nullable) | |
| 34 NSTouchBarCustomizationIdentifier customizationIdentifier; | |
| 35 @property(copy) NSArray* customizationAllowedItemIdentifiers; | |
| 36 @property(copy) NSArray* customizationRequiredItemIdentifiers; | |
| 37 @property(copy) NSArray* defaultItemIdentifiers; | |
| 38 @property(copy, readonly) NSArray* itemIdentifiers; | |
| 39 @property(copy, nullable) NSTouchBarItemIdentifier principalItemIdentifier; | |
| 40 @property(copy) NSSet* templateItems; | |
| 41 @property(nullable, weak) id<NSTouchBarDelegate> delegate; | |
| 42 | |
| 43 - (nullable __kindof NSTouchBarItem*)itemForIdentifier: | |
|
tapted
2016/11/30 23:29:27
I think __kindof is Xcode 7 (10.11 SDK). But hopef
| |
| 44 (NSTouchBarItemIdentifier)identifier; | |
| 45 | |
| 46 @property(readonly, getter=isVisible) BOOL visible; | |
| 47 | |
| 28 @end | 48 @end |
| 29 | 49 |
| 30 @interface NSObject (FakeNSCustomTouchBarItem) | 50 @interface NSTouchBarItem : NSObject<NSCoding> |
| 31 @property(readwrite, strong) NSView* view; | 51 |
| 52 - (instancetype)initWithIdentifier:(NSTouchBarItemIdentifier)identifier | |
| 53 NS_DESIGNATED_INITIALIZER; | |
| 54 - (nullable instancetype)initWithCoder:(NSCoder*)coder | |
| 55 NS_DESIGNATED_INITIALIZER; | |
| 56 - (instancetype)init NS_UNAVAILABLE; | |
| 57 | |
| 58 @property(readonly, copy) NSTouchBarItemIdentifier identifier; | |
| 59 @property NSTouchBarItemPriority visibilityPriority; | |
| 60 @property(readonly, nullable) NSView* view; | |
| 61 @property(readonly, nullable) NSViewController* viewController; | |
| 62 @property(readonly, copy) NSString* customizationLabel; | |
| 63 @property(readonly, getter=isVisible) BOOL visible; | |
| 64 | |
| 32 @end | 65 @end |
| 33 | 66 |
| 34 @interface NSObject (FakeNSGroupTouchBarItem) | 67 @interface NSGroupTouchBarItem : NSTouchBarItem |
| 68 | |
| 35 + (NSGroupTouchBarItem*)groupItemWithIdentifier: | 69 + (NSGroupTouchBarItem*)groupItemWithIdentifier: |
| 36 (NSTouchBarItemIdentifier)identifier | 70 (NSTouchBarItemIdentifier)identifier |
| 37 items:(NSArray*)items; | 71 items:(NSArray*)items; |
| 72 | |
| 73 @property(strong) NSTouchBar* groupTouchBar; | |
| 74 @property(readwrite, copy, null_resettable) NSString* customizationLabel; | |
| 75 | |
| 38 @end | 76 @end |
| 39 | 77 |
| 40 @interface NSObject (FakeNSTouchBar) | 78 @interface NSCustomTouchBarItem : NSTouchBarItem |
| 41 @property(copy) NSArray* defaultItemIdentifiers; | 79 |
| 42 @property(copy) NSTouchBarItemIdentifier principalItemIdentifier; | 80 @property(readwrite, strong) __kindof NSView* view; |
| 43 @property(weak) id<NSTouchBarDelegate> delegate; | 81 @property(readwrite, strong, nullable) |
| 82 __kindof NSViewController* viewController; | |
| 83 @property(readwrite, copy, null_resettable) NSString* customizationLabel; | |
| 84 | |
| 44 @end | 85 @end |
| 45 | 86 |
| 87 @protocol NSTouchBarDelegate<NSObject> | |
| 88 | |
| 89 @optional | |
| 90 - (nullable NSTouchBarItem*)touchBar:(NSTouchBar*)touchBar | |
| 91 makeItemForIdentifier:(NSTouchBarItemIdentifier)identifier; | |
| 92 @end | |
| 93 | |
| 94 #pragma clang assume_nonnull end | |
| 95 | |
| 46 #elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12_1 | 96 #elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12_1 |
| 47 | 97 |
| 48 // When compiling against the 10.12.1 SDK or later, just provide forward | 98 // When compiling against the 10.12.1 SDK or later, just provide forward |
| 49 // declarations to suppress the partial availability warnings. | 99 // declarations to suppress the partial availability warnings. |
| 50 | 100 |
| 51 @class NSCustomTouchBarItem; | 101 @class NSCustomTouchBarItem; |
| 52 @class NSGroupTouchBarItem; | 102 @class NSGroupTouchBarItem; |
| 53 @class NSTouchBar; | 103 @class NSTouchBar; |
| 54 @protocol NSTouchBarDelegate; | 104 @protocol NSTouchBarDelegate; |
| 55 @class NSTouchBarItem; | 105 @class NSTouchBarItem; |
| 56 | 106 |
| 57 #endif // MAC_OS_X_VERSION_10_12_1 | 107 #endif // MAC_OS_X_VERSION_10_12_1 |
| 58 | 108 |
| 59 #endif // UI_BASE_COCOA_TOUCH_BAR_FORWARD_DECLARATIONS_H_ | 109 #endif // UI_BASE_COCOA_TOUCH_BAR_FORWARD_DECLARATIONS_H_ |
| OLD | NEW |