Make ElectronBrowser mojo interface frame associated. (#32734)

This commit is contained in:
marekharanczyk 2022-02-08 17:33:21 +01:00 committed by GitHub
parent 58af7d2a9a
commit e119da8ce2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 38 additions and 32 deletions

View file

@ -1450,6 +1450,12 @@ bool ElectronBrowserClient::PreSpawnChild(sandbox::TargetPolicy* policy,
}
#endif // defined(OS_WIN)
void BindElectronBrowser(
mojo::PendingAssociatedReceiver<electron::mojom::ElectronBrowser> receiver,
content::RenderFrameHost* frame_host) {
ElectronBrowserHandlerImpl::Create(frame_host, std::move(receiver));
}
bool ElectronBrowserClient::BindAssociatedReceiverFromFrame(
content::RenderFrameHost* render_frame_host,
const std::string& interface_name,
@ -1461,6 +1467,13 @@ bool ElectronBrowserClient::BindAssociatedReceiverFromFrame(
render_frame_host);
return true;
}
if (interface_name == electron::mojom::ElectronBrowser::Name_) {
BindElectronBrowser(
mojo::PendingAssociatedReceiver<electron::mojom::ElectronBrowser>(
std::move(*handle)),
render_frame_host);
return true;
}
#if BUILDFLAG(ENABLE_PRINTING)
if (interface_name == printing::mojom::PrintManagerHost::Name_) {
mojo::PendingAssociatedReceiver<printing::mojom::PrintManagerHost> receiver(
@ -1522,12 +1535,6 @@ void ElectronBrowserClient::BindHostReceiverForRenderer(
#endif
}
void BindElectronBrowser(
content::RenderFrameHost* frame_host,
mojo::PendingReceiver<electron::mojom::ElectronBrowser> receiver) {
ElectronBrowserHandlerImpl::Create(frame_host, std::move(receiver));
}
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
void BindMimeHandlerService(
content::RenderFrameHost* frame_host,
@ -1576,8 +1583,6 @@ void ElectronBrowserClient::RegisterBrowserInterfaceBindersForFrame(
base::BindRepeating(&BindNetworkHintsHandler));
map->Add<blink::mojom::BadgeService>(
base::BindRepeating(&badging::BadgeManager::BindFrameReceiver));
map->Add<electron::mojom::ElectronBrowser>(
base::BindRepeating(&BindElectronBrowser));
map->Add<blink::mojom::KeyboardLockService>(base::BindRepeating(
&content::KeyboardLockServiceImpl::CreateMojoService));
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)