From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 20 Sep 2018 17:48:49 -0700 Subject: mas: disable private window-frame APIs Disable private window frame APIs (NSNextStepFrame and NSThemeFrame) for MAS build. diff --git a/components/remote_cocoa/app_shim/browser_native_widget_window_mac.mm b/components/remote_cocoa/app_shim/browser_native_widget_window_mac.mm index 3234ed46122056d58f33d17f33c8083a0e8e9d0a..6a7c75cddeaf46275a1628e187fd3907aaf53e75 100644 --- a/components/remote_cocoa/app_shim/browser_native_widget_window_mac.mm +++ b/components/remote_cocoa/app_shim/browser_native_widget_window_mac.mm @@ -13,6 +13,7 @@ #error "This file requires ARC support." #endif +#if !IS_MAS_BUILD() @interface NSWindow (PrivateBrowserNativeWidgetAPI) + (Class)frameViewClassForStyleMask:(NSUInteger)windowStyle; @end @@ -73,10 +74,13 @@ - (BOOL)_shouldCenterTrafficLights { @end +#endif // MAS_BUILD + @implementation BrowserNativeWidgetWindow // NSWindow (PrivateAPI) overrides. +#if !IS_MAS_BUILD() + (Class)frameViewClassForStyleMask:(NSUInteger)windowStyle { // - NSThemeFrame and its subclasses will be nil if it's missing at runtime. if ([BrowserWindowFrame class]) @@ -91,6 +95,8 @@ - (BOOL)_usesCustomDrawing { return NO; } +#endif // MAS_BUILD + // Handle "Move focus to the window toolbar" configured in System Preferences -> // Keyboard -> Shortcuts -> Keyboard. Usually Ctrl+F5. The argument (|unknown|) // tends to just be nil. diff --git a/components/remote_cocoa/app_shim/native_widget_mac_frameless_nswindow.mm b/components/remote_cocoa/app_shim/native_widget_mac_frameless_nswindow.mm index 2d4be7e4df5a0f6de9046593434eb276e28232f9..c727984807d555b8e6ab8fe37d9a6daa8c091663 100644 --- a/components/remote_cocoa/app_shim/native_widget_mac_frameless_nswindow.mm +++ b/components/remote_cocoa/app_shim/native_widget_mac_frameless_nswindow.mm @@ -8,6 +8,8 @@ #error "This file requires ARC support." #endif +#if !IS_MAS_BUILD() + @interface NSWindow (PrivateAPI) + (Class)frameViewClassForStyleMask:(NSUInteger)windowStyle; @end @@ -22,8 +24,12 @@ - (CGFloat)_titlebarHeight { } @end +#endif // MAS_BUILD + @implementation NativeWidgetMacFramelessNSWindow +#if !IS_MAS_BUILD() + + (Class)frameViewClassForStyleMask:(NSUInteger)windowStyle { if ([NativeWidgetMacFramelessNSWindowFrame class]) { return [NativeWidgetMacFramelessNSWindowFrame class]; @@ -31,4 +37,6 @@ + (Class)frameViewClassForStyleMask:(NSUInteger)windowStyle { return [super frameViewClassForStyleMask:windowStyle]; } +#endif // MAS_BUILD + @end diff --git a/components/remote_cocoa/app_shim/native_widget_mac_nswindow.h b/components/remote_cocoa/app_shim/native_widget_mac_nswindow.h index 841358dd85201f4972e4c91a334e55b81867d2ec..0069d4f904c527fa3c280c723574fe2c62c282b8 100644 --- a/components/remote_cocoa/app_shim/native_widget_mac_nswindow.h +++ b/components/remote_cocoa/app_shim/native_widget_mac_nswindow.h @@ -17,6 +17,7 @@ class NativeWidgetNSWindowBridge; @protocol WindowTouchBarDelegate; +#if !IS_MAS_BUILD() // Weak lets Chrome launch even if a future macOS doesn't have the below classes WEAK_IMPORT_ATTRIBUTE @interface NSNextStepFrame : NSView @@ -33,6 +34,7 @@ REMOTE_COCOA_APP_SHIM_EXPORT REMOTE_COCOA_APP_SHIM_EXPORT @interface NativeWidgetMacNSWindowTitledFrame : NSThemeFrame @end +#endif // The NSWindow used by BridgedNativeWidget. Provides hooks into AppKit that // can only be accomplished by overriding methods. diff --git a/components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm b/components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm index 8a89e3e1759b9785f069546aa564520a9375f0c2..fd09550a2f1fe59ba0d38a258107573a052fd784 100644 --- a/components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm +++ b/components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm @@ -106,7 +106,9 @@ void OrderChildWindow(NSWindow* child_window, } // namespace @interface NSWindow (Private) +#if !IS_MAS_BUILD() + (Class)frameViewClassForStyleMask:(NSWindowStyleMask)windowStyle; +#endif - (BOOL)hasKeyAppearance; - (long long)_resizeDirectionForMouseLocation:(CGPoint)location; - (BOOL)_isConsideredOpenForPersistentState; @@ -150,6 +152,8 @@ - (void)cr_mouseDownOnFrameView:(NSEvent*)event { } @end +#if !IS_MAS_BUILD() + @implementation NativeWidgetMacNSWindowTitledFrame - (void)mouseDown:(NSEvent*)event { if (self.window.isMovable) @@ -176,6 +180,8 @@ - (BOOL)usesCustomDrawing { } @end +#endif // MAS_BUILD + @implementation NativeWidgetMacNSWindow { @private CommandDispatcher* __strong _commandDispatcher; @@ -381,6 +387,8 @@ - (NSAccessibilityRole)accessibilityRole { // NSWindow overrides. +#if !IS_MAS_BUILD() + + (Class)frameViewClassForStyleMask:(NSWindowStyleMask)windowStyle { if (windowStyle & NSWindowStyleMaskTitled) { if (Class customFrame = [NativeWidgetMacNSWindowTitledFrame class]) @@ -392,6 +400,8 @@ + (Class)frameViewClassForStyleMask:(NSWindowStyleMask)windowStyle { return [super frameViewClassForStyleMask:windowStyle]; } +#endif + - (BOOL)_isTitleHidden { bool shouldShowWindowTitle = YES; if (_bridge)