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 | |
| 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]. | 14 // To alloc one of these classes, use -[NSClassFromString(@"..") alloc]. |
| 18 | 15 |
| 19 // Incomplete. Add more as necessary. | 16 // Incomplete. Add more as necessary. |
| 20 | 17 |
| 21 typedef NSObject NSCustomTouchBarItem; | 18 NS_ASSUME_NONNULL_BEGIN |
| 22 typedef NSObject NSGroupTouchBarItem; | 19 |
| 23 typedef NSObject NSTouchBar; | 20 @protocol NSTouchBarDelegate; |
| 24 typedef NSObject NSTouchBarItem; | 21 @class NSTouchBarItem; |
| 22 | |
| 23 typedef float NSTouchBarItemPriority; | |
| 24 static const NSTouchBarItemPriority NSTouchBarItemPriorityHigh = 1000; | |
| 25 static const NSTouchBarItemPriority NSTouchBarItemPriorityNormal = 0; | |
| 26 static const NSTouchBarItemPriority NSTouchBarItemPriorityLow = -1000; | |
| 27 | |
| 25 typedef NSString* NSTouchBarItemIdentifier; | 28 typedef NSString* NSTouchBarItemIdentifier; |
| 29 typedef NSString* NSTouchBarCustomizationIdentifier; | |
| 26 | 30 |
| 27 @protocol NSTouchBarDelegate<NSObject> | 31 @interface NSTouchBar : NSObject<NSCoding> |
| 32 | |
| 33 - (instancetype)init NS_DESIGNATED_INITIALIZER; | |
| 34 - (nullable instancetype)initWithCoder:(NSCoder*)aDecoder | |
| 35 NS_DESIGNATED_INITIALIZER; | |
| 36 | |
| 37 @property(copy, nullable) | |
| 38 NSTouchBarCustomizationIdentifier customizationIdentifier; | |
| 39 @property(copy) NSArray* customizationAllowedItemIdentifiers; | |
| 40 @property(copy) NSArray* customizationRequiredItemIdentifiers; | |
| 41 @property(copy) NSArray* defaultItemIdentifiers; | |
| 42 @property(copy, readonly) NSArray* itemIdentifiers; | |
| 43 @property(copy, nullable) NSTouchBarItemIdentifier principalItemIdentifier; | |
| 44 @property(copy) NSSet* templateItems; | |
| 45 @property(nullable, weak) id<NSTouchBarDelegate> delegate; | |
| 46 | |
| 47 - (nullable __kindof NSTouchBarItem*)itemForIdentifier: | |
| 48 (NSTouchBarItemIdentifier)identifier; | |
| 49 | |
| 50 @property(readonly, getter=isVisible) BOOL visible; | |
| 51 | |
| 28 @end | 52 @end |
| 29 | 53 |
| 30 @interface NSObject (FakeNSCustomTouchBarItem) | 54 @interface NSTouchBarItem : NSObject<NSCoding> |
| 31 @property(readwrite, strong) NSView* view; | 55 |
| 56 - (instancetype)initWithIdentifier:(NSTouchBarItemIdentifier)identifier | |
| 57 NS_DESIGNATED_INITIALIZER; | |
| 58 - (nullable instancetype)initWithCoder:(NSCoder*)coder | |
| 59 NS_DESIGNATED_INITIALIZER; | |
| 60 - (instancetype)init NS_UNAVAILABLE; | |
| 61 | |
| 62 @property(readonly, copy) NSTouchBarItemIdentifier identifier; | |
| 63 @property NSTouchBarItemPriority visibilityPriority; | |
| 64 @property(readonly, nullable) NSView* view; | |
| 65 @property(readonly, nullable) NSViewController* viewController; | |
| 66 @property(readonly, copy) NSString* customizationLabel; | |
| 67 @property(readonly, getter=isVisible) BOOL visible; | |
| 68 | |
| 32 @end | 69 @end |
| 33 | 70 |
| 34 @interface NSObject (FakeNSGroupTouchBarItem) | 71 @interface NSGroupTouchBarItem : NSTouchBarItem |
| 72 | |
| 35 + (NSGroupTouchBarItem*)groupItemWithIdentifier: | 73 + (NSGroupTouchBarItem*)groupItemWithIdentifier: |
| 36 (NSTouchBarItemIdentifier)identifier | 74 (NSTouchBarItemIdentifier)identifier |
| 37 items:(NSArray*)items; | 75 items:(NSArray*)items; |
| 76 | |
| 77 @property(retain) NSTouchBar* groupTouchBar; | |
| 78 @property(readwrite, copy, null_resettable) NSString* customizationLabel; | |
| 79 | |
| 38 @end | 80 @end |
| 39 | 81 |
| 40 @interface NSObject (FakeNSTouchBar) | 82 @interface NSCustomTouchBarItem : NSTouchBarItem |
| 41 @property(copy) NSArray* defaultItemIdentifiers; | 83 |
| 42 @property(copy) NSTouchBarItemIdentifier principalItemIdentifier; | 84 @property(readwrite, retain) __kindof NSView* view; |
| 43 @property(weak) id<NSTouchBarDelegate> delegate; | 85 @property(readwrite, retain, nullable) |
| 86 __kindof NSViewController* viewController; | |
| 87 @property(readwrite, copy, null_resettable) NSString* customizationLabel; | |
| 88 | |
| 44 @end | 89 @end |
| 45 | 90 |
| 91 @protocol NSTouchBarDelegate<NSObject> | |
| 92 @optional | |
| 93 - (nullable NSTouchBarItem*)touchBar:(NSTouchBar*)touchBar | |
| 94 makeItemForIdentifier:(NSTouchBarItemIdentifier)identifier; | |
| 95 @end | |
| 96 | |
| 97 NS_ASSUME_NONNULL_END | |
| 98 | |
| 46 #elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12_1 | 99 #elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12_1 |
| 47 | 100 |
| 48 // When compiling against the 10.12.1 SDK or later, just provide forward | 101 // When compiling against the 10.12.1 SDK or later, just provide forward |
| 49 // declarations to suppress the partial availability warnings. | 102 // declarations to suppress the partial availability warnings. |
|
tapted
2016/11/21 22:32:25
I think I'm ok with it for now but, if I understan
tapted
2016/11/23 04:54:22
Yeah I think removing these broke compilation agai
| |
| 50 | 103 |
| 51 @class NSCustomTouchBarItem; | 104 @class NSCustomTouchBarItem; |
| 52 @class NSGroupTouchBarItem; | 105 @class NSGroupTouchBarItem; |
| 53 @class NSTouchBar; | 106 @class NSTouchBar; |
| 54 @protocol NSTouchBarDelegate; | 107 @protocol NSTouchBarDelegate; |
| 55 @class NSTouchBarItem; | 108 @class NSTouchBarItem; |
| 56 | 109 |
| 57 #endif // MAC_OS_X_VERSION_10_12_1 | 110 #endif // MAC_OS_X_VERSION_10_12_1 |
| 58 | 111 |
| 59 #endif // UI_BASE_COCOA_TOUCH_BAR_FORWARD_DECLARATIONS_H_ | 112 #endif // UI_BASE_COCOA_TOUCH_BAR_FORWARD_DECLARATIONS_H_ |
| OLD | NEW |