2020-01-13 14:04:38 +00: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 18:20:12 +00:00
|
|
|
Subject: mas: disable private window-frame APIs
|
2020-01-13 14:04:38 +00: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-03-31 02:03:58 +00:00
|
|
|
index b31c3be1895f7ca4a0f5c61f06a66eb1e1fbc5a6..ad4a1ecb02573bb5d34d134c61ec71f3fb092f42 100644
|
2020-01-13 14:04:38 +00: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
|
|
|
|
@@ -9,6 +9,7 @@
|
|
|
|
#include "components/remote_cocoa/app_shim/native_widget_ns_window_bridge.h"
|
|
|
|
#include "components/remote_cocoa/common/native_widget_ns_window_host.mojom.h"
|
|
|
|
|
2022-11-14 20:46:52 +00:00
|
|
|
+#if !IS_MAS_BUILD()
|
2020-01-13 14:04:38 +00:00
|
|
|
@interface NSWindow (PrivateBrowserNativeWidgetAPI)
|
|
|
|
+ (Class)frameViewClassForStyleMask:(NSUInteger)windowStyle;
|
|
|
|
@end
|
2023-03-31 02:03:58 +00:00
|
|
|
@@ -69,10 +70,13 @@ - (BOOL)_shouldCenterTrafficLights {
|
2020-01-13 14:04:38 +00:00
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
+#endif // MAS_BUILD
|
|
|
|
+
|
|
|
|
@implementation BrowserNativeWidgetWindow
|
|
|
|
|
|
|
|
// NSWindow (PrivateAPI) overrides.
|
|
|
|
|
2022-11-14 20:46:52 +00:00
|
|
|
+#if !IS_MAS_BUILD()
|
2020-01-13 14:04:38 +00:00
|
|
|
+ (Class)frameViewClassForStyleMask:(NSUInteger)windowStyle {
|
|
|
|
// - NSThemeFrame and its subclasses will be nil if it's missing at runtime.
|
|
|
|
if ([BrowserWindowFrame class])
|
2023-03-31 02:03:58 +00:00
|
|
|
@@ -87,6 +91,8 @@ - (BOOL)_usesCustomDrawing {
|
2020-01-13 14:04:38 +00: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
|
2022-11-14 20:46:52 +00:00
|
|
|
index 3a815ebf505bd95fa7f6b61ba433d98fbfe20225..dbbebbdc1735bc14224dfcde0b7fe3a6fd9f9e40 100644
|
2020-01-13 14:04:38 +00: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
|
|
|
|
@@ -4,6 +4,8 @@
|
|
|
|
|
|
|
|
#import "components/remote_cocoa/app_shim/native_widget_mac_frameless_nswindow.h"
|
|
|
|
|
2022-11-14 20:46:52 +00:00
|
|
|
+#if !IS_MAS_BUILD()
|
2020-01-13 14:04:38 +00:00
|
|
|
+
|
|
|
|
@interface NSWindow (PrivateAPI)
|
|
|
|
+ (Class)frameViewClassForStyleMask:(NSUInteger)windowStyle;
|
|
|
|
@end
|
2020-08-10 15:23:21 +00:00
|
|
|
@@ -18,8 +20,12 @@ - (CGFloat)_titlebarHeight {
|
2020-01-13 14:04:38 +00:00
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
|
|
+#endif // MAS_BUILD
|
|
|
|
+
|
|
|
|
@implementation NativeWidgetMacFramelessNSWindow
|
|
|
|
|
2022-11-14 20:46:52 +00:00
|
|
|
+#if !IS_MAS_BUILD()
|
2020-01-13 14:04:38 +00:00
|
|
|
+
|
|
|
|
+ (Class)frameViewClassForStyleMask:(NSUInteger)windowStyle {
|
|
|
|
if ([NativeWidgetMacFramelessNSWindowFrame class]) {
|
|
|
|
return [NativeWidgetMacFramelessNSWindowFrame class];
|
2020-08-10 15:23:21 +00:00
|
|
|
@@ -27,4 +33,6 @@ + (Class)frameViewClassForStyleMask:(NSUInteger)windowStyle {
|
2020-01-13 14:04:38 +00: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-04-03 16:56:57 +00:00
|
|
|
index 58e974137f318b0f990e0b77630fe3a51db62c8c..8638f9ee32bea5fca67a377f27f3e24b00982e44 100644
|
2020-01-13 14:04:38 +00: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 20:46:52 +00:00
|
|
|
+#if !IS_MAS_BUILD()
|
2020-01-13 14:04:38 +00: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-05-23 19:58:58 +00:00
|
|
|
index e90c7946c683f23852c785769e1c2809ec4f4961..6ebef9ed0e77fd215f3ee58c542549345d5e630c 100644
|
2020-01-13 14:04:38 +00:00
|
|
|
--- a/components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm
|
|
|
|
+++ b/components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm
|
2023-03-10 16:07:42 +00:00
|
|
|
@@ -96,7 +96,9 @@ void OrderChildWindow(NSWindow* child_window,
|
2022-06-27 20:50:08 +00:00
|
|
|
} // namespace
|
2020-01-13 14:04:38 +00:00
|
|
|
|
|
|
|
@interface NSWindow (Private)
|
2022-11-14 20:46:52 +00:00
|
|
|
+#if !IS_MAS_BUILD()
|
2020-01-13 14:04:38 +00:00
|
|
|
+ (Class)frameViewClassForStyleMask:(NSWindowStyleMask)windowStyle;
|
|
|
|
+#endif
|
|
|
|
- (BOOL)hasKeyAppearance;
|
|
|
|
- (long long)_resizeDirectionForMouseLocation:(CGPoint)location;
|
|
|
|
- (BOOL)_isConsideredOpenForPersistentState;
|
2023-05-23 19:58:58 +00:00
|
|
|
@@ -134,6 +136,8 @@ - (void)cr_mouseDownOnFrameView:(NSEvent*)event {
|
2020-01-13 14:04:38 +00:00
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
2022-11-14 20:46:52 +00:00
|
|
|
+#if !IS_MAS_BUILD()
|
2020-01-13 14:04:38 +00:00
|
|
|
+
|
|
|
|
@implementation NativeWidgetMacNSWindowTitledFrame
|
|
|
|
- (void)mouseDown:(NSEvent*)event {
|
2020-08-12 18:33:58 +00:00
|
|
|
if (self.window.isMovable)
|
2023-05-23 19:58:58 +00:00
|
|
|
@@ -160,6 +164,8 @@ - (BOOL)usesCustomDrawing {
|
2020-01-13 14:04:38 +00:00
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
|
|
+#endif // MAS_BUILD
|
|
|
|
+
|
|
|
|
@implementation NativeWidgetMacNSWindow {
|
|
|
|
@private
|
|
|
|
base::scoped_nsobject<CommandDispatcher> _commandDispatcher;
|
2023-05-23 19:58:58 +00:00
|
|
|
@@ -355,6 +361,8 @@ - (NSAccessibilityRole)accessibilityRole {
|
2020-01-13 14:04:38 +00:00
|
|
|
|
|
|
|
// NSWindow overrides.
|
|
|
|
|
2022-11-14 20:46:52 +00:00
|
|
|
+#if !IS_MAS_BUILD()
|
2020-01-13 14:04:38 +00:00
|
|
|
+
|
|
|
|
+ (Class)frameViewClassForStyleMask:(NSWindowStyleMask)windowStyle {
|
|
|
|
if (windowStyle & NSWindowStyleMaskTitled) {
|
|
|
|
if (Class customFrame = [NativeWidgetMacNSWindowTitledFrame class])
|
2023-05-23 19:58:58 +00:00
|
|
|
@@ -366,6 +374,8 @@ + (Class)frameViewClassForStyleMask:(NSWindowStyleMask)windowStyle {
|
2020-01-13 14:04:38 +00:00
|
|
|
return [super frameViewClassForStyleMask:windowStyle];
|
|
|
|
}
|
|
|
|
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
- (BOOL)_isTitleHidden {
|
|
|
|
bool shouldShowWindowTitle = YES;
|
|
|
|
if (_bridge)
|