Fix nativeWindowOpen's opener being null

This commit is contained in:
Samuel Attard 2017-07-29 19:21:28 +10:00
parent d38c9a4644
commit 3ac2f674bc
No known key found for this signature in database
GPG key ID: 273DC1869D8F13EF

View file

@ -100,13 +100,14 @@ bool AtomBrowserClient::ShouldCreateNewSiteInstance(
int process_id = current_instance->GetProcess()->GetID(); int process_id = current_instance->GetProcess()->GetID();
if (!IsRendererSandboxed(process_id)) { if (!IsRendererSandboxed(process_id)) {
if (!RendererUsesNativeWindowOpen(process_id)) { auto web_contents =
content::WebContents::FromRenderFrameHost(render_frame_host);
if (!WebContentsPreferences::UsesNativeWindowOpen(web_contents)) {
// non-sandboxed renderers without native window.open should always create // non-sandboxed renderers without native window.open should always create
// a new SiteInstance // a new SiteInstance
return true; return true;
} }
auto web_contents =
content::WebContents::FromRenderFrameHost(render_frame_host);
if (!ChildWebContentsTracker::IsChildWebContents(web_contents)) { if (!ChildWebContentsTracker::IsChildWebContents(web_contents)) {
// Root WebContents should always create new process to make sure // Root WebContents should always create new process to make sure
// native addons are loaded correctly after reload / navigation. // native addons are loaded correctly after reload / navigation.
@ -114,6 +115,14 @@ bool AtomBrowserClient::ShouldCreateNewSiteInstance(
// reuse process to allow synchronous cross-window scripting.) // reuse process to allow synchronous cross-window scripting.)
return true; return true;
} }
// In a non-sandboxed renderer with native window open we should
// reuse the same site to allow cross-window scripting. We do
// not need to check urls / domains as native window open logic
// handles cross site scripting protection.
if (WebContentsPreferences::UsesNativeWindowOpen(web_contents)) {
return false;
}
} }
// Create new a SiteInstance if navigating to a different site. // Create new a SiteInstance if navigating to a different site.