Always create new SiteInstance on root WebContents
This commit is contained in:
parent
90852c665d
commit
cbdd52e43b
2 changed files with 41 additions and 3 deletions
|
@ -96,9 +96,20 @@ bool AtomBrowserClient::ShouldCreateNewSiteInstance(
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
int process_id = current_instance->GetProcess()->GetID();
|
int process_id = current_instance->GetProcess()->GetID();
|
||||||
if (!IsRendererSandboxed(process_id))
|
if (!IsRendererSandboxed(process_id)) {
|
||||||
// non-sandboxed renderers should always create a new SiteInstance
|
if (!RendererUsesNativeWindowOpen(process_id)) {
|
||||||
return true;
|
// non-sandboxed renderers without native window.open should always create
|
||||||
|
// a new SiteInstance
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
auto web_contents =
|
||||||
|
content::WebContents::FromRenderFrameHost(render_frame_host);
|
||||||
|
if (root_web_contents_.find(web_contents) != root_web_contents_.end()) {
|
||||||
|
// non-sandboxed renderers with native.window.open always create a new
|
||||||
|
// SiteInstance in the root webcontents.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Create new a SiteInstance if navigating to a different site.
|
// Create new a SiteInstance if navigating to a different site.
|
||||||
auto src_url = current_instance->GetSiteURL();
|
auto src_url = current_instance->GetSiteURL();
|
||||||
|
@ -149,6 +160,8 @@ void AtomBrowserClient::RenderProcessWillLaunch(
|
||||||
AddProcessPreferences(host->GetID(), process_prefs);
|
AddProcessPreferences(host->GetID(), process_prefs);
|
||||||
// ensure the ProcessPreferences is removed later
|
// ensure the ProcessPreferences is removed later
|
||||||
host->AddObserver(this);
|
host->AddObserver(this);
|
||||||
|
|
||||||
|
new RootWebContentsTracker(web_contents, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
content::SpeechRecognitionManagerDelegate*
|
content::SpeechRecognitionManagerDelegate*
|
||||||
|
@ -392,4 +405,16 @@ void AtomBrowserClient::RenderProcessHostDestroyed(
|
||||||
RemoveProcessPreferences(process_id);
|
RemoveProcessPreferences(process_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AtomBrowserClient::RootWebContentsTracker::RootWebContentsTracker(
|
||||||
|
content::WebContents* web_contents,
|
||||||
|
AtomBrowserClient* client)
|
||||||
|
: content::WebContentsObserver(web_contents), client_(client) {
|
||||||
|
client->root_web_contents_.insert(web_contents);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AtomBrowserClient::RootWebContentsTracker::WebContentsDestroyed() {
|
||||||
|
client_->root_web_contents_.erase(web_contents());
|
||||||
|
delete this;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
|
|
||||||
#include "brightray/browser/browser_client.h"
|
#include "brightray/browser/browser_client.h"
|
||||||
#include "content/public/browser/render_process_host_observer.h"
|
#include "content/public/browser/render_process_host_observer.h"
|
||||||
|
#include "content/public/browser/web_contents_observer.h"
|
||||||
|
|
||||||
namespace content {
|
namespace content {
|
||||||
class QuotaPermissionContext;
|
class QuotaPermissionContext;
|
||||||
|
@ -136,6 +137,18 @@ class AtomBrowserClient : public brightray::BrowserClient,
|
||||||
|
|
||||||
Delegate* delegate_;
|
Delegate* delegate_;
|
||||||
|
|
||||||
|
class RootWebContentsTracker : public content::WebContentsObserver {
|
||||||
|
public:
|
||||||
|
RootWebContentsTracker(content::WebContents* web_contents,
|
||||||
|
AtomBrowserClient* client);
|
||||||
|
void WebContentsDestroyed() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
AtomBrowserClient* client_;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::set<content::WebContents*> root_web_contents_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(AtomBrowserClient);
|
DISALLOW_COPY_AND_ASSIGN(AtomBrowserClient);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue