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
|
|
|
|
Subject: mas_disable_remote_accessibility.patch
|
|
|
|
|
|
|
|
Disable remote accessibility APIs (NSAccessibilityRemoteUIElement) for MAS
|
|
|
|
build.
|
|
|
|
|
|
|
|
According to ccameron:
|
|
|
|
|
|
|
|
NSAccessibilityRemoteUIElement is unnecessary for Electron's use-case. We use it
|
|
|
|
for progressive web apps (where the AXTree is in the browser process, but macOS
|
|
|
|
needs to think it's coming from the PWA process). I think it can just be chopped
|
|
|
|
out -- if there are any side-effects, we should be able to work around them.
|
|
|
|
|
|
|
|
diff --git a/components/remote_cocoa/app_shim/application_bridge.mm b/components/remote_cocoa/app_shim/application_bridge.mm
|
2020-01-17 18:41:52 +00:00
|
|
|
index 9ddda9116e7284cbccde8a51e23ad7560dd06367..e846091ad99b0154636489e53491209ff3cbfaaa 100644
|
2020-01-13 14:04:38 +00:00
|
|
|
--- a/components/remote_cocoa/app_shim/application_bridge.mm
|
|
|
|
+++ b/components/remote_cocoa/app_shim/application_bridge.mm
|
2020-04-08 15:59:14 +00:00
|
|
|
@@ -49,6 +49,7 @@ class NativeWidgetBridgeOwner : public NativeWidgetNSWindowHostHelper {
|
2020-01-13 14:04:38 +00:00
|
|
|
|
|
|
|
// NativeWidgetNSWindowHostHelper:
|
|
|
|
id GetNativeViewAccessible() override {
|
|
|
|
+#ifndef MAS_BUILD
|
|
|
|
if (!remote_accessibility_element_) {
|
|
|
|
int64_t browser_pid = 0;
|
|
|
|
std::vector<uint8_t> element_token;
|
2020-04-08 15:59:14 +00:00
|
|
|
@@ -59,6 +60,9 @@ class NativeWidgetBridgeOwner : public NativeWidgetNSWindowHostHelper {
|
2020-01-13 14:04:38 +00:00
|
|
|
ui::RemoteAccessibility::GetRemoteElementFromToken(element_token);
|
|
|
|
}
|
|
|
|
return remote_accessibility_element_.get();
|
|
|
|
+#else
|
|
|
|
+ return nil;
|
|
|
|
+#endif
|
|
|
|
}
|
|
|
|
void DispatchKeyEvent(ui::KeyEvent* event) override {
|
|
|
|
bool event_handled = false;
|
2020-04-08 15:59:14 +00:00
|
|
|
@@ -96,8 +100,10 @@ class NativeWidgetBridgeOwner : public NativeWidgetNSWindowHostHelper {
|
2020-01-13 14:04:38 +00:00
|
|
|
mojo::AssociatedRemote<mojom::TextInputHost> text_input_host_remote_;
|
|
|
|
|
|
|
|
std::unique_ptr<NativeWidgetNSWindowBridge> bridge_;
|
|
|
|
+#ifndef MAS_BUILD
|
|
|
|
base::scoped_nsobject<NSAccessibilityRemoteUIElement>
|
|
|
|
remote_accessibility_element_;
|
|
|
|
+#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
diff --git a/components/remote_cocoa/app_shim/native_widget_ns_window_bridge.mm b/components/remote_cocoa/app_shim/native_widget_ns_window_bridge.mm
|
2020-01-31 18:36:00 +00:00
|
|
|
index 2ee45cb069ec5d78d9c7a3f61fdd1d444a590f41..badc4323b910f8e3957583e05af303472cb204f6 100644
|
2020-01-13 14:04:38 +00:00
|
|
|
--- a/components/remote_cocoa/app_shim/native_widget_ns_window_bridge.mm
|
|
|
|
+++ b/components/remote_cocoa/app_shim/native_widget_ns_window_bridge.mm
|
2020-04-08 15:59:14 +00:00
|
|
|
@@ -543,10 +543,12 @@ void NativeWidgetNSWindowBridge::CreateContentView(uint64_t ns_view_id,
|
2020-01-13 14:04:38 +00:00
|
|
|
// this should be treated as an error and caught early.
|
|
|
|
CHECK(bridged_view_);
|
|
|
|
|
|
|
|
+#ifndef MAS_BUILD
|
|
|
|
// Send the accessibility tokens for the NSView now that it exists.
|
|
|
|
host_->SetRemoteAccessibilityTokens(
|
|
|
|
ui::RemoteAccessibility::GetTokenForLocalElement(window_),
|
|
|
|
ui::RemoteAccessibility::GetTokenForLocalElement(bridged_view_));
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
// Beware: This view was briefly removed (in favor of a bare CALayer) in
|
|
|
|
// crrev/c/1236675. The ordering of unassociated layers relative to NSView
|
|
|
|
diff --git a/content/app_shim_remote_cocoa/ns_view_bridge_factory_impl.mm b/content/app_shim_remote_cocoa/ns_view_bridge_factory_impl.mm
|
2020-04-24 01:55:17 +00:00
|
|
|
index 82696053ce7cd1d47c9034899a76555af716f4ba..0ed7a32fa839b449aaacc2338f59f6ff17814891 100644
|
2020-01-13 14:04:38 +00:00
|
|
|
--- a/content/app_shim_remote_cocoa/ns_view_bridge_factory_impl.mm
|
|
|
|
+++ b/content/app_shim_remote_cocoa/ns_view_bridge_factory_impl.mm
|
2020-04-08 15:59:14 +00:00
|
|
|
@@ -66,8 +66,10 @@ class RenderWidgetHostNSViewBridgeOwner
|
2020-01-13 14:04:38 +00:00
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
void SetAccessibilityWindow(NSWindow* window) override {
|
|
|
|
+#ifndef MAS_BUILD
|
|
|
|
host_->SetRemoteAccessibilityWindowToken(
|
|
|
|
ui::RemoteAccessibility::GetTokenForLocalElement(window));
|
|
|
|
+#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void ForwardKeyboardEvent(const content::NativeWebKeyboardEvent& key_event,
|
2020-04-08 15:59:14 +00:00
|
|
|
@@ -126,8 +128,10 @@ class RenderWidgetHostNSViewBridgeOwner
|
2020-01-13 14:04:38 +00:00
|
|
|
|
|
|
|
mojo::AssociatedRemote<mojom::RenderWidgetHostNSViewHost> host_;
|
|
|
|
std::unique_ptr<RenderWidgetHostNSViewBridge> bridge_;
|
|
|
|
+#ifndef MAS_BUILD
|
|
|
|
base::scoped_nsobject<NSAccessibilityRemoteUIElement>
|
|
|
|
remote_accessibility_element_;
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostNSViewBridgeOwner);
|
|
|
|
};
|
|
|
|
diff --git a/content/browser/renderer_host/render_widget_host_view_mac.h b/content/browser/renderer_host/render_widget_host_view_mac.h
|
2020-04-24 01:55:17 +00:00
|
|
|
index c610426ad9b91505da7b529015fc19a27d5ee170..2858e299ab9788a17e006c1093f01803c223fb1b 100644
|
2020-01-13 14:04:38 +00:00
|
|
|
--- a/content/browser/renderer_host/render_widget_host_view_mac.h
|
|
|
|
+++ b/content/browser/renderer_host/render_widget_host_view_mac.h
|
|
|
|
@@ -46,7 +46,9 @@ class ScopedPasswordInputEnabler;
|
|
|
|
|
|
|
|
@protocol RenderWidgetHostViewMacDelegate;
|
|
|
|
|
|
|
|
+#ifndef MAS_BUILD
|
|
|
|
@class NSAccessibilityRemoteUIElement;
|
|
|
|
+#endif
|
|
|
|
@class RenderWidgetHostViewCocoa;
|
|
|
|
|
|
|
|
namespace content {
|
2020-04-24 01:55:17 +00:00
|
|
|
@@ -619,10 +621,12 @@ class CONTENT_EXPORT RenderWidgetHostViewMac
|
2020-01-13 14:04:38 +00:00
|
|
|
// EnsureSurfaceSynchronizedForWebTest().
|
|
|
|
uint32_t latest_capture_sequence_number_ = 0u;
|
|
|
|
|
|
|
|
+#ifndef MAS_BUILD
|
|
|
|
// Remote accessibility objects corresponding to the NSWindow that this is
|
|
|
|
// displayed to the user in.
|
|
|
|
base::scoped_nsobject<NSAccessibilityRemoteUIElement>
|
|
|
|
remote_window_accessible_;
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
// Used to force the NSApplication's focused accessibility element to be the
|
|
|
|
// content::BrowserAccessibilityCocoa accessibility tree when the NSView for
|
|
|
|
diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm
|
2020-04-24 01:55:17 +00:00
|
|
|
index c56fb05c579f3c95a132ee00a2ed83bf2cb85268..385b0dbeb7cbfb31ad0726051dc2e8fb4d7b16b2 100644
|
2020-01-13 14:04:38 +00:00
|
|
|
--- a/content/browser/renderer_host/render_widget_host_view_mac.mm
|
|
|
|
+++ b/content/browser/renderer_host/render_widget_host_view_mac.mm
|
2020-04-08 15:59:14 +00:00
|
|
|
@@ -231,8 +231,10 @@ RenderWidgetHostViewMac::~RenderWidgetHostViewMac() {
|
2020-01-13 14:04:38 +00:00
|
|
|
void RenderWidgetHostViewMac::MigrateNSViewBridge(
|
|
|
|
remote_cocoa::mojom::Application* remote_cocoa_application,
|
|
|
|
uint64_t parent_ns_view_id) {
|
|
|
|
+#ifndef MAS_BUILD
|
|
|
|
// Destroy the previous remote accessibility element.
|
|
|
|
remote_window_accessible_.reset();
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
// Disconnect from the previous bridge (this will have the effect of
|
|
|
|
// destroying the associated bridge), and close the receiver (to allow it
|
2020-04-24 01:55:17 +00:00
|
|
|
@@ -1350,8 +1352,10 @@ RenderWidgetHostViewMac::AccessibilityGetNativeViewAccessible() {
|
2020-01-13 14:04:38 +00:00
|
|
|
|
|
|
|
gfx::NativeViewAccessible
|
|
|
|
RenderWidgetHostViewMac::AccessibilityGetNativeViewAccessibleForWindow() {
|
|
|
|
+#ifndef MAS_BUILD
|
|
|
|
if (remote_window_accessible_)
|
|
|
|
return remote_window_accessible_.get();
|
|
|
|
+#endif
|
|
|
|
return [GetInProcessNSView() window];
|
|
|
|
}
|
|
|
|
|
2020-04-24 01:55:17 +00:00
|
|
|
@@ -1383,9 +1387,11 @@ id RenderWidgetHostViewMac::GetFocusedBrowserAccessibilityElement() {
|
2020-01-13 14:04:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void RenderWidgetHostViewMac::SetAccessibilityWindow(NSWindow* window) {
|
|
|
|
+#ifndef MAS_BUILD
|
|
|
|
// When running in-process, just use the NSView's NSWindow as its own
|
|
|
|
// accessibility element.
|
|
|
|
remote_window_accessible_.reset();
|
|
|
|
+#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
bool RenderWidgetHostViewMac::SyncIsWidgetForMainFrame(
|
2020-04-24 01:55:17 +00:00
|
|
|
@@ -1872,12 +1878,14 @@ void RenderWidgetHostViewMac::StopSpeaking() {
|
2020-01-13 14:04:38 +00:00
|
|
|
|
|
|
|
void RenderWidgetHostViewMac::SetRemoteAccessibilityWindowToken(
|
|
|
|
const std::vector<uint8_t>& window_token) {
|
|
|
|
+#ifndef MAS_BUILD
|
|
|
|
if (window_token.empty()) {
|
|
|
|
remote_window_accessible_.reset();
|
|
|
|
} else {
|
|
|
|
remote_window_accessible_ =
|
|
|
|
ui::RemoteAccessibility::GetRemoteElementFromToken(window_token);
|
|
|
|
}
|
|
|
|
+#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
diff --git a/ui/base/BUILD.gn b/ui/base/BUILD.gn
|
2020-04-13 23:39:26 +00:00
|
|
|
index a4c47479dd8a39f467e5ea8ed3e2bb934e911973..46047665d20233d22b0c8c451a1ce375dcb2567e 100644
|
2020-01-13 14:04:38 +00:00
|
|
|
--- a/ui/base/BUILD.gn
|
|
|
|
+++ b/ui/base/BUILD.gn
|
2020-04-13 23:39:26 +00:00
|
|
|
@@ -305,6 +305,13 @@ jumbo_component("base") {
|
2020-01-13 14:04:38 +00:00
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
+ if (is_mas_build) {
|
|
|
|
+ sources -= [
|
|
|
|
+ "cocoa/remote_accessibility_api.h",
|
|
|
|
+ "cocoa/remote_accessibility_api.mm",
|
|
|
|
+ ]
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
if (is_posix) {
|
|
|
|
sources += [ "l10n/l10n_util_posix.cc" ]
|
|
|
|
}
|
|
|
|
diff --git a/ui/base/cocoa/remote_accessibility_api.h b/ui/base/cocoa/remote_accessibility_api.h
|
2020-01-17 18:41:52 +00:00
|
|
|
index 2a58aebabb23443a2c11364af4988c573f3909ba..3424b6011e80e9c995519b6a8d652abd843d926b 100644
|
2020-01-13 14:04:38 +00:00
|
|
|
--- a/ui/base/cocoa/remote_accessibility_api.h
|
|
|
|
+++ b/ui/base/cocoa/remote_accessibility_api.h
|
|
|
|
@@ -11,6 +11,8 @@
|
|
|
|
#include "base/mac/scoped_nsobject.h"
|
|
|
|
#include "ui/base/ui_base_export.h"
|
|
|
|
|
|
|
|
+#ifndef MAS_BUILD
|
|
|
|
+
|
|
|
|
@interface NSAccessibilityRemoteUIElement : NSObject
|
|
|
|
+ (void)registerRemoteUIProcessIdentifier:(int)pid;
|
|
|
|
+ (NSData*)remoteTokenForLocalUIElement:(id)element;
|
|
|
|
@@ -32,4 +34,6 @@ class UI_BASE_EXPORT RemoteAccessibility {
|
|
|
|
|
|
|
|
} // namespace ui
|
|
|
|
|
|
|
|
+#endif // MAS_BUILD
|
|
|
|
+
|
|
|
|
#endif // UI_BASE_COCOA_REMOTE_ACCESSIBILITY_API_H_
|
|
|
|
diff --git a/ui/views/cocoa/native_widget_mac_ns_window_host.h b/ui/views/cocoa/native_widget_mac_ns_window_host.h
|
2020-04-13 23:39:26 +00:00
|
|
|
index 06427b2009ceb2cecf39d783fd1c3477cd5e66f9..1a2cd7a0e52e6345472f29283dfe94be506a338a 100644
|
2020-01-13 14:04:38 +00:00
|
|
|
--- a/ui/views/cocoa/native_widget_mac_ns_window_host.h
|
|
|
|
+++ b/ui/views/cocoa/native_widget_mac_ns_window_host.h
|
2020-04-13 23:39:26 +00:00
|
|
|
@@ -29,7 +29,9 @@
|
2020-01-13 14:04:38 +00:00
|
|
|
#include "ui/views/window/dialog_observer.h"
|
|
|
|
|
|
|
|
@class NativeWidgetMacNSWindow;
|
|
|
|
+#ifndef MAS_BUILD
|
|
|
|
@class NSAccessibilityRemoteUIElement;
|
|
|
|
+#endif
|
|
|
|
@class NSView;
|
|
|
|
|
|
|
|
namespace remote_cocoa {
|
2020-04-13 23:39:26 +00:00
|
|
|
@@ -408,11 +410,13 @@ class VIEWS_EXPORT NativeWidgetMacNSWindowHost
|
2020-01-13 14:04:38 +00:00
|
|
|
mojo::AssociatedRemote<remote_cocoa::mojom::NativeWidgetNSWindow>
|
|
|
|
remote_ns_window_remote_;
|
|
|
|
|
|
|
|
+#ifndef MAS_BUILD
|
|
|
|
// Remote accessibility objects corresponding to the NSWindow and its root
|
|
|
|
// NSView.
|
|
|
|
base::scoped_nsobject<NSAccessibilityRemoteUIElement>
|
|
|
|
remote_window_accessible_;
|
|
|
|
base::scoped_nsobject<NSAccessibilityRemoteUIElement> remote_view_accessible_;
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
// Used to force the NSApplication's focused accessibility element to be the
|
|
|
|
// views::Views accessibility tree when the NSView for this is focused.
|
|
|
|
diff --git a/ui/views/cocoa/native_widget_mac_ns_window_host.mm b/ui/views/cocoa/native_widget_mac_ns_window_host.mm
|
2020-03-03 21:35:05 +00:00
|
|
|
index 2256c365af5b1af79458fdcb0cb9d44c9ff641fd..f4949b071a177452b0074a2436669e9846558d1a 100644
|
2020-01-13 14:04:38 +00:00
|
|
|
--- a/ui/views/cocoa/native_widget_mac_ns_window_host.mm
|
|
|
|
+++ b/ui/views/cocoa/native_widget_mac_ns_window_host.mm
|
2020-04-08 15:59:14 +00:00
|
|
|
@@ -282,14 +282,22 @@ gfx::NativeViewAccessible
|
2020-01-13 14:04:38 +00:00
|
|
|
NativeWidgetMacNSWindowHost::GetNativeViewAccessibleForNSView() const {
|
|
|
|
if (in_process_ns_window_bridge_)
|
|
|
|
return in_process_ns_window_bridge_->ns_view();
|
|
|
|
+#ifndef MAS_BUILD
|
|
|
|
return remote_view_accessible_.get();
|
|
|
|
+#else
|
|
|
|
+ return nullptr;
|
|
|
|
+#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
gfx::NativeViewAccessible
|
|
|
|
NativeWidgetMacNSWindowHost::GetNativeViewAccessibleForNSWindow() const {
|
|
|
|
if (in_process_ns_window_bridge_)
|
|
|
|
return in_process_ns_window_bridge_->ns_window();
|
|
|
|
+#ifndef MAS_BUILD
|
|
|
|
return remote_window_accessible_.get();
|
|
|
|
+#else
|
|
|
|
+ return nullptr;
|
|
|
|
+#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
remote_cocoa::mojom::NativeWidgetNSWindow*
|
2020-04-08 15:59:14 +00:00
|
|
|
@@ -1118,6 +1126,7 @@ void NativeWidgetMacNSWindowHost::OnFocusWindowToolbar() {
|
2020-01-13 14:04:38 +00:00
|
|
|
void NativeWidgetMacNSWindowHost::SetRemoteAccessibilityTokens(
|
|
|
|
const std::vector<uint8_t>& window_token,
|
|
|
|
const std::vector<uint8_t>& view_token) {
|
|
|
|
+#ifndef MAS_BUILD
|
|
|
|
remote_window_accessible_ =
|
|
|
|
ui::RemoteAccessibility::GetRemoteElementFromToken(window_token);
|
|
|
|
remote_view_accessible_ =
|
2020-04-08 15:59:14 +00:00
|
|
|
@@ -1125,14 +1134,17 @@ void NativeWidgetMacNSWindowHost::SetRemoteAccessibilityTokens(
|
2020-01-13 14:04:38 +00:00
|
|
|
[remote_view_accessible_ setWindowUIElement:remote_window_accessible_.get()];
|
|
|
|
[remote_view_accessible_
|
|
|
|
setTopLevelUIElement:remote_window_accessible_.get()];
|
|
|
|
+#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
bool NativeWidgetMacNSWindowHost::GetRootViewAccessibilityToken(
|
|
|
|
int64_t* pid,
|
|
|
|
std::vector<uint8_t>* token) {
|
|
|
|
+#ifndef MAS_BUILD
|
|
|
|
*pid = getpid();
|
|
|
|
id element_id = GetNativeViewAccessible();
|
|
|
|
*token = ui::RemoteAccessibility::GetTokenForLocalElement(element_id);
|
|
|
|
+#endif
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|