mas_disable_custom_window_frame.patch 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
  2. From: Cheng Zhao <[email protected]>
  3. Date: Thu, 20 Sep 2018 17:48:49 -0700
  4. Subject: mas: disable private window-frame APIs
  5. Disable private window frame APIs (NSNextStepFrame and NSThemeFrame) for MAS
  6. build.
  7. 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
  8. index 9db1a07aabdbc5ebcf5d971664a8783a3d4810a3..eed51d0af307a0bb1c6cbbcbe2dbd3c906d0999c 100644
  9. --- a/components/remote_cocoa/app_shim/browser_native_widget_window_mac.mm
  10. +++ b/components/remote_cocoa/app_shim/browser_native_widget_window_mac.mm
  11. @@ -10,6 +10,7 @@
  12. #include "components/remote_cocoa/app_shim/native_widget_ns_window_bridge.h"
  13. #include "components/remote_cocoa/common/native_widget_ns_window_host.mojom.h"
  14. +#if !IS_MAS_BUILD()
  15. @interface NSWindow (PrivateBrowserNativeWidgetAPI)
  16. + (Class)frameViewClassForStyleMask:(NSUInteger)windowStyle;
  17. @end
  18. @@ -70,10 +71,13 @@ - (BOOL)_shouldCenterTrafficLights {
  19. @end
  20. +#endif // MAS_BUILD
  21. +
  22. @implementation BrowserNativeWidgetWindow
  23. // NSWindow (PrivateAPI) overrides.
  24. +#if !IS_MAS_BUILD()
  25. + (Class)frameViewClassForStyleMask:(NSUInteger)windowStyle {
  26. // - NSThemeFrame and its subclasses will be nil if it's missing at runtime.
  27. if ([BrowserWindowFrame class])
  28. @@ -120,6 +124,8 @@ - (BOOL)_usesCustomDrawing {
  29. return NO;
  30. }
  31. +#endif // MAS_BUILD
  32. +
  33. // Handle "Move focus to the window toolbar" configured in System Preferences ->
  34. // Keyboard -> Shortcuts -> Keyboard. Usually Ctrl+F5. The argument (|unknown|)
  35. // tends to just be nil.
  36. 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
  37. index 3a815ebf505bd95fa7f6b61ba433d98fbfe20225..dbbebbdc1735bc14224dfcde0b7fe3a6fd9f9e40 100644
  38. --- a/components/remote_cocoa/app_shim/native_widget_mac_frameless_nswindow.mm
  39. +++ b/components/remote_cocoa/app_shim/native_widget_mac_frameless_nswindow.mm
  40. @@ -4,6 +4,8 @@
  41. #import "components/remote_cocoa/app_shim/native_widget_mac_frameless_nswindow.h"
  42. +#if !IS_MAS_BUILD()
  43. +
  44. @interface NSWindow (PrivateAPI)
  45. + (Class)frameViewClassForStyleMask:(NSUInteger)windowStyle;
  46. @end
  47. @@ -18,8 +20,12 @@ - (CGFloat)_titlebarHeight {
  48. }
  49. @end
  50. +#endif // MAS_BUILD
  51. +
  52. @implementation NativeWidgetMacFramelessNSWindow
  53. +#if !IS_MAS_BUILD()
  54. +
  55. + (Class)frameViewClassForStyleMask:(NSUInteger)windowStyle {
  56. if ([NativeWidgetMacFramelessNSWindowFrame class]) {
  57. return [NativeWidgetMacFramelessNSWindowFrame class];
  58. @@ -27,4 +33,6 @@ + (Class)frameViewClassForStyleMask:(NSUInteger)windowStyle {
  59. return [super frameViewClassForStyleMask:windowStyle];
  60. }
  61. +#endif // MAS_BUILD
  62. +
  63. @end
  64. diff --git a/components/remote_cocoa/app_shim/native_widget_mac_nswindow.h b/components/remote_cocoa/app_shim/native_widget_mac_nswindow.h
  65. index 94ac4fa8db42cb70fa5032a0c1eeb10ad94b8d9a..048cfe7b16d74845492c9317f1ed9790fed36250 100644
  66. --- a/components/remote_cocoa/app_shim/native_widget_mac_nswindow.h
  67. +++ b/components/remote_cocoa/app_shim/native_widget_mac_nswindow.h
  68. @@ -17,6 +17,7 @@ class NativeWidgetNSWindowBridge;
  69. @protocol WindowTouchBarDelegate;
  70. +#if !IS_MAS_BUILD()
  71. // Weak lets Chrome launch even if a future macOS doesn't have the below classes
  72. WEAK_IMPORT_ATTRIBUTE
  73. @interface NSNextStepFrame : NSView
  74. @@ -33,6 +34,7 @@ REMOTE_COCOA_APP_SHIM_EXPORT
  75. REMOTE_COCOA_APP_SHIM_EXPORT
  76. @interface NativeWidgetMacNSWindowTitledFrame : NSThemeFrame
  77. @end
  78. +#endif
  79. // The NSWindow used by BridgedNativeWidget. Provides hooks into AppKit that
  80. // can only be accomplished by overriding methods.
  81. diff --git a/components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm b/components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm
  82. index 517333705c9b68706159bff2396c3ba1f8dc1f55..f11ce18fb4d1567eb53e6b9272424eecb40e51e1 100644
  83. --- a/components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm
  84. +++ b/components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm
  85. @@ -113,7 +113,9 @@ void OrderChildWindow(NSWindow* child_window,
  86. } // namespace
  87. @interface NSWindow (Private)
  88. +#if !IS_MAS_BUILD()
  89. + (Class)frameViewClassForStyleMask:(NSWindowStyleMask)windowStyle;
  90. +#endif
  91. - (BOOL)hasKeyAppearance;
  92. - (long long)_resizeDirectionForMouseLocation:(CGPoint)location;
  93. - (BOOL)_isConsideredOpenForPersistentState;
  94. @@ -161,6 +163,8 @@ - (void)cr_mouseDownOnFrameView:(NSEvent*)event {
  95. }
  96. @end
  97. +#if !IS_MAS_BUILD()
  98. +
  99. @implementation NativeWidgetMacNSWindowTitledFrame
  100. - (void)mouseDown:(NSEvent*)event {
  101. if (self.window.isMovable)
  102. @@ -187,6 +191,8 @@ - (BOOL)usesCustomDrawing {
  103. }
  104. @end
  105. +#endif // MAS_BUILD
  106. +
  107. @implementation NativeWidgetMacNSWindow {
  108. @private
  109. CommandDispatcher* __strong _commandDispatcher;
  110. @@ -396,6 +402,8 @@ - (NSAccessibilityRole)accessibilityRole {
  111. // NSWindow overrides.
  112. +#if !IS_MAS_BUILD()
  113. +
  114. + (Class)frameViewClassForStyleMask:(NSWindowStyleMask)windowStyle {
  115. if (windowStyle & NSWindowStyleMaskTitled) {
  116. if (Class customFrame = [NativeWidgetMacNSWindowTitledFrame class])
  117. @@ -407,6 +415,8 @@ + (Class)frameViewClassForStyleMask:(NSWindowStyleMask)windowStyle {
  118. return [super frameViewClassForStyleMask:windowStyle];
  119. }
  120. +#endif
  121. +
  122. - (BOOL)_isTitleHidden {
  123. bool shouldShowWindowTitle = YES;
  124. if (_bridge)