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

Migrate crostini_installer::mojom::PageHandlerFactor 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: I273a91f6b0dfd34e4994ef8987396295ce8436f7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1969127
Commit-Queue: Miyoung Shin <myid.shin@igalia.com>
Reviewed-by: default avatarcalamity <calamity@chromium.org>
Reviewed-by: default avatarSam McNally <sammc@chromium.org>
Reviewed-by: default avatarOksana Zhuravlova <oksamyt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#726231}
parent f9006b3b
......@@ -20,7 +20,6 @@
#include "services/service_manager/public/cpp/manifest_builder.h"
#if defined(OS_CHROMEOS)
#include "chrome/browser/ui/webui/chromeos/crostini_installer/crostini_installer.mojom.h"
#include "chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader.mojom.h"
#include "chromeos/services/media_perception/public/mojom/media_perception.mojom.h"
#include "chromeos/services/multidevice_setup/public/mojom/multidevice_setup.mojom.h"
......@@ -89,7 +88,6 @@ const service_manager::Manifest& GetChromeContentBrowserOverlayManifest() {
"navigation:frame", "renderer",
service_manager::Manifest::InterfaceList<
#if defined(OS_CHROMEOS)
chromeos::crostini_installer::mojom::PageHandlerFactory,
chromeos::crostini_upgrader::mojom::PageHandlerFactory,
chromeos::multidevice_setup::mojom::MultiDeviceSetup,
chromeos::multidevice_setup::mojom::PrivilegedHostDeviceSetter,
......
......@@ -116,6 +116,8 @@
#if defined(OS_CHROMEOS)
#include "chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_dialog.h"
#include "chrome/browser/ui/webui/chromeos/crostini_installer/crostini_installer.mojom.h"
#include "chrome/browser/ui/webui/chromeos/crostini_installer/crostini_installer_ui.h"
#include "chromeos/services/cellular_setup/public/mojom/cellular_setup.mojom.h"
#endif
......@@ -443,7 +445,9 @@ void PopulateChromeWebUIFrameBinders(
RegisterWebUIControllerInterfaceBinder<
chromeos::cellular_setup::CellularSetupDialogUI,
chromeos::cellular_setup::mojom::CellularSetup>(map);
RegisterWebUIControllerInterfaceBinder<
chromeos::CrostiniInstallerUI,
chromeos::crostini_installer::mojom::PageHandlerFactory>(map);
RegisterWebUIControllerInterfaceBinder<
chromeos::machine_learning::MachineLearningInternalsUI,
chromeos::machine_learning::mojom::PageHandler>(map);
......
......@@ -17,7 +17,8 @@ export class BrowserProxy {
this.handler = new chromeos.crostiniInstaller.mojom.PageHandlerRemote();
const factory =
chromeos.crostiniInstaller.mojom.PageHandlerFactory.getRemote();
chromeos.crostiniInstaller.mojom.PageHandlerFactory.getRemote(
/*useBrowserInterfaceBroker=*/ true);
factory.createPageHandler(
this.callbackRouter.$.bindNewPipeAndPassRemote(),
this.handler.$.bindNewPipeAndPassReceiver());
......
......@@ -130,9 +130,6 @@ CrostiniInstallerUI::CrostiniInstallerUI(content::WebUI* web_ui)
source->EnableReplaceI18nInJS();
content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), source);
AddHandlerToRegistry(base::BindRepeating(
&CrostiniInstallerUI::BindPageHandlerFactory, base::Unretained(this)));
}
CrostiniInstallerUI::~CrostiniInstallerUI() = default;
......@@ -148,7 +145,7 @@ void CrostiniInstallerUI::ClickInstallForTesting() {
base::NullCallback());
}
void CrostiniInstallerUI::BindPageHandlerFactory(
void CrostiniInstallerUI::BindInterface(
mojo::PendingReceiver<
chromeos::crostini_installer::mojom::PageHandlerFactory>
pending_receiver) {
......@@ -181,4 +178,6 @@ void CrostiniInstallerUI::OnWebUICloseDialog() {
ui::MojoWebDialogUI::CloseDialog(nullptr);
}
WEB_UI_CONTROLLER_TYPE_IMPL(CrostiniInstallerUI)
} // namespace chromeos
......@@ -29,12 +29,13 @@ class CrostiniInstallerUI
bool can_close();
void ClickInstallForTesting();
private:
void BindPageHandlerFactory(
mojo::PendingReceiver<
chromeos::crostini_installer::mojom::PageHandlerFactory>
pending_receiver);
// Instantiates implementor of the mojom::PageHandlerFactory
// mojo interface passing the pending receiver that will be internally bound.
void BindInterface(mojo::PendingReceiver<
chromeos::crostini_installer::mojom::PageHandlerFactory>
pending_receiver);
private:
// chromeos::crostini_installer::mojom::PageHandlerFactory:
void CreatePageHandler(
mojo::PendingRemote<chromeos::crostini_installer::mojom::Page>
......@@ -49,6 +50,8 @@ class CrostiniInstallerUI
page_factory_receiver_{this};
bool can_close_ = false;
WEB_UI_CONTROLLER_TYPE_DECL();
DISALLOW_COPY_AND_ASSIGN(CrostiniInstallerUI);
};
......
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