Commit 4938fc0d authored by Julie Jeongeun Kim's avatar Julie Jeongeun Kim Committed by Commit Bot

Convert mojom::TextInputHost to new Mojo types

It converts TextInputHost from text_input_host.mojom to new
Mojo types using PendingAssociatedReceiver, AssociatedReceiver,
PendingAssociatedRemote, and AssociatedRemote.

Bug: 955171
Change-Id: I39b94453e0bbfe6bf713cdad8cc288347d49a736
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1893607
Commit-Queue: Julie Kim <jkim@igalia.com>
Reviewed-by: default avatarOksana Zhuravlova <oksamyt@chromium.org>
Reviewed-by: default avatarccameron <ccameron@chromium.org>
Reviewed-by: default avatarSam McNally <sammc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#712054}
parent 6532435a
......@@ -53,7 +53,8 @@ class REMOTE_COCOA_APP_SHIM_EXPORT ApplicationBridge
mojo::PendingAssociatedReceiver<mojom::NativeWidgetNSWindow>
bridge_receiver,
mojo::PendingAssociatedRemote<mojom::NativeWidgetNSWindowHost> host,
mojom::TextInputHostAssociatedPtrInfo text_input_host) override;
mojo::PendingAssociatedRemote<mojom::TextInputHost> text_input_host)
override;
void CreateRenderWidgetHostNSView(
mojom::StubInterfaceAssociatedPtrInfo host,
mojom::StubInterfaceAssociatedRequest view_request) override;
......
......@@ -27,13 +27,15 @@ class NativeWidgetBridgeOwner : public NativeWidgetNSWindowHostHelper {
bridge_receiver,
mojo::PendingAssociatedRemote<mojom::NativeWidgetNSWindowHost>
host_remote,
mojom::TextInputHostAssociatedPtrInfo text_input_host_ptr) {
mojo::PendingAssociatedRemote<mojom::TextInputHost>
text_input_host_remote) {
host_remote_.Bind(std::move(host_remote),
ui::WindowResizeHelperMac::Get()->task_runner());
text_input_host_ptr_.Bind(std::move(text_input_host_ptr),
ui::WindowResizeHelperMac::Get()->task_runner());
text_input_host_remote_.Bind(
std::move(text_input_host_remote),
ui::WindowResizeHelperMac::Get()->task_runner());
bridge_ = std::make_unique<NativeWidgetNSWindowBridge>(
bridge_id, host_remote_.get(), this, text_input_host_ptr_.get());
bridge_id, host_remote_.get(), this, text_input_host_remote_.get());
bridge_->BindReceiver(
std::move(bridge_receiver),
base::BindOnce(&NativeWidgetBridgeOwner::OnMojoDisconnect,
......@@ -91,7 +93,7 @@ class NativeWidgetBridgeOwner : public NativeWidgetNSWindowHostHelper {
}
mojo::AssociatedRemote<mojom::NativeWidgetNSWindowHost> host_remote_;
mojom::TextInputHostAssociatedPtr text_input_host_ptr_;
mojo::AssociatedRemote<mojom::TextInputHost> text_input_host_remote_;
std::unique_ptr<NativeWidgetNSWindowBridge> bridge_;
base::scoped_nsobject<NSAccessibilityRemoteUIElement>
......@@ -137,7 +139,7 @@ void ApplicationBridge::CreateNativeWidgetNSWindow(
mojo::PendingAssociatedReceiver<mojom::NativeWidgetNSWindow>
bridge_receiver,
mojo::PendingAssociatedRemote<mojom::NativeWidgetNSWindowHost> host,
mojom::TextInputHostAssociatedPtrInfo text_input_host) {
mojo::PendingAssociatedRemote<mojom::TextInputHost> text_input_host) {
// The resulting object will be destroyed when its message pipe is closed.
ignore_result(
new NativeWidgetBridgeOwner(bridge_id, std::move(bridge_receiver),
......
......@@ -39,7 +39,7 @@ interface Application {
uint64 bridge_id,
pending_associated_receiver<NativeWidgetNSWindow> window_receiver,
pending_associated_remote<NativeWidgetNSWindowHost> host,
associated TextInputHost text_input_host);
pending_associated_remote<TextInputHost> text_input_host);
// Create and take ownership of the NSView for a RenderWidgetHostView. The
// resulting object will be destroyed when the connection is closed.
......
......@@ -350,13 +350,15 @@ void NativeWidgetMacNSWindowHost::CreateRemoteNSWindow(
// Initialize |remote_ns_window_remote_| to point to a bridge created by
// |factory|.
remote_cocoa::mojom::TextInputHostAssociatedPtr text_input_host_ptr;
text_input_host_->BindRequest(mojo::MakeRequest(&text_input_host_ptr));
mojo::PendingAssociatedRemote<remote_cocoa::mojom::TextInputHost>
text_input_host_remote;
text_input_host_->BindReceiver(
text_input_host_remote.InitWithNewEndpointAndPassReceiver());
application_host_->GetApplication()->CreateNativeWidgetNSWindow(
widget_id_, remote_ns_window_remote_.BindNewEndpointAndPassReceiver(),
remote_ns_window_host_receiver_.BindNewEndpointAndPassRemote(
ui::WindowResizeHelperMac::Get()->task_runner()),
text_input_host_ptr.PassInterface());
std::move(text_input_host_remote));
// Create the window in its process, and attach it to its parent window.
GetNSWindowMojo()->CreateWindow(std::move(window_create_params));
......
......@@ -7,7 +7,8 @@
#include "base/macros.h"
#include "components/remote_cocoa/common/text_input_host.mojom.h"
#include "mojo/public/cpp/bindings/associated_binding.h"
#include "mojo/public/cpp/bindings/associated_receiver.h"
#include "mojo/public/cpp/bindings/pending_associated_receiver.h"
#include "ui/views/views_export.h"
namespace ui {
......@@ -22,7 +23,9 @@ class VIEWS_EXPORT TextInputHost : public remote_cocoa::mojom::TextInputHost {
public:
explicit TextInputHost(NativeWidgetMacNSWindowHost* host_impl);
~TextInputHost() override;
void BindRequest(remote_cocoa::mojom::TextInputHostAssociatedRequest request);
void BindReceiver(
mojo::PendingAssociatedReceiver<remote_cocoa::mojom::TextInputHost>
receiver);
// Set the current TextInputClient.
void SetTextInputClient(ui::TextInputClient* new_text_input_client);
......@@ -80,7 +83,8 @@ class VIEWS_EXPORT TextInputHost : public remote_cocoa::mojom::TextInputHost {
NativeWidgetMacNSWindowHost* const host_impl_;
mojo::AssociatedBinding<remote_cocoa::mojom::TextInputHost> mojo_binding_;
mojo::AssociatedReceiver<remote_cocoa::mojom::TextInputHost> mojo_receiver_{
this};
DISALLOW_COPY_AND_ASSIGN(TextInputHost);
};
......
......@@ -132,14 +132,15 @@ namespace views {
// TextInputHost, public:
TextInputHost::TextInputHost(NativeWidgetMacNSWindowHost* host_impl)
: host_impl_(host_impl), mojo_binding_(this) {}
: host_impl_(host_impl) {}
TextInputHost::~TextInputHost() = default;
void TextInputHost::BindRequest(
remote_cocoa::mojom::TextInputHostAssociatedRequest request) {
mojo_binding_.Bind(std::move(request),
ui::WindowResizeHelperMac::Get()->task_runner());
void TextInputHost::BindReceiver(
mojo::PendingAssociatedReceiver<remote_cocoa::mojom::TextInputHost>
receiver) {
mojo_receiver_.Bind(std::move(receiver),
ui::WindowResizeHelperMac::Get()->task_runner());
}
ui::TextInputClient* TextInputHost::GetTextInputClient() const {
......
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