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

Unified Diff: ui/base/cocoa/touch_bar_forward_declarations.h

Issue 2530633002: Revert of [Mac] Switch from NSObject categories to forward declarations for Touch Bar support. (pat… (Closed)
Patch Set: Created 4 years, 1 month 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/cocoa/touch_bar_forward_declarations.h
diff --git a/ui/base/cocoa/touch_bar_forward_declarations.h b/ui/base/cocoa/touch_bar_forward_declarations.h
index 5fd9b962ac5f08c931c7c35b37142e2851bc86d3..54c68ae534ba473664f61d8cdc69de1982752224 100644
--- a/ui/base/cocoa/touch_bar_forward_declarations.h
+++ b/ui/base/cocoa/touch_bar_forward_declarations.h
@@ -5,101 +5,54 @@
#ifndef UI_BASE_COCOA_TOUCH_BAR_FORWARD_DECLARATIONS_H_
#define UI_BASE_COCOA_TOUCH_BAR_FORWARD_DECLARATIONS_H_
-// Once Chrome is built with the 10.12.1 SDK, the NSTouchBar… classes can be
-// referred to normally (instead of with NSClassFromString(@"…")), and this
-// file can be deleted.
+// Once Chrome no longer supports OSX 10.12.0, this file can be deleted.
#import <Foundation/Foundation.h>
#if !defined(MAC_OS_X_VERSION_10_12_1)
-#define __NSi_10_12_1 introduced = 10.12.1
-NS_ASSUME_NONNULL_BEGIN
+// The TouchBar classes do not exist at all without the 10.12.1 SDK. When
+// compiling with older SDKs, pretend they are NSObject and add categories to
+// NSObject to expose the methods.
+// To alloc one of these classes, use -[NSClassFromString(@"..") alloc].
-@class NSTouchBar, NSTouchBarItem;
-@protocol NSTouchBarDelegate;
-
-typedef float NSTouchBarItemPriority;
-static const NSTouchBarItemPriority NSTouchBarItemPriorityHigh = 1000;
-static const NSTouchBarItemPriority NSTouchBarItemPriorityNormal = 0;
-static const NSTouchBarItemPriority NSTouchBarItemPriorityLow = -1000;
+// Incomplete. Add more as necessary.
+typedef NSObject NSCustomTouchBarItem;
+typedef NSObject NSGroupTouchBarItem;
+typedef NSObject NSTouchBar;
+typedef NSObject NSTouchBarItem;
typedef NSString* NSTouchBarItemIdentifier;
-typedef NSString* NSTouchBarCustomizationIdentifier;
-
-NS_CLASS_AVAILABLE_MAC(10_12_1)
-@interface NSTouchBar : NSObject<NSCoding>
-
-- (instancetype)init NS_DESIGNATED_INITIALIZER;
-- (nullable instancetype)initWithCoder:(NSCoder*)aDecoder
- NS_DESIGNATED_INITIALIZER;
-
-@property(copy, nullable)
- NSTouchBarCustomizationIdentifier customizationIdentifier;
-@property(copy) NSArray* customizationAllowedItemIdentifiers;
-@property(copy) NSArray* customizationRequiredItemIdentifiers;
-@property(copy) NSArray* defaultItemIdentifiers;
-@property(copy, readonly) NSArray* itemIdentifiers;
-@property(copy, nullable) NSTouchBarItemIdentifier principalItemIdentifier;
-@property(copy) NSSet* templateItems;
-@property(nullable, weak) id<NSTouchBarDelegate> delegate;
-
-- (nullable __kindof NSTouchBarItem*)itemForIdentifier:
- (NSTouchBarItemIdentifier)identifier;
-
-@property(readonly, getter=isVisible) BOOL visible;
+@protocol NSTouchBarDelegate<NSObject>
@end
-NS_CLASS_AVAILABLE_MAC(10_12_1)
-@interface NSTouchBarItem : NSObject<NSCoding>
-
-- (instancetype)initWithIdentifier:(NSTouchBarItemIdentifier)identifier
- NS_DESIGNATED_INITIALIZER;
-- (nullable instancetype)initWithCoder:(NSCoder*)coder
- NS_DESIGNATED_INITIALIZER;
-- (instancetype)init NS_UNAVAILABLE;
-
-@property(readonly, copy) NSTouchBarItemIdentifier identifier;
-@property NSTouchBarItemPriority visibilityPriority;
-@property(readonly, nullable) NSView* view;
-@property(readonly, nullable) NSViewController* viewController;
-@property(readonly, copy) NSString* customizationLabel;
-@property(readonly, getter=isVisible) BOOL visible;
-
+@interface NSObject (FakeNSCustomTouchBarItem)
+@property(readwrite, strong) NSView* view;
@end
-NS_CLASS_AVAILABLE_MAC(10_12_1)
-@interface NSGroupTouchBarItem : NSTouchBarItem
-
+@interface NSObject (FakeNSGroupTouchBarItem)
+ (NSGroupTouchBarItem*)groupItemWithIdentifier:
(NSTouchBarItemIdentifier)identifier
items:(NSArray*)items;
-
-@property(strong) NSTouchBar* groupTouchBar;
-@property(readwrite, copy, null_resettable) NSString* customizationLabel;
-
@end
-NS_CLASS_AVAILABLE_MAC(10_12_1)
-@interface NSCustomTouchBarItem : NSTouchBarItem
-
-@property(readwrite, strong) __kindof NSView* view;
-@property(readwrite, strong, nullable)
- __kindof NSViewController* viewController;
-@property(readwrite, copy, null_resettable) NSString* customizationLabel;
-
+@interface NSObject (FakeNSTouchBar)
+@property(copy) NSArray* defaultItemIdentifiers;
+@property(copy) NSTouchBarItemIdentifier principalItemIdentifier;
+@property(weak) id<NSTouchBarDelegate> delegate;
@end
-@protocol NSTouchBarDelegate<NSObject>
+#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12_1
-@optional
-- (nullable NSTouchBarItem*)touchBar:(NSTouchBar*)touchBar
- makeItemForIdentifier:(NSTouchBarItemIdentifier)identifier
- NS_AVAILABLE_MAC(10_12_1);
-@end
+// When compiling against the 10.12.1 SDK or later, just provide forward
+// declarations to suppress the partial availability warnings.
-NS_ASSUME_NONNULL_END
+@class NSCustomTouchBarItem;
+@class NSGroupTouchBarItem;
+@class NSTouchBar;
+@protocol NSTouchBarDelegate;
+@class NSTouchBarItem;
#endif // MAC_OS_X_VERSION_10_12_1
« 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