mas_disable_custom_window_frame.patch 4.9 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_custom_window_frame.patch
  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 677279352ba9a0415814654cfb676a240a316bc3..2194a762c6a14233f2246fb320ea158879a196cd 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. @@ -9,6 +9,7 @@
  12. #include "components/remote_cocoa/app_shim/bridged_native_widget_impl.h"
  13. #include "components/remote_cocoa/common/bridged_native_widget_host.mojom.h"
  14. +#ifndef MAS_BUILD
  15. @interface NSWindow (PrivateBrowserNativeWidgetAPI)
  16. + (Class)frameViewClassForStyleMask:(NSUInteger)windowStyle;
  17. @end
  18. @@ -69,10 +70,13 @@
  19. @end
  20. +#endif // MAS_BUILD
  21. +
  22. @implementation BrowserNativeWidgetWindow
  23. // NSWindow (PrivateAPI) overrides.
  24. +#ifndef 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. @@ -87,6 +91,8 @@
  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 8416c7c6e052dafb2aad61c0bd3224c36e945d23..cd356beda023ab2409b16d58ca38c70ba3674913 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. +#ifndef MAS_BUILD
  43. +
  44. @interface NSWindow (PrivateAPI)
  45. + (Class)frameViewClassForStyleMask:(NSUInteger)windowStyle;
  46. @end
  47. @@ -18,8 +20,12 @@
  48. }
  49. @end
  50. +#endif // MAS_BUILD
  51. +
  52. @implementation NativeWidgetMacFramelessNSWindow
  53. +#ifndef MAS_BUILD
  54. +
  55. + (Class)frameViewClassForStyleMask:(NSUInteger)windowStyle {
  56. if ([NativeWidgetMacFramelessNSWindowFrame class]) {
  57. return [NativeWidgetMacFramelessNSWindowFrame class];
  58. @@ -27,4 +33,6 @@
  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 5b481e482e27f455ec4ecf03de3883d5be0d25f7..6f551699f09879f08e8f9298758a8ab0ec09c84c 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 BridgedNativeWidgetImpl;
  69. @protocol WindowTouchBarDelegate;
  70. +#ifndef 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 aa2bb3a5f886c44f8217eaca8b0d19526090b47e..198d2f03d5b4c41f280bc4d9ce93bdcd209410df 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. @@ -15,7 +15,9 @@
  86. #import "ui/base/cocoa/window_size_constants.h"
  87. @interface NSWindow (Private)
  88. +#ifndef MAS_BUILD
  89. + (Class)frameViewClassForStyleMask:(NSWindowStyleMask)windowStyle;
  90. +#endif
  91. - (BOOL)hasKeyAppearance;
  92. - (long long)_resizeDirectionForMouseLocation:(CGPoint)location;
  93. @@ -56,6 +58,8 @@
  94. }
  95. @end
  96. +#ifndef MAS_BUILD
  97. +
  98. @implementation NativeWidgetMacNSWindowTitledFrame
  99. - (void)mouseDown:(NSEvent*)event {
  100. [self cr_mouseDownOnFrameView:event];
  101. @@ -76,6 +80,8 @@
  102. }
  103. @end
  104. +#endif // MAS_BUILD
  105. +
  106. @implementation NativeWidgetMacNSWindow {
  107. @private
  108. base::scoped_nsobject<CommandDispatcher> commandDispatcher_;
  109. @@ -153,6 +159,8 @@
  110. // NSWindow overrides.
  111. +#ifndef MAS_BUILD
  112. +
  113. + (Class)frameViewClassForStyleMask:(NSWindowStyleMask)windowStyle {
  114. if (windowStyle & NSWindowStyleMaskTitled) {
  115. if (Class customFrame = [NativeWidgetMacNSWindowTitledFrame class])
  116. @@ -164,6 +172,8 @@
  117. return [super frameViewClassForStyleMask:windowStyle];
  118. }
  119. +#endif
  120. +
  121. - (BOOL)_isTitleHidden {
  122. bool shouldShowWindowTitle = YES;
  123. if (bridgeImpl_)