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

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

Issue 2519563002: [Mac] Switch from NSObject categories to forward declarations for Touch Bar support. (Closed)
Patch Set: Tweak comment, change `retain` back to `strong` in interfaces from Apple headers. 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 no longer supports OSX 10.12.0, this file can be deleted. 8 // Once Chrome is built with the 10.12.1 SDK, the NSTouchBar… classes can be
9 // referred to normally (instead of with NSClassFromString(@"…")), and this
10 // file can be deleted.
9 11
10 #import <Foundation/Foundation.h> 12 #import <Foundation/Foundation.h>
11 13
12 #if !defined(MAC_OS_X_VERSION_10_12_1) 14 #if !defined(MAC_OS_X_VERSION_10_12_1)
15 #define __NSi_10_12_1 introduced = 10.12.1
13 16
14 // The TouchBar classes do not exist at all without the 10.12.1 SDK. When 17 NS_ASSUME_NONNULL_BEGIN
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 // Incomplete. Add more as necessary. 19 @class NSTouchBar, NSTouchBarItem;
20 @protocol NSTouchBarDelegate;
20 21
21 typedef NSObject NSCustomTouchBarItem; 22 typedef float NSTouchBarItemPriority;
22 typedef NSObject NSGroupTouchBarItem; 23 static const NSTouchBarItemPriority NSTouchBarItemPriorityHigh = 1000;
23 typedef NSObject NSTouchBar; 24 static const NSTouchBarItemPriority NSTouchBarItemPriorityNormal = 0;
24 typedef NSObject NSTouchBarItem; 25 static const NSTouchBarItemPriority NSTouchBarItemPriorityLow = -1000;
26
25 typedef NSString* NSTouchBarItemIdentifier; 27 typedef NSString* NSTouchBarItemIdentifier;
28 typedef NSString* NSTouchBarCustomizationIdentifier;
26 29
27 @protocol NSTouchBarDelegate<NSObject> 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
28 @end 52 @end
29 53
30 @interface NSObject (FakeNSCustomTouchBarItem) 54 NS_CLASS_AVAILABLE_MAC(10_12_1)
31 @property(readwrite, strong) NSView* view; 55 @interface NSTouchBarItem : NSObject<NSCoding>
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
32 @end 70 @end
33 71
34 @interface NSObject (FakeNSGroupTouchBarItem) 72 NS_CLASS_AVAILABLE_MAC(10_12_1)
73 @interface NSGroupTouchBarItem : NSTouchBarItem
74
35 + (NSGroupTouchBarItem*)groupItemWithIdentifier: 75 + (NSGroupTouchBarItem*)groupItemWithIdentifier:
36 (NSTouchBarItemIdentifier)identifier 76 (NSTouchBarItemIdentifier)identifier
37 items:(NSArray*)items; 77 items:(NSArray*)items;
78
79 @property(strong) NSTouchBar* groupTouchBar;
80 @property(readwrite, copy, null_resettable) NSString* customizationLabel;
81
38 @end 82 @end
39 83
40 @interface NSObject (FakeNSTouchBar) 84 NS_CLASS_AVAILABLE_MAC(10_12_1)
41 @property(copy) NSArray* defaultItemIdentifiers; 85 @interface NSCustomTouchBarItem : NSTouchBarItem
42 @property(copy) NSTouchBarItemIdentifier principalItemIdentifier; 86
43 @property(weak) id<NSTouchBarDelegate> delegate; 87 @property(readwrite, strong) __kindof NSView* view;
88 @property(readwrite, strong, nullable)
89 __kindof NSViewController* viewController;
90 @property(readwrite, copy, null_resettable) NSString* customizationLabel;
91
44 @end 92 @end
45 93
46 #elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12_1 94 @protocol NSTouchBarDelegate<NSObject>
47 95
48 // When compiling against the 10.12.1 SDK or later, just provide forward 96 @optional
49 // declarations to suppress the partial availability warnings. 97 - (nullable NSTouchBarItem*)touchBar:(NSTouchBar*)touchBar
98 makeItemForIdentifier:(NSTouchBarItemIdentifier)identifier
99 NS_AVAILABLE_MAC(10_12_1);
100 @end
50 101
51 @class NSCustomTouchBarItem; 102 NS_ASSUME_NONNULL_END
52 @class NSGroupTouchBarItem;
53 @class NSTouchBar;
54 @protocol NSTouchBarDelegate;
55 @class NSTouchBarItem;
56 103
57 #endif // MAC_OS_X_VERSION_10_12_1 104 #endif // MAC_OS_X_VERSION_10_12_1
58 105
59 #endif // UI_BASE_COCOA_TOUCH_BAR_FORWARD_DECLARATIONS_H_ 106 #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