fix: ensure ElectronBrowser mojo service is only bound to appropriate render frames (#33323)

* fix: ensure ElectronBrowser mojo service is only bound to authorized render frames

Notes: no-notes

* refactor: extract electron API IPC to its own mojo interface

* fix: just check main frame not primary main frame
This commit is contained in:
Samuel Attard 2022-03-18 19:50:05 -07:00 committed by GitHub
parent f2b06324b8
commit e07c2b84d7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 381 additions and 229 deletions

View file

@ -149,9 +149,11 @@ void ElectronRenderFrameObserver::DraggableRegionsChanged() {
regions.push_back(std::move(region));
}
mojo::AssociatedRemote<mojom::ElectronBrowser> browser_remote;
render_frame_->GetRemoteAssociatedInterfaces()->GetInterface(&browser_remote);
browser_remote->UpdateDraggableRegions(std::move(regions));
mojo::AssociatedRemote<mojom::ElectronWebContentsUtility>
web_contents_utility_remote;
render_frame_->GetRemoteAssociatedInterfaces()->GetInterface(
&web_contents_utility_remote);
web_contents_utility_remote->UpdateDraggableRegions(std::move(regions));
}
void ElectronRenderFrameObserver::WillReleaseScriptContext(
@ -168,10 +170,11 @@ void ElectronRenderFrameObserver::OnDestruct() {
void ElectronRenderFrameObserver::DidMeaningfulLayout(
blink::WebMeaningfulLayout layout_type) {
if (layout_type == blink::WebMeaningfulLayout::kVisuallyNonEmpty) {
mojo::AssociatedRemote<mojom::ElectronBrowser> browser_remote;
mojo::AssociatedRemote<mojom::ElectronWebContentsUtility>
web_contents_utility_remote;
render_frame_->GetRemoteAssociatedInterfaces()->GetInterface(
&browser_remote);
browser_remote->OnFirstNonEmptyLayout();
&web_contents_utility_remote);
web_contents_utility_remote->OnFirstNonEmptyLayout();
}
}