Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Side by Side Diff: ui/base/cocoa/touch_bar_forward_declarations.h

Issue 2526723002: Revert of [Mac] Switch from NSObject categories to forward declarations for Touch Bar support. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ui/views/cocoa/bridged_content_view_touch_bar.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 is built with the 10.12.1 SDK, the NSTouchBar… classes can be 8 // Once Chrome no longer supports OSX 10.12.0, this file can be deleted.
9 // referred to normally (instead of with NSClassFromString(@"…")), and this
10 // file can be deleted.
11 9
12 #import <Foundation/Foundation.h> 10 #import <Foundation/Foundation.h>
13 11
14 #if !defined(MAC_OS_X_VERSION_10_12_1) 12 #if !defined(MAC_OS_X_VERSION_10_12_1)
15 #define __NSi_10_12_1 introduced = 10.12.1
16 13
17 NS_ASSUME_NONNULL_BEGIN 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].
18 18
19 @class NSTouchBar, NSTouchBarItem; 19 // Incomplete. Add more as necessary.
20 @protocol NSTouchBarDelegate;
21 20
22 typedef float NSTouchBarItemPriority; 21 typedef NSObject NSCustomTouchBarItem;
23 static const NSTouchBarItemPriority NSTouchBarItemPriorityHigh = 1000; 22 typedef NSObject NSGroupTouchBarItem;
24 static const NSTouchBarItemPriority NSTouchBarItemPriorityNormal = 0; 23 typedef NSObject NSTouchBar;
25 static const NSTouchBarItemPriority NSTouchBarItemPriorityLow = -1000; 24 typedef NSObject NSTouchBarItem;
25 typedef NSString* NSTouchBarItemIdentifier;
26 26
27 typedef NSString* NSTouchBarItemIdentifier; 27 @protocol NSTouchBarDelegate<NSObject>
28 typedef NSString* NSTouchBarCustomizationIdentifier;
29
30 NS_CLASS_AVAILABLE_MAC(10_12_1)
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
52 @end 28 @end
53 29
54 NS_CLASS_AVAILABLE_MAC(10_12_1) 30 @interface NSObject (FakeNSCustomTouchBarItem)
55 @interface NSTouchBarItem : NSObject<NSCoding> 31 @property(readwrite, strong) NSView* view;
56
57 - (instancetype)initWithIdentifier:(NSTouchBarItemIdentifier)identifier
58 NS_DESIGNATED_INITIALIZER;
59 - (nullable instancetype)initWithCoder:(NSCoder*)coder
60 NS_DESIGNATED_INITIALIZER;
61 - (instancetype)init NS_UNAVAILABLE;
62
63 @property(readonly, copy) NSTouchBarItemIdentifier identifier;
64 @property NSTouchBarItemPriority visibilityPriority;
65 @property(readonly, nullable) NSView* view;
66 @property(readonly, nullable) NSViewController* viewController;
67 @property(readonly, copy) NSString* customizationLabel;
68 @property(readonly, getter=isVisible) BOOL visible;
69
70 @end 32 @end
71 33
72 NS_CLASS_AVAILABLE_MAC(10_12_1) 34 @interface NSObject (FakeNSGroupTouchBarItem)
73 @interface NSGroupTouchBarItem : NSTouchBarItem
74
75 + (NSGroupTouchBarItem*)groupItemWithIdentifier: 35 + (NSGroupTouchBarItem*)groupItemWithIdentifier:
76 (NSTouchBarItemIdentifier)identifier 36 (NSTouchBarItemIdentifier)identifier
77 items:(NSArray*)items; 37 items:(NSArray*)items;
78
79 @property(strong) NSTouchBar* groupTouchBar;
80 @property(readwrite, copy, null_resettable) NSString* customizationLabel;
81
82 @end 38 @end
83 39
84 NS_CLASS_AVAILABLE_MAC(10_12_1) 40 @interface NSObject (FakeNSTouchBar)
85 @interface NSCustomTouchBarItem : NSTouchBarItem 41 @property(copy) NSArray* defaultItemIdentifiers;
86 42 @property(copy) NSTouchBarItemIdentifier principalItemIdentifier;
87 @property(readwrite, strong) __kindof NSView* view; 43 @property(weak) id<NSTouchBarDelegate> delegate;
88 @property(readwrite, strong, nullable)
89 __kindof NSViewController* viewController;
90 @property(readwrite, copy, null_resettable) NSString* customizationLabel;
91
92 @end 44 @end
93 45
94 @protocol NSTouchBarDelegate<NSObject> 46 #elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12_1
95 47
96 @optional 48 // When compiling against the 10.12.1 SDK or later, just provide forward
97 - (nullable NSTouchBarItem*)touchBar:(NSTouchBar*)touchBar 49 // declarations to suppress the partial availability warnings.
98 makeItemForIdentifier:(NSTouchBarItemIdentifier)identifier
99 NS_AVAILABLE_MAC(10_12_1);
100 @end
101 50
102 NS_ASSUME_NONNULL_END 51 @class NSCustomTouchBarItem;
52 @class NSGroupTouchBarItem;
53 @class NSTouchBar;
54 @protocol NSTouchBarDelegate;
55 @class NSTouchBarItem;
103 56
104 #endif // MAC_OS_X_VERSION_10_12_1 57 #endif // MAC_OS_X_VERSION_10_12_1
105 58
106 #endif // UI_BASE_COCOA_TOUCH_BAR_FORWARD_DECLARATIONS_H_ 59 #endif // UI_BASE_COCOA_TOUCH_BAR_FORWARD_DECLARATIONS_H_
OLDNEW
« no previous file with comments | « no previous file | ui/views/cocoa/bridged_content_view_touch_bar.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698