| 
									
										
										
										
											2020-01-13 23:04:38 +09:00
										 |  |  | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | 
					
						
							|  |  |  | From: Cheng Zhao <zcbenz@gmail.com> | 
					
						
							|  |  |  | Date: Thu, 20 Sep 2018 17:48:49 -0700 | 
					
						
							| 
									
										
										
										
											2021-05-19 11:20:12 -07:00
										 |  |  | Subject: mas: disable private window-frame APIs | 
					
						
							| 
									
										
										
										
											2020-01-13 23:04:38 +09:00
										 |  |  | 
 | 
					
						
							|  |  |  | 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
 | 
					
						
							| 
									
										
										
										
											2023-07-16 16:14:43 +02:00
										 |  |  | index 3234ed46122056d58f33d17f33c8083a0e8e9d0a..6a7c75cddeaf46275a1628e187fd3907aaf53e75 100644
 | 
					
						
							| 
									
										
										
										
											2020-01-13 23:04:38 +09:00
										 |  |  | --- a/components/remote_cocoa/app_shim/browser_native_widget_window_mac.mm
 | 
					
						
							|  |  |  | +++ b/components/remote_cocoa/app_shim/browser_native_widget_window_mac.mm
 | 
					
						
							| 
									
										
										
										
											2023-07-16 16:14:43 +02:00
										 |  |  | @@ -13,6 +13,7 @@
 | 
					
						
							|  |  |  |  #error "This file requires ARC support." | 
					
						
							|  |  |  |  #endif | 
					
						
							| 
									
										
										
										
											2020-01-13 23:04:38 +09:00
										 |  |  |   | 
					
						
							| 
									
										
										
										
											2022-11-14 12:46:52 -08:00
										 |  |  | +#if !IS_MAS_BUILD()
 | 
					
						
							| 
									
										
										
										
											2020-01-13 23:04:38 +09:00
										 |  |  |  @interface NSWindow (PrivateBrowserNativeWidgetAPI) | 
					
						
							|  |  |  |  + (Class)frameViewClassForStyleMask:(NSUInteger)windowStyle; | 
					
						
							|  |  |  |  @end | 
					
						
							| 
									
										
										
										
											2023-07-16 16:14:43 +02:00
										 |  |  | @@ -73,10 +74,13 @@ - (BOOL)_shouldCenterTrafficLights {
 | 
					
						
							| 
									
										
										
										
											2020-01-13 23:04:38 +09:00
										 |  |  |   | 
					
						
							|  |  |  |  @end | 
					
						
							|  |  |  |   | 
					
						
							|  |  |  | +#endif  // MAS_BUILD
 | 
					
						
							|  |  |  | +
 | 
					
						
							|  |  |  |  @implementation BrowserNativeWidgetWindow | 
					
						
							|  |  |  |   | 
					
						
							|  |  |  |  // NSWindow (PrivateAPI) overrides. | 
					
						
							|  |  |  |   | 
					
						
							| 
									
										
										
										
											2022-11-14 12:46:52 -08:00
										 |  |  | +#if !IS_MAS_BUILD()
 | 
					
						
							| 
									
										
										
										
											2020-01-13 23:04:38 +09:00
										 |  |  |  + (Class)frameViewClassForStyleMask:(NSUInteger)windowStyle { | 
					
						
							|  |  |  |    // - NSThemeFrame and its subclasses will be nil if it's missing at runtime. | 
					
						
							|  |  |  |    if ([BrowserWindowFrame class]) | 
					
						
							| 
									
										
										
										
											2023-07-16 16:14:43 +02:00
										 |  |  | @@ -91,6 +95,8 @@ - (BOOL)_usesCustomDrawing {
 | 
					
						
							| 
									
										
										
										
											2020-01-13 23:04:38 +09:00
										 |  |  |    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
 | 
					
						
							| 
									
										
										
										
											2023-07-16 16:14:43 +02:00
										 |  |  | index 2d4be7e4df5a0f6de9046593434eb276e28232f9..c727984807d555b8e6ab8fe37d9a6daa8c091663 100644
 | 
					
						
							| 
									
										
										
										
											2020-01-13 23:04:38 +09:00
										 |  |  | --- a/components/remote_cocoa/app_shim/native_widget_mac_frameless_nswindow.mm
 | 
					
						
							|  |  |  | +++ b/components/remote_cocoa/app_shim/native_widget_mac_frameless_nswindow.mm
 | 
					
						
							| 
									
										
										
										
											2023-07-16 16:14:43 +02:00
										 |  |  | @@ -8,6 +8,8 @@
 | 
					
						
							|  |  |  |  #error "This file requires ARC support." | 
					
						
							|  |  |  |  #endif | 
					
						
							| 
									
										
										
										
											2020-01-13 23:04:38 +09:00
										 |  |  |   | 
					
						
							| 
									
										
										
										
											2022-11-14 12:46:52 -08:00
										 |  |  | +#if !IS_MAS_BUILD()
 | 
					
						
							| 
									
										
										
										
											2020-01-13 23:04:38 +09:00
										 |  |  | +
 | 
					
						
							|  |  |  |  @interface NSWindow (PrivateAPI) | 
					
						
							|  |  |  |  + (Class)frameViewClassForStyleMask:(NSUInteger)windowStyle; | 
					
						
							|  |  |  |  @end | 
					
						
							| 
									
										
										
										
											2023-07-16 16:14:43 +02:00
										 |  |  | @@ -22,8 +24,12 @@ - (CGFloat)_titlebarHeight {
 | 
					
						
							| 
									
										
										
										
											2020-01-13 23:04:38 +09:00
										 |  |  |  } | 
					
						
							|  |  |  |  @end | 
					
						
							|  |  |  |   | 
					
						
							|  |  |  | +#endif  // MAS_BUILD
 | 
					
						
							|  |  |  | +
 | 
					
						
							|  |  |  |  @implementation NativeWidgetMacFramelessNSWindow | 
					
						
							|  |  |  |   | 
					
						
							| 
									
										
										
										
											2022-11-14 12:46:52 -08:00
										 |  |  | +#if !IS_MAS_BUILD()
 | 
					
						
							| 
									
										
										
										
											2020-01-13 23:04:38 +09:00
										 |  |  | +
 | 
					
						
							|  |  |  |  + (Class)frameViewClassForStyleMask:(NSUInteger)windowStyle { | 
					
						
							|  |  |  |    if ([NativeWidgetMacFramelessNSWindowFrame class]) { | 
					
						
							|  |  |  |      return [NativeWidgetMacFramelessNSWindowFrame class]; | 
					
						
							| 
									
										
										
										
											2023-07-16 16:14:43 +02:00
										 |  |  | @@ -31,4 +37,6 @@ + (Class)frameViewClassForStyleMask:(NSUInteger)windowStyle {
 | 
					
						
							| 
									
										
										
										
											2020-01-13 23:04:38 +09:00
										 |  |  |    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
 | 
					
						
							| 
									
										
										
										
											2023-08-04 10:47:29 +02:00
										 |  |  | index 841358dd85201f4972e4c91a334e55b81867d2ec..0069d4f904c527fa3c280c723574fe2c62c282b8 100644
 | 
					
						
							| 
									
										
										
										
											2020-01-13 23:04:38 +09:00
										 |  |  | --- 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; | 
					
						
							|  |  |  |   | 
					
						
							| 
									
										
										
										
											2022-11-14 12:46:52 -08:00
										 |  |  | +#if !IS_MAS_BUILD()
 | 
					
						
							| 
									
										
										
										
											2020-01-13 23:04:38 +09:00
										 |  |  |  // 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
 | 
					
						
							| 
									
										
										
										
											2023-08-04 10:47:29 +02:00
										 |  |  | index 8a89e3e1759b9785f069546aa564520a9375f0c2..fd09550a2f1fe59ba0d38a258107573a052fd784 100644
 | 
					
						
							| 
									
										
										
										
											2020-01-13 23:04:38 +09:00
										 |  |  | --- a/components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm
 | 
					
						
							|  |  |  | +++ b/components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm
 | 
					
						
							| 
									
										
										
										
											2023-08-04 10:47:29 +02:00
										 |  |  | @@ -106,7 +106,9 @@ void OrderChildWindow(NSWindow* child_window,
 | 
					
						
							| 
									
										
										
										
											2022-06-27 15:50:08 -05:00
										 |  |  |  }  // namespace | 
					
						
							| 
									
										
										
										
											2020-01-13 23:04:38 +09:00
										 |  |  |   | 
					
						
							|  |  |  |  @interface NSWindow (Private) | 
					
						
							| 
									
										
										
										
											2022-11-14 12:46:52 -08:00
										 |  |  | +#if !IS_MAS_BUILD()
 | 
					
						
							| 
									
										
										
										
											2020-01-13 23:04:38 +09:00
										 |  |  |  + (Class)frameViewClassForStyleMask:(NSWindowStyleMask)windowStyle; | 
					
						
							|  |  |  | +#endif
 | 
					
						
							|  |  |  |  - (BOOL)hasKeyAppearance; | 
					
						
							|  |  |  |  - (long long)_resizeDirectionForMouseLocation:(CGPoint)location; | 
					
						
							|  |  |  |  - (BOOL)_isConsideredOpenForPersistentState; | 
					
						
							| 
									
										
										
										
											2023-08-04 10:47:29 +02:00
										 |  |  | @@ -150,6 +152,8 @@ - (void)cr_mouseDownOnFrameView:(NSEvent*)event {
 | 
					
						
							| 
									
										
										
										
											2020-01-13 23:04:38 +09:00
										 |  |  |  } | 
					
						
							|  |  |  |  @end | 
					
						
							|  |  |  |   | 
					
						
							| 
									
										
										
										
											2022-11-14 12:46:52 -08:00
										 |  |  | +#if !IS_MAS_BUILD()
 | 
					
						
							| 
									
										
										
										
											2020-01-13 23:04:38 +09:00
										 |  |  | +
 | 
					
						
							|  |  |  |  @implementation NativeWidgetMacNSWindowTitledFrame | 
					
						
							|  |  |  |  - (void)mouseDown:(NSEvent*)event { | 
					
						
							| 
									
										
										
										
											2020-08-12 11:33:58 -07:00
										 |  |  |    if (self.window.isMovable) | 
					
						
							| 
									
										
										
										
											2023-08-04 10:47:29 +02:00
										 |  |  | @@ -176,6 +180,8 @@ - (BOOL)usesCustomDrawing {
 | 
					
						
							| 
									
										
										
										
											2020-01-13 23:04:38 +09:00
										 |  |  |  } | 
					
						
							|  |  |  |  @end | 
					
						
							|  |  |  |   | 
					
						
							|  |  |  | +#endif  // MAS_BUILD
 | 
					
						
							|  |  |  | +
 | 
					
						
							|  |  |  |  @implementation NativeWidgetMacNSWindow { | 
					
						
							|  |  |  |   @private | 
					
						
							| 
									
										
										
										
											2023-07-16 16:14:43 +02:00
										 |  |  |    CommandDispatcher* __strong _commandDispatcher; | 
					
						
							| 
									
										
										
										
											2023-08-04 10:47:29 +02:00
										 |  |  | @@ -381,6 +387,8 @@ - (NSAccessibilityRole)accessibilityRole {
 | 
					
						
							| 
									
										
										
										
											2020-01-13 23:04:38 +09:00
										 |  |  |   | 
					
						
							|  |  |  |  // NSWindow overrides. | 
					
						
							|  |  |  |   | 
					
						
							| 
									
										
										
										
											2022-11-14 12:46:52 -08:00
										 |  |  | +#if !IS_MAS_BUILD()
 | 
					
						
							| 
									
										
										
										
											2020-01-13 23:04:38 +09:00
										 |  |  | +
 | 
					
						
							|  |  |  |  + (Class)frameViewClassForStyleMask:(NSWindowStyleMask)windowStyle { | 
					
						
							|  |  |  |    if (windowStyle & NSWindowStyleMaskTitled) { | 
					
						
							|  |  |  |      if (Class customFrame = [NativeWidgetMacNSWindowTitledFrame class]) | 
					
						
							| 
									
										
										
										
											2023-08-04 10:47:29 +02:00
										 |  |  | @@ -392,6 +400,8 @@ + (Class)frameViewClassForStyleMask:(NSWindowStyleMask)windowStyle {
 | 
					
						
							| 
									
										
										
										
											2020-01-13 23:04:38 +09:00
										 |  |  |    return [super frameViewClassForStyleMask:windowStyle]; | 
					
						
							|  |  |  |  } | 
					
						
							|  |  |  |   | 
					
						
							|  |  |  | +#endif
 | 
					
						
							|  |  |  | +
 | 
					
						
							|  |  |  |  - (BOOL)_isTitleHidden { | 
					
						
							|  |  |  |    bool shouldShowWindowTitle = YES; | 
					
						
							|  |  |  |    if (_bridge) |