Commit 95fdfd8d authored by Julie Jeongeun Kim's avatar Julie Jeongeun Kim Committed by Commit Bot

Convert remote_cocoa::mojom::Application to new Mojo types

It converts remote_cocoa::mojom::Application from
application.mojom to new Mojo types using
PendingAssociatedReceiver, AssociatedReceiver,
PendingAssociatedRemote, and AssociatedRemote.

Bug: 955171
Change-Id: I5c8979e8509cb064878f133457c20d95c6a38b25
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1895022
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@{#712055}
parent 4938fc0d
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "base/mac/scoped_nsobject.h" #include "base/mac/scoped_nsobject.h"
#include "chrome/common/mac/app_shim.mojom.h" #include "chrome/common/mac/app_shim.mojom.h"
#include "chrome/common/mac/app_shim_param_traits.h" #include "chrome/common/mac/app_shim_param_traits.h"
#include "mojo/public/cpp/bindings/pending_associated_receiver.h"
#include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/receiver.h" #include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h" #include "mojo/public/cpp/bindings/remote.h"
...@@ -77,7 +78,8 @@ class AppShimController : public chrome::mojom::AppShim { ...@@ -77,7 +78,8 @@ class AppShimController : public chrome::mojom::AppShim {
// chrome::mojom::AppShim implementation. // chrome::mojom::AppShim implementation.
void CreateRemoteCocoaApplication( void CreateRemoteCocoaApplication(
remote_cocoa::mojom::ApplicationAssociatedRequest request) override; mojo::PendingAssociatedReceiver<remote_cocoa::mojom::Application>
receiver) override;
void CreateCommandDispatcherForWidget(uint64_t widget_id) override; void CreateCommandDispatcherForWidget(uint64_t widget_id) override;
void SetBadgeLabel(const std::string& badge_label) override; void SetBadgeLabel(const std::string& badge_label) override;
void SetUserAttention(apps::AppShimAttentionType attention_type) override; void SetUserAttention(apps::AppShimAttentionType attention_type) override;
......
...@@ -373,8 +373,9 @@ void AppShimController::OnShimConnectedResponse( ...@@ -373,8 +373,9 @@ void AppShimController::OnShimConnectedResponse(
} }
void AppShimController::CreateRemoteCocoaApplication( void AppShimController::CreateRemoteCocoaApplication(
remote_cocoa::mojom::ApplicationAssociatedRequest request) { mojo::PendingAssociatedReceiver<remote_cocoa::mojom::Application>
remote_cocoa::ApplicationBridge::Get()->BindRequest(std::move(request)); receiver) {
remote_cocoa::ApplicationBridge::Get()->BindReceiver(std::move(receiver));
remote_cocoa::ApplicationBridge::Get()->SetContentNSViewCreateCallbacks( remote_cocoa::ApplicationBridge::Get()->SetContentNSViewCreateCallbacks(
base::BindRepeating(remote_cocoa::CreateRenderWidgetHostNSView), base::BindRepeating(remote_cocoa::CreateRenderWidgetHostNSView),
base::BindRepeating(remote_cocoa::CreateWebContentsNSView)); base::BindRepeating(remote_cocoa::CreateWebContentsNSView));
......
...@@ -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/application.mojom.h" #include "components/remote_cocoa/common/application.mojom.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "mojo/public/cpp/bindings/interface_request.h" #include "mojo/public/cpp/bindings/pending_associated_receiver.h"
AppShimHost::AppShimHost(AppShimHost::Client* client, AppShimHost::AppShimHost(AppShimHost::Client* client,
const std::string& app_id, const std::string& app_id,
...@@ -34,12 +34,13 @@ AppShimHost::AppShimHost(AppShimHost::Client* client, ...@@ -34,12 +34,13 @@ AppShimHost::AppShimHost(AppShimHost::Client* client,
base::FeatureList::IsEnabled(features::kAppShimRemoteCocoa)) { base::FeatureList::IsEnabled(features::kAppShimRemoteCocoa)) {
// Create the interface that will be used by views::NativeWidgetMac to // Create the interface that will be used by views::NativeWidgetMac to
// create NSWindows hosted in the app shim process. // create NSWindows hosted in the app shim process.
remote_cocoa::mojom::ApplicationAssociatedRequest views_application_request; mojo::PendingAssociatedReceiver<remote_cocoa::mojom::Application>
views_application_receiver;
remote_cocoa_application_host_ = remote_cocoa_application_host_ =
std::make_unique<remote_cocoa::ApplicationHost>( std::make_unique<remote_cocoa::ApplicationHost>(
&views_application_request); &views_application_receiver);
app_shim_->CreateRemoteCocoaApplication( app_shim_->CreateRemoteCocoaApplication(
std::move(views_application_request)); std::move(views_application_receiver));
} }
} }
......
...@@ -22,8 +22,7 @@ ...@@ -22,8 +22,7 @@
#include "chrome/common/mac/app_shim.mojom.h" #include "chrome/common/mac/app_shim.mojom.h"
#include "chrome/common/mac/app_shim_param_traits.h" #include "chrome/common/mac/app_shim_param_traits.h"
#include "ipc/ipc_message.h" #include "ipc/ipc_message.h"
#include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/pending_associated_receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
namespace { namespace {
...@@ -57,7 +56,8 @@ class TestingAppShim : public chrome::mojom::AppShim { ...@@ -57,7 +56,8 @@ class TestingAppShim : public chrome::mojom::AppShim {
// chrome::mojom::AppShim implementation. // chrome::mojom::AppShim implementation.
void CreateRemoteCocoaApplication( void CreateRemoteCocoaApplication(
remote_cocoa::mojom::ApplicationAssociatedRequest request) override {} mojo::PendingAssociatedReceiver<remote_cocoa::mojom::Application>
receiver) override {}
void CreateCommandDispatcherForWidget(uint64_t widget_id) override {} void CreateCommandDispatcherForWidget(uint64_t widget_id) override {}
void SetUserAttention(apps::AppShimAttentionType attention_type) override {} void SetUserAttention(apps::AppShimAttentionType attention_type) override {}
void SetBadgeLabel(const std::string& badge_label) override {} void SetBadgeLabel(const std::string& badge_label) override {}
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/in_process_browser_test.h"
#include "components/version_info/version_info.h" #include "components/version_info/version_info.h"
#include "content/public/test/test_utils.h" #include "content/public/test/test_utils.h"
#include "mojo/public/cpp/bindings/pending_associated_receiver.h"
#include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/receiver.h" #include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h" #include "mojo/public/cpp/bindings/remote.h"
...@@ -66,7 +67,8 @@ class TestShimClient : public chrome::mojom::AppShim { ...@@ -66,7 +67,8 @@ class TestShimClient : public chrome::mojom::AppShim {
// chrome::mojom::AppShim implementation (not used in testing, but can be). // chrome::mojom::AppShim implementation (not used in testing, but can be).
void CreateRemoteCocoaApplication( void CreateRemoteCocoaApplication(
remote_cocoa::mojom::ApplicationAssociatedRequest request) override {} mojo::PendingAssociatedReceiver<remote_cocoa::mojom::Application>
receiver) override {}
void CreateCommandDispatcherForWidget(uint64_t widget_id) override {} void CreateCommandDispatcherForWidget(uint64_t widget_id) override {}
void SetUserAttention(apps::AppShimAttentionType attention_type) override {} void SetUserAttention(apps::AppShimAttentionType attention_type) override {}
void SetBadgeLabel(const std::string& badge_label) override {} void SetBadgeLabel(const std::string& badge_label) override {}
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "content/public/test/browser_task_environment.h" #include "content/public/test/browser_task_environment.h"
#include "extensions/common/extension.h" #include "extensions/common/extension.h"
#include "extensions/common/extension_builder.h" #include "extensions/common/extension_builder.h"
#include "mojo/public/cpp/bindings/pending_associated_receiver.h"
#include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/remote.h" #include "mojo/public/cpp/bindings/remote.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
...@@ -258,7 +259,8 @@ class TestAppShim : public chrome::mojom::AppShim { ...@@ -258,7 +259,8 @@ class TestAppShim : public chrome::mojom::AppShim {
public: public:
// chrome::mojom::AppShim: // chrome::mojom::AppShim:
void CreateRemoteCocoaApplication( void CreateRemoteCocoaApplication(
remote_cocoa::mojom::ApplicationAssociatedRequest request) override {} mojo::PendingAssociatedReceiver<remote_cocoa::mojom::Application>
receiver) override {}
void CreateCommandDispatcherForWidget(uint64_t widget_id) override {} void CreateCommandDispatcherForWidget(uint64_t widget_id) override {}
void SetBadgeLabel(const std::string& badge_label) override {} void SetBadgeLabel(const std::string& badge_label) override {}
void SetUserAttention(apps::AppShimAttentionType attention_type) override {} void SetUserAttention(apps::AppShimAttentionType attention_type) override {}
......
...@@ -45,7 +45,7 @@ interface AppShim { ...@@ -45,7 +45,7 @@ interface AppShim {
// Create the interface to the NSApplication (through which NSViews and // Create the interface to the NSApplication (through which NSViews and
// NSWindows may be created). // NSWindows may be created).
CreateRemoteCocoaApplication( CreateRemoteCocoaApplication(
associated remote_cocoa.mojom.Application& application); pending_associated_receiver<remote_cocoa.mojom.Application> application);
// Initialize the command handler for the specified BridgedNativeWidget. This // Initialize the command handler for the specified BridgedNativeWidget. This
// method exists at this scope (as opposed to in remote_cocoa) because it // method exists at this scope (as opposed to in remote_cocoa) because it
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include "components/remote_cocoa/common/application.mojom.h" #include "components/remote_cocoa/common/application.mojom.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/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_associated_remote.h"
#include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/pending_receiver.h"
...@@ -26,7 +26,8 @@ class REMOTE_COCOA_APP_SHIM_EXPORT ApplicationBridge ...@@ -26,7 +26,8 @@ class REMOTE_COCOA_APP_SHIM_EXPORT ApplicationBridge
: public mojom::Application { : public mojom::Application {
public: public:
static ApplicationBridge* Get(); static ApplicationBridge* Get();
void BindRequest(mojom::ApplicationAssociatedRequest request); void BindReceiver(
mojo::PendingAssociatedReceiver<mojom::Application> receiver);
// Set callbacks to create content types (content types cannot be created // Set callbacks to create content types (content types cannot be created
// in remote_cocoa). // in remote_cocoa).
...@@ -71,7 +72,7 @@ class REMOTE_COCOA_APP_SHIM_EXPORT ApplicationBridge ...@@ -71,7 +72,7 @@ class REMOTE_COCOA_APP_SHIM_EXPORT ApplicationBridge
RenderWidgetHostNSViewCreateCallback render_widget_host_create_callback_; RenderWidgetHostNSViewCreateCallback render_widget_host_create_callback_;
WebContentsNSViewCreateCallback web_conents_create_callback_; WebContentsNSViewCreateCallback web_conents_create_callback_;
mojo::AssociatedBinding<mojom::Application> binding_; mojo::AssociatedReceiver<mojom::Application> receiver_{this};
}; };
} // namespace remote_cocoa } // namespace remote_cocoa
......
...@@ -108,10 +108,10 @@ ApplicationBridge* ApplicationBridge::Get() { ...@@ -108,10 +108,10 @@ ApplicationBridge* ApplicationBridge::Get() {
return application_bridge.get(); return application_bridge.get();
} }
void ApplicationBridge::BindRequest( void ApplicationBridge::BindReceiver(
mojom::ApplicationAssociatedRequest request) { mojo::PendingAssociatedReceiver<mojom::Application> receiver) {
binding_.Bind(std::move(request), receiver_.Bind(std::move(receiver),
ui::WindowResizeHelperMac::Get()->task_runner()); ui::WindowResizeHelperMac::Get()->task_runner());
} }
void ApplicationBridge::SetContentNSViewCreateCallbacks( void ApplicationBridge::SetContentNSViewCreateCallbacks(
...@@ -165,8 +165,8 @@ void ApplicationBridge::CreateWebContentsNSView( ...@@ -165,8 +165,8 @@ void ApplicationBridge::CreateWebContentsNSView(
view_request.PassHandle()); view_request.PassHandle());
} }
ApplicationBridge::ApplicationBridge() : binding_(this) {} ApplicationBridge::ApplicationBridge() = default;
ApplicationBridge::~ApplicationBridge() {} ApplicationBridge::~ApplicationBridge() = default;
} // namespace remote_cocoa } // namespace remote_cocoa
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
#include "base/observer_list_types.h" #include "base/observer_list_types.h"
#include "components/remote_cocoa/browser/remote_cocoa_browser_export.h" #include "components/remote_cocoa/browser/remote_cocoa_browser_export.h"
#include "components/remote_cocoa/common/application.mojom.h" #include "components/remote_cocoa/common/application.mojom.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "mojo/public/cpp/bindings/pending_associated_receiver.h"
#include "ui/gfx/native_widget_types.h" #include "ui/gfx/native_widget_types.h"
namespace remote_cocoa { namespace remote_cocoa {
...@@ -26,7 +28,8 @@ class REMOTE_COCOA_BROWSER_EXPORT ApplicationHost { ...@@ -26,7 +28,8 @@ class REMOTE_COCOA_BROWSER_EXPORT ApplicationHost {
~Observer() override {} ~Observer() override {}
}; };
ApplicationHost(mojom::ApplicationAssociatedRequest* request); ApplicationHost(
mojo::PendingAssociatedReceiver<mojom::Application>* receiver);
~ApplicationHost(); ~ApplicationHost();
mojom::Application* GetApplication(); mojom::Application* GetApplication();
...@@ -37,7 +40,7 @@ class REMOTE_COCOA_BROWSER_EXPORT ApplicationHost { ...@@ -37,7 +40,7 @@ class REMOTE_COCOA_BROWSER_EXPORT ApplicationHost {
static ApplicationHost* GetForNativeView(gfx::NativeView view); static ApplicationHost* GetForNativeView(gfx::NativeView view);
private: private:
mojom::ApplicationAssociatedPtr application_ptr_; mojo::AssociatedRemote<mojom::Application> application_remote_;
base::ObserverList<Observer> observers_; base::ObserverList<Observer> observers_;
}; };
......
...@@ -7,12 +7,12 @@ ...@@ -7,12 +7,12 @@
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#include "components/remote_cocoa/browser/window.h" #include "components/remote_cocoa/browser/window.h"
#include "mojo/public/cpp/bindings/interface_request.h"
namespace remote_cocoa { namespace remote_cocoa {
ApplicationHost::ApplicationHost(mojom::ApplicationAssociatedRequest* request) { ApplicationHost::ApplicationHost(
*request = mojo::MakeRequest(&application_ptr_); mojo::PendingAssociatedReceiver<mojom::Application>* receiver) {
*receiver = application_remote_.BindNewEndpointAndPassReceiver();
} }
ApplicationHost::~ApplicationHost() { ApplicationHost::~ApplicationHost() {
...@@ -21,7 +21,7 @@ ApplicationHost::~ApplicationHost() { ...@@ -21,7 +21,7 @@ ApplicationHost::~ApplicationHost() {
} }
mojom::Application* ApplicationHost::GetApplication() { mojom::Application* ApplicationHost::GetApplication() {
return application_ptr_.get(); return application_remote_.get();
} }
void ApplicationHost::AddObserver(Observer* observer) { void ApplicationHost::AddObserver(Observer* observer) {
......
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