fix: load the chrome.* API on chrome-extension pages in sandbox mode (#15563)

With mixed sandbox enabled we need to load the chrome.* APIs in the
sandbox init.js so that chrome extensions load correctly.

This mirrors the equivilant impl in `atom_renderer_client.cc`

Fixes #15561
This commit is contained in:
Samuel Attard 2018-11-22 04:56:58 +11:00 committed by John Kleinschmidt
parent a68e3371f3
commit 0b0a17ff91
2 changed files with 20 additions and 5 deletions

View file

@ -38,6 +38,11 @@ bool IsDevTools(content::RenderFrame* render_frame) {
"chrome-devtools");
}
bool IsDevToolsExtension(content::RenderFrame* render_frame) {
return render_frame->GetWebFrame()->GetDocument().Url().ProtocolIs(
"chrome-extension");
}
v8::Local<v8::Object> GetModuleCache(v8::Isolate* isolate) {
mate::Dictionary global(isolate, isolate->GetCurrentContext()->Global());
v8::Local<v8::Value> cache;
@ -189,7 +194,8 @@ void AtomSandboxedRendererClient::DidCreateScriptContext(
// Only allow preload for the main frame or
// For devtools we still want to run the preload_bundle script
if (!render_frame->IsMainFrame() && !IsDevTools(render_frame))
if (!render_frame->IsMainFrame() && !IsDevTools(render_frame) &&
!IsDevToolsExtension(render_frame))
return;
auto* isolate = context->GetIsolate();