Commit 18a54a6d authored by Julie Jeongeun Kim's avatar Julie Jeongeun Kim Committed by Commit Bot

Convert mojom::NativeWidgetNSWindowHost to new Mojo types

It converts NativeWidgetNSWindowHost to new Mojo types using
PendingAssociatedReceiver, AssociatedReceiver,
PendingAssociatedRemote, and AssociatedRemote.

Bug: 955171
Change-Id: Iec4a1dceaf904a7b4552216900d43c683d3ece7c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1895095Reviewed-by: default avatarSam McNally <sammc@chromium.org>
Reviewed-by: default avatarOksana Zhuravlova <oksamyt@chromium.org>
Reviewed-by: default avatarccameron <ccameron@chromium.org>
Commit-Queue: Julie Kim <jkim@igalia.com>
Cr-Commit-Position: refs/heads/master@{#712051}
parent 031bfa42
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "components/remote_cocoa/common/native_widget_ns_window_host.mojom.h" #include "components/remote_cocoa/common/native_widget_ns_window_host.mojom.h"
#include "mojo/public/cpp/bindings/associated_binding.h" #include "mojo/public/cpp/bindings/associated_binding.h"
#include "mojo/public/cpp/bindings/pending_associated_receiver.h" #include "mojo/public/cpp/bindings/pending_associated_receiver.h"
#include "mojo/public/cpp/bindings/pending_associated_remote.h"
#include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h" #include "mojo/public/cpp/bindings/pending_remote.h"
...@@ -51,7 +52,7 @@ class REMOTE_COCOA_APP_SHIM_EXPORT ApplicationBridge ...@@ -51,7 +52,7 @@ class REMOTE_COCOA_APP_SHIM_EXPORT ApplicationBridge
uint64_t bridge_id, uint64_t bridge_id,
mojo::PendingAssociatedReceiver<mojom::NativeWidgetNSWindow> mojo::PendingAssociatedReceiver<mojom::NativeWidgetNSWindow>
bridge_receiver, bridge_receiver,
mojom::NativeWidgetNSWindowHostAssociatedPtrInfo host, mojo::PendingAssociatedRemote<mojom::NativeWidgetNSWindowHost> host,
mojom::TextInputHostAssociatedPtrInfo text_input_host) override; mojom::TextInputHostAssociatedPtrInfo text_input_host) override;
void CreateRenderWidgetHostNSView( void CreateRenderWidgetHostNSView(
mojom::StubInterfaceAssociatedPtrInfo host, mojom::StubInterfaceAssociatedPtrInfo host,
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "components/remote_cocoa/app_shim/color_panel_bridge.h" #include "components/remote_cocoa/app_shim/color_panel_bridge.h"
#include "components/remote_cocoa/app_shim/native_widget_ns_window_bridge.h" #include "components/remote_cocoa/app_shim/native_widget_ns_window_bridge.h"
#include "components/remote_cocoa/app_shim/native_widget_ns_window_host_helper.h" #include "components/remote_cocoa/app_shim/native_widget_ns_window_host_helper.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h" #include "mojo/public/cpp/bindings/self_owned_receiver.h"
#include "ui/accelerated_widget_mac/window_resize_helper_mac.h" #include "ui/accelerated_widget_mac/window_resize_helper_mac.h"
#include "ui/base/cocoa/remote_accessibility_api.h" #include "ui/base/cocoa/remote_accessibility_api.h"
...@@ -24,14 +25,15 @@ class NativeWidgetBridgeOwner : public NativeWidgetNSWindowHostHelper { ...@@ -24,14 +25,15 @@ class NativeWidgetBridgeOwner : public NativeWidgetNSWindowHostHelper {
uint64_t bridge_id, uint64_t bridge_id,
mojo::PendingAssociatedReceiver<mojom::NativeWidgetNSWindow> mojo::PendingAssociatedReceiver<mojom::NativeWidgetNSWindow>
bridge_receiver, bridge_receiver,
mojom::NativeWidgetNSWindowHostAssociatedPtrInfo host_ptr, mojo::PendingAssociatedRemote<mojom::NativeWidgetNSWindowHost>
host_remote,
mojom::TextInputHostAssociatedPtrInfo text_input_host_ptr) { mojom::TextInputHostAssociatedPtrInfo text_input_host_ptr) {
host_ptr_.Bind(std::move(host_ptr), host_remote_.Bind(std::move(host_remote),
ui::WindowResizeHelperMac::Get()->task_runner()); ui::WindowResizeHelperMac::Get()->task_runner());
text_input_host_ptr_.Bind(std::move(text_input_host_ptr), text_input_host_ptr_.Bind(std::move(text_input_host_ptr),
ui::WindowResizeHelperMac::Get()->task_runner()); ui::WindowResizeHelperMac::Get()->task_runner());
bridge_ = std::make_unique<NativeWidgetNSWindowBridge>( bridge_ = std::make_unique<NativeWidgetNSWindowBridge>(
bridge_id, host_ptr_.get(), this, text_input_host_ptr_.get()); bridge_id, host_remote_.get(), this, text_input_host_ptr_.get());
bridge_->BindReceiver( bridge_->BindReceiver(
std::move(bridge_receiver), std::move(bridge_receiver),
base::BindOnce(&NativeWidgetBridgeOwner::OnMojoDisconnect, base::BindOnce(&NativeWidgetBridgeOwner::OnMojoDisconnect,
...@@ -48,7 +50,7 @@ class NativeWidgetBridgeOwner : public NativeWidgetNSWindowHostHelper { ...@@ -48,7 +50,7 @@ class NativeWidgetBridgeOwner : public NativeWidgetNSWindowHostHelper {
if (!remote_accessibility_element_) { if (!remote_accessibility_element_) {
int64_t browser_pid = 0; int64_t browser_pid = 0;
std::vector<uint8_t> element_token; std::vector<uint8_t> element_token;
host_ptr_->GetRootViewAccessibilityToken(&browser_pid, &element_token); host_remote_->GetRootViewAccessibilityToken(&browser_pid, &element_token);
[NSAccessibilityRemoteUIElement [NSAccessibilityRemoteUIElement
registerRemoteUIProcessIdentifier:browser_pid]; registerRemoteUIProcessIdentifier:browser_pid];
remote_accessibility_element_ = remote_accessibility_element_ =
...@@ -58,15 +60,15 @@ class NativeWidgetBridgeOwner : public NativeWidgetNSWindowHostHelper { ...@@ -58,15 +60,15 @@ class NativeWidgetBridgeOwner : public NativeWidgetNSWindowHostHelper {
} }
void DispatchKeyEvent(ui::KeyEvent* event) override { void DispatchKeyEvent(ui::KeyEvent* event) override {
bool event_handled = false; bool event_handled = false;
host_ptr_->DispatchKeyEventRemote(std::make_unique<ui::KeyEvent>(*event), host_remote_->DispatchKeyEventRemote(std::make_unique<ui::KeyEvent>(*event),
&event_handled); &event_handled);
if (event_handled) if (event_handled)
event->SetHandled(); event->SetHandled();
} }
bool DispatchKeyEventToMenuController(ui::KeyEvent* event) override { bool DispatchKeyEventToMenuController(ui::KeyEvent* event) override {
bool event_swallowed = false; bool event_swallowed = false;
bool event_handled = false; bool event_handled = false;
host_ptr_->DispatchKeyEventToMenuControllerRemote( host_remote_->DispatchKeyEventToMenuControllerRemote(
std::make_unique<ui::KeyEvent>(*event), &event_swallowed, std::make_unique<ui::KeyEvent>(*event), &event_swallowed,
&event_handled); &event_handled);
if (event_handled) if (event_handled)
...@@ -88,7 +90,7 @@ class NativeWidgetBridgeOwner : public NativeWidgetNSWindowHostHelper { ...@@ -88,7 +90,7 @@ class NativeWidgetBridgeOwner : public NativeWidgetNSWindowHostHelper {
return nullptr; return nullptr;
} }
mojom::NativeWidgetNSWindowHostAssociatedPtr host_ptr_; mojo::AssociatedRemote<mojom::NativeWidgetNSWindowHost> host_remote_;
mojom::TextInputHostAssociatedPtr text_input_host_ptr_; mojom::TextInputHostAssociatedPtr text_input_host_ptr_;
std::unique_ptr<NativeWidgetNSWindowBridge> bridge_; std::unique_ptr<NativeWidgetNSWindowBridge> bridge_;
...@@ -134,7 +136,7 @@ void ApplicationBridge::CreateNativeWidgetNSWindow( ...@@ -134,7 +136,7 @@ void ApplicationBridge::CreateNativeWidgetNSWindow(
uint64_t bridge_id, uint64_t bridge_id,
mojo::PendingAssociatedReceiver<mojom::NativeWidgetNSWindow> mojo::PendingAssociatedReceiver<mojom::NativeWidgetNSWindow>
bridge_receiver, bridge_receiver,
mojom::NativeWidgetNSWindowHostAssociatedPtrInfo host, mojo::PendingAssociatedRemote<mojom::NativeWidgetNSWindowHost> host,
mojom::TextInputHostAssociatedPtrInfo text_input_host) { mojom::TextInputHostAssociatedPtrInfo text_input_host) {
// The resulting object will be destroyed when its message pipe is closed. // The resulting object will be destroyed when its message pipe is closed.
ignore_result( ignore_result(
......
...@@ -38,7 +38,7 @@ interface Application { ...@@ -38,7 +38,7 @@ interface Application {
CreateNativeWidgetNSWindow( CreateNativeWidgetNSWindow(
uint64 bridge_id, uint64 bridge_id,
pending_associated_receiver<NativeWidgetNSWindow> window_receiver, pending_associated_receiver<NativeWidgetNSWindow> window_receiver,
associated NativeWidgetNSWindowHost host, pending_associated_remote<NativeWidgetNSWindowHost> host,
associated TextInputHost text_input_host); associated TextInputHost text_input_host);
// Create and take ownership of the NSView for a RenderWidgetHostView. The // Create and take ownership of the NSView for a RenderWidgetHostView. The
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include "components/remote_cocoa/browser/application_host.h" #include "components/remote_cocoa/browser/application_host.h"
#include "components/remote_cocoa/common/native_widget_ns_window.mojom.h" #include "components/remote_cocoa/common/native_widget_ns_window.mojom.h"
#include "components/remote_cocoa/common/native_widget_ns_window_host.mojom.h" #include "components/remote_cocoa/common/native_widget_ns_window_host.mojom.h"
#include "mojo/public/cpp/bindings/associated_binding.h" #include "mojo/public/cpp/bindings/associated_receiver.h"
#include "mojo/public/cpp/bindings/associated_remote.h" #include "mojo/public/cpp/bindings/associated_remote.h"
#include "ui/accelerated_widget_mac/accelerated_widget_mac.h" #include "ui/accelerated_widget_mac/accelerated_widget_mac.h"
#include "ui/base/cocoa/accessibility_focus_overrider.h" #include "ui/base/cocoa/accessibility_focus_overrider.h"
...@@ -483,8 +483,8 @@ class VIEWS_EXPORT NativeWidgetMacNSWindowHost ...@@ -483,8 +483,8 @@ class VIEWS_EXPORT NativeWidgetMacNSWindowHost
// attached to |this|. // attached to |this|.
std::map<const views::View*, NSView*> attached_native_view_host_views_; std::map<const views::View*, NSView*> attached_native_view_host_views_;
mojo::AssociatedBinding<remote_cocoa::mojom::NativeWidgetNSWindowHost> mojo::AssociatedReceiver<remote_cocoa::mojom::NativeWidgetNSWindowHost>
remote_ns_window_host_binding_; remote_ns_window_host_receiver_{this};
DISALLOW_COPY_AND_ASSIGN(NativeWidgetMacNSWindowHost); DISALLOW_COPY_AND_ASSIGN(NativeWidgetMacNSWindowHost);
}; };
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include "components/remote_cocoa/app_shim/native_widget_ns_window_bridge.h" #include "components/remote_cocoa/app_shim/native_widget_ns_window_bridge.h"
#include "components/remote_cocoa/browser/ns_view_ids.h" #include "components/remote_cocoa/browser/ns_view_ids.h"
#include "components/remote_cocoa/browser/window.h" #include "components/remote_cocoa/browser/window.h"
#include "mojo/public/cpp/bindings/strong_associated_binding.h" #include "mojo/public/cpp/bindings/self_owned_associated_receiver.h"
#include "ui/accelerated_widget_mac/window_resize_helper_mac.h" #include "ui/accelerated_widget_mac/window_resize_helper_mac.h"
#include "ui/base/cocoa/animation_utils.h" #include "ui/base/cocoa/animation_utils.h"
#include "ui/base/cocoa/remote_accessibility_api.h" #include "ui/base/cocoa/remote_accessibility_api.h"
...@@ -247,8 +247,7 @@ NativeWidgetMacNSWindowHost::NativeWidgetMacNSWindowHost(NativeWidgetMac* owner) ...@@ -247,8 +247,7 @@ NativeWidgetMacNSWindowHost::NativeWidgetMacNSWindowHost(NativeWidgetMac* owner)
native_widget_mac_(owner), native_widget_mac_(owner),
root_view_id_(remote_cocoa::GetNewNSViewId()), root_view_id_(remote_cocoa::GetNewNSViewId()),
accessibility_focus_overrider_(this), accessibility_focus_overrider_(this),
text_input_host_(new TextInputHost(this)), text_input_host_(new TextInputHost(this)) {
remote_ns_window_host_binding_(this) {
DCHECK(GetIdToWidgetHostImplMap().find(widget_id_) == DCHECK(GetIdToWidgetHostImplMap().find(widget_id_) ==
GetIdToWidgetHostImplMap().end()); GetIdToWidgetHostImplMap().end());
GetIdToWidgetHostImplMap().emplace(widget_id_, this); GetIdToWidgetHostImplMap().emplace(widget_id_, this);
...@@ -265,11 +264,12 @@ NativeWidgetMacNSWindowHost::~NativeWidgetMacNSWindowHost() { ...@@ -265,11 +264,12 @@ NativeWidgetMacNSWindowHost::~NativeWidgetMacNSWindowHost() {
} }
// Workaround for https://crbug.com/915572 // Workaround for https://crbug.com/915572
if (remote_ns_window_host_binding_.is_bound()) { if (remote_ns_window_host_receiver_.is_bound()) {
auto request = remote_ns_window_host_binding_.Unbind(); auto receiver = remote_ns_window_host_receiver_.Unbind();
if (request.is_pending()) { if (receiver.is_valid()) {
mojo::MakeStrongAssociatedBinding( mojo::MakeSelfOwnedAssociatedReceiver(
std::make_unique<BridgedNativeWidgetHostDummy>(), std::move(request)); std::make_unique<BridgedNativeWidgetHostDummy>(),
std::move(receiver));
} }
} }
...@@ -350,15 +350,13 @@ void NativeWidgetMacNSWindowHost::CreateRemoteNSWindow( ...@@ -350,15 +350,13 @@ void NativeWidgetMacNSWindowHost::CreateRemoteNSWindow(
// Initialize |remote_ns_window_remote_| to point to a bridge created by // Initialize |remote_ns_window_remote_| to point to a bridge created by
// |factory|. // |factory|.
remote_cocoa::mojom::NativeWidgetNSWindowHostAssociatedPtr host_ptr;
remote_ns_window_host_binding_.Bind(
mojo::MakeRequest(&host_ptr),
ui::WindowResizeHelperMac::Get()->task_runner());
remote_cocoa::mojom::TextInputHostAssociatedPtr text_input_host_ptr; remote_cocoa::mojom::TextInputHostAssociatedPtr text_input_host_ptr;
text_input_host_->BindRequest(mojo::MakeRequest(&text_input_host_ptr)); text_input_host_->BindRequest(mojo::MakeRequest(&text_input_host_ptr));
application_host_->GetApplication()->CreateNativeWidgetNSWindow( application_host_->GetApplication()->CreateNativeWidgetNSWindow(
widget_id_, remote_ns_window_remote_.BindNewEndpointAndPassReceiver(), widget_id_, remote_ns_window_remote_.BindNewEndpointAndPassReceiver(),
host_ptr.PassInterface(), text_input_host_ptr.PassInterface()); remote_ns_window_host_receiver_.BindNewEndpointAndPassRemote(
ui::WindowResizeHelperMac::Get()->task_runner()),
text_input_host_ptr.PassInterface());
// Create the window in its process, and attach it to its parent window. // Create the window in its process, and attach it to its parent window.
GetNSWindowMojo()->CreateWindow(std::move(window_create_params)); GetNSWindowMojo()->CreateWindow(std::move(window_create_params));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment