Commit c11398ab authored by Miyoung Shin's avatar Miyoung Shin Committed by Commit Bot

Migrate chromeos::multidevice_setup::mojom::MultiDeviceSetup to BrowserInterfaceBroker

This CL migrates code to the new BrowserInterfaceBroker class. This
allows retrieving the remote implementation in the browser process
without relying on the InterfaceProvider API.

Bug: 936482, 1002647
Change-Id: I9be9e414f9574a556757ec4c11a5f73690e2906d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1969129
Commit-Queue: Miyoung Shin <myid.shin@igalia.com>
Reviewed-by: default avatarSam McNally <sammc@chromium.org>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Reviewed-by: default avatarOksana Zhuravlova <oksamyt@chromium.org>
Reviewed-by: default avatarcalamity <calamity@chromium.org>
Cr-Commit-Position: refs/heads/master@{#726732}
parent 7ad5ab37
......@@ -87,7 +87,6 @@ const service_manager::Manifest& GetChromeContentBrowserOverlayManifest() {
"navigation:frame", "renderer",
service_manager::Manifest::InterfaceList<
#if defined(OS_CHROMEOS)
chromeos::multidevice_setup::mojom::MultiDeviceSetup,
chromeos::multidevice_setup::mojom::PrivilegedHostDeviceSetter,
chromeos::network_config::mojom::CrosNetworkConfig,
#endif
......
......@@ -491,7 +491,7 @@ void OobeUI::ConfigureOobeDisplay() {
oobe_display_chooser_ = std::make_unique<OobeDisplayChooser>();
}
void OobeUI::BindMultiDeviceSetup(
void OobeUI::BindInterface(
mojo::PendingReceiver<multidevice_setup::mojom::MultiDeviceSetup>
receiver) {
multidevice_setup::MultiDeviceSetupService* service =
......@@ -554,8 +554,6 @@ OobeUI::OobeUI(content::WebUI* web_ui, const GURL& url)
base::BindOnce(DisablePolymer2));
}
AddHandlerToRegistry(base::BindRepeating(&OobeUI::BindMultiDeviceSetup,
base::Unretained(this)));
AddHandlerToRegistry(base::BindRepeating(
&OobeUI::BindPrivilegedHostDeviceSetter, base::Unretained(this)));
AddHandlerToRegistry(base::BindRepeating(&OobeUI::BindCrosNetworkConfig,
......@@ -705,4 +703,6 @@ void OobeUI::SetLoginUserCount(int user_count) {
core_handler_->SetLoginUserCount(user_count);
}
WEB_UI_CONTROLLER_TYPE_IMPL(OobeUI)
} // namespace chromeos
......@@ -145,6 +145,12 @@ class OobeUI : public ui::MojoWebUIController {
return nullptr;
}
// Instantiates implementor of the mojom::MultiDeviceSetup mojo interface
// passing the pending receiver that will be internally bound.
void BindInterface(
mojo::PendingReceiver<multidevice_setup::mojom::MultiDeviceSetup>
receiver);
private:
void AddWebUIHandler(std::unique_ptr<BaseWebUIHandler> handler);
void AddScreenHandler(std::unique_ptr<BaseScreenHandler> handler);
......@@ -153,10 +159,6 @@ class OobeUI : public ui::MojoWebUIController {
// display type.
void ConfigureOobeDisplay();
// Adds Mojo receivers for this WebUIController.
void BindMultiDeviceSetup(
mojo::PendingReceiver<multidevice_setup::mojom::MultiDeviceSetup>
receiver);
void BindPrivilegedHostDeviceSetter(
mojo::PendingReceiver<
multidevice_setup::mojom::PrivilegedHostDeviceSetter> receiver);
......@@ -206,6 +208,8 @@ class OobeUI : public ui::MojoWebUIController {
// initialized.
std::unique_ptr<JSCallsContainer> js_calls_container_;
WEB_UI_CONTROLLER_TYPE_DECL();
DISALLOW_COPY_AND_ASSIGN(OobeUI);
};
......
......@@ -127,15 +127,11 @@ MultiDeviceSetupDialogUI::MultiDeviceSetupDialogUI(content::WebUI* web_ui)
web_ui->AddMessageHandler(std::make_unique<MultideviceSetupHandler>());
web_ui->AddMessageHandler(std::make_unique<MetricsHandler>());
content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), source);
// Add Mojo bindings to this WebUI so that Mojo calls can occur in JavaScript.
AddHandlerToRegistry(base::BindRepeating(
&MultiDeviceSetupDialogUI::BindMultiDeviceSetup, base::Unretained(this)));
}
MultiDeviceSetupDialogUI::~MultiDeviceSetupDialogUI() = default;
void MultiDeviceSetupDialogUI::BindMultiDeviceSetup(
void MultiDeviceSetupDialogUI::BindInterface(
mojo::PendingReceiver<chromeos::multidevice_setup::mojom::MultiDeviceSetup>
receiver) {
MultiDeviceSetupService* service =
......@@ -145,6 +141,8 @@ void MultiDeviceSetupDialogUI::BindMultiDeviceSetup(
service->BindMultiDeviceSetup(std::move(receiver));
}
WEB_UI_CONTROLLER_TYPE_IMPL(MultiDeviceSetupDialogUI)
} // namespace multidevice_setup
} // namespace chromeos
......@@ -60,11 +60,15 @@ class MultiDeviceSetupDialogUI : public ui::MojoWebDialogUI {
explicit MultiDeviceSetupDialogUI(content::WebUI* web_ui);
~MultiDeviceSetupDialogUI() override;
private:
void BindMultiDeviceSetup(
// Instantiates implementor of the mojom::MultiDeviceSetup mojo interface
// passing the pending receiver that will be internally bound.
void BindInterface(
mojo::PendingReceiver<
chromeos::multidevice_setup::mojom::MultiDeviceSetup> receiver);
private:
WEB_UI_CONTROLLER_TYPE_DECL();
DISALLOW_COPY_AND_ASSIGN(MultiDeviceSetupDialogUI);
};
......
......@@ -49,18 +49,18 @@ ProximityAuthUI::ProximityAuthUI(
content::WebUIDataSource::Add(browser_context, source);
web_ui->AddMessageHandler(std::make_unique<ProximityAuthWebUIHandler>(
device_sync_client, secure_channel_client));
AddHandlerToRegistry(base::BindRepeating(
&ProximityAuthUI::BindMultiDeviceSetup, base::Unretained(this)));
}
ProximityAuthUI::~ProximityAuthUI() = default;
void ProximityAuthUI::BindMultiDeviceSetup(
void ProximityAuthUI::BindInterface(
mojo::PendingReceiver<chromeos::multidevice_setup::mojom::MultiDeviceSetup>
receiver) {
multidevice_setup_binder_.Run(std::move(receiver));
}
WEB_UI_CONTROLLER_TYPE_IMPL(ProximityAuthUI)
} // namespace multidevice
} // namespace chromeos
......@@ -39,14 +39,17 @@ class ProximityAuthUI : public ui::MojoWebUIController {
MultiDeviceSetupBinder multidevice_setup_binder);
~ProximityAuthUI() override;
protected:
void BindMultiDeviceSetup(
// Instantiates implementor of the mojom::MultiDeviceSetup mojo interface
// passing the pending receiver that will be internally bound.
void BindInterface(
mojo::PendingReceiver<multidevice_setup::mojom::MultiDeviceSetup>
receiver);
private:
const MultiDeviceSetupBinder multidevice_setup_binder_;
WEB_UI_CONTROLLER_TYPE_DECL();
DISALLOW_COPY_AND_ASSIGN(ProximityAuthUI);
};
......
......@@ -94,7 +94,8 @@ class CryptAuthController {
this.showExistingUserNewChromebookNotification_.bind(this);
this.multiDeviceSetup =
chromeos.multideviceSetup.mojom.MultiDeviceSetup.getRemote();
chromeos.multideviceSetup.mojom.MultiDeviceSetup.getRemote(
/*useBrowserInterfaceBroker=*/ true);
}
/**
......
......@@ -22,7 +22,8 @@ cr.define('multidevice_setup', function() {
getMojoServiceRemote() {
if (!this.remote_) {
this.remote_ =
chromeos.multideviceSetup.mojom.MultiDeviceSetup.getRemote();
chromeos.multideviceSetup.mojom.MultiDeviceSetup.getRemote(
/*useBrowserInterfaceBroker=*/ true);
}
return this.remote_;
......
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