Commit 87072389 authored by Mario Sanchez Prada's avatar Mario Sanchez Prada Committed by Commit Bot

Migrate new_tab_page::mojom::PageHandlerFactory 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: Ib8c5141ae28a0789df2a327d9d2305722edeeead
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1953110
Commit-Queue: Mario Sanchez Prada <mario@igalia.com>
Reviewed-by: default avatarEsmael Elmoslimany <aee@chromium.org>
Reviewed-by: default avatarOksana Zhuravlova <oksamyt@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Cr-Commit-Position: refs/heads/master@{#725548}
parent f7c4aa31
......@@ -10,7 +10,6 @@
#include "chrome/browser/media/media_engagement_score_details.mojom.h"
#include "chrome/browser/ui/webui/downloads/downloads.mojom.h"
#include "chrome/browser/ui/webui/feed_internals/feed_internals.mojom.h"
#include "chrome/browser/ui/webui/new_tab_page/new_tab_page.mojom.h"
#include "chrome/browser/ui/webui/omnibox/omnibox.mojom.h"
#include "chrome/browser/ui/webui/reset_password/reset_password.mojom.h"
#include "chrome/browser/ui/webui/snippets_internals/snippets_internals.mojom.h"
......@@ -105,7 +104,6 @@ const service_manager::Manifest& GetChromeContentBrowserOverlayManifest() {
// brokered through a dedicated interface, but they're here
// for for now.
feed_internals::mojom::PageHandler,
new_tab_page::mojom::PageHandlerFactory,
#if !defined(OS_ANDROID)
app_management::mojom::PageHandlerFactory,
#endif
......
......@@ -78,6 +78,8 @@
#include "chrome/browser/payments/payment_request_factory.h"
#include "chrome/browser/ui/webui/downloads/downloads.mojom.h"
#include "chrome/browser/ui/webui/downloads/downloads_ui.h"
#include "chrome/browser/ui/webui/new_tab_page/new_tab_page.mojom.h"
#include "chrome/browser/ui/webui/new_tab_page/new_tab_page_ui.h"
#endif
#if defined(OS_CHROMEOS)
......@@ -401,6 +403,9 @@ void PopulateChromeWebUIFrameBinders(
RegisterWebUIControllerInterfaceBinder<DownloadsUI,
downloads::mojom::PageHandlerFactory>(
map);
RegisterWebUIControllerInterfaceBinder<
NewTabPageUI, new_tab_page::mojom::PageHandlerFactory>(map);
#endif
#if defined(OS_CHROMEOS)
......
......@@ -17,7 +17,8 @@ export class BrowserProxy {
/** @type {newTabPage.mojom.PageHandlerRemote} */
this.handler = new newTabPage.mojom.PageHandlerRemote();
const factory = newTabPage.mojom.PageHandlerFactory.getRemote();
const factory = newTabPage.mojom.PageHandlerFactory.getRemote(
/*useBrowserInterfaceBroker=*/ true);
factory.createPageHandler(
this.callbackRouter.$.bindNewPipeAndPassRemote(),
this.handler.$.bindNewPipeAndPassReceiver());
......
......@@ -85,14 +85,13 @@ NewTabPageUI::NewTabPageUI(content::WebUI* web_ui)
content::URLDataSource::Add(
profile_, std::make_unique<FaviconSource>(
profile_, chrome::FaviconUrlFormat::kFavicon2));
AddHandlerToRegistry(base::BindRepeating(
&NewTabPageUI::BindPageHandlerFactory, base::Unretained(this)));
}
WEB_UI_CONTROLLER_TYPE_IMPL(NewTabPageUI)
NewTabPageUI::~NewTabPageUI() = default;
void NewTabPageUI::BindPageHandlerFactory(
void NewTabPageUI::BindInterface(
mojo::PendingReceiver<new_tab_page::mojom::PageHandlerFactory>
pending_receiver) {
if (page_factory_receiver_.is_bound()) {
......
......@@ -27,11 +27,13 @@ class NewTabPageUI : public ui::MojoWebUIController,
static bool IsNewTabPageOrigin(const GURL& url);
private:
void BindPageHandlerFactory(
// Instantiates the implementor of the mojom::PageHandlerFactory mojo
// interface passing the pending receiver that will be internally bound.
void BindInterface(
mojo::PendingReceiver<new_tab_page::mojom::PageHandlerFactory>
pending_receiver);
private:
// new_tab_page::mojom::PageHandlerFactory:
void CreatePageHandler(
mojo::PendingRemote<new_tab_page::mojom::Page> pending_page,
......@@ -45,6 +47,8 @@ class NewTabPageUI : public ui::MojoWebUIController,
Profile* profile_;
WEB_UI_CONTROLLER_TYPE_DECL();
DISALLOW_COPY_AND_ASSIGN(NewTabPageUI);
};
......
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