Revert "Reuse site instance only on window.open"

This reverts commit 4d61d071b2.
This commit is contained in:
Ryohei Ikegami 2017-04-04 13:48:17 +09:00
parent 37c4569982
commit 3eab5df4a4
3 changed files with 10 additions and 26 deletions

View file

@ -468,7 +468,6 @@ void WebContents::AddNewContents(content::WebContents* source,
if (Emit("-add-new-contents", api_web_contents, disposition, user_gesture,
initial_rect.x(), initial_rect.y(), initial_rect.width(),
initial_rect.height())) {
AtomBrowserClient::CancelReuseRendererProcessForNewWindow();
api_web_contents->DestroyWebContents();
}
}

View file

@ -51,10 +51,6 @@ namespace {
// Next navigation should not restart renderer process.
bool g_suppress_renderer_process_restart = false;
// Next navigation is caused by native window.open and
// the renderer process may be reused.
bool g_reuse_renderer_process_for_new_window = false;
// Custom schemes to be registered to handle service worker.
std::string g_custom_service_worker_schemes = "";
@ -68,10 +64,6 @@ void AtomBrowserClient::SuppressRendererProcessRestartForOnce() {
g_suppress_renderer_process_restart = true;
}
void AtomBrowserClient::CancelReuseRendererProcessForNewWindow() {
g_reuse_renderer_process_for_new_window = false;
}
void AtomBrowserClient::SetCustomServiceWorkerSchemes(
const std::vector<std::string>& schemes) {
g_custom_service_worker_schemes = base::JoinString(schemes, ",");
@ -98,22 +90,16 @@ bool AtomBrowserClient::ShouldCreateNewSiteInstance(
content::BrowserContext* browser_context,
content::SiteInstance* current_instance,
const GURL& url) {
if (g_suppress_renderer_process_restart) {
g_suppress_renderer_process_restart = false;
return false;
}
if (url.SchemeIs(url::kJavaScriptScheme))
// "javacript:" scheme should always use same SiteInstance
return false;
int process_id = current_instance->GetProcess()->GetID();
if (g_reuse_renderer_process_for_new_window) {
// native window.open can reuse renderer process
g_reuse_renderer_process_for_new_window = false;
} else if (!IsRendererSandboxed(process_id)) {
if (!(IsRendererSandboxed(process_id)
|| RendererUsesNativeWindowOpen(process_id)))
// non-sandboxed renderers should always create a new SiteInstance
return true;
}
// Create new a SiteInstance if navigating to a different site.
auto src_url = current_instance->GetSiteURL();
@ -202,6 +188,11 @@ void AtomBrowserClient::OverrideSiteInstanceForNavigation(
content::SiteInstance* current_instance,
const GURL& url,
content::SiteInstance** new_instance) {
if (g_suppress_renderer_process_restart) {
g_suppress_renderer_process_restart = false;
return;
}
if (!ShouldCreateNewSiteInstance(browser_context, current_instance, url))
return;
@ -331,12 +322,8 @@ bool AtomBrowserClient::CanCreateWindow(
bool* no_javascript_access) {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
if (IsRendererSandboxed(render_process_id)) {
*no_javascript_access = false;
return true;
}
if (RendererUsesNativeWindowOpen(render_process_id)) {
g_reuse_renderer_process_for_new_window = true;
if (IsRendererSandboxed(render_process_id)
|| RendererUsesNativeWindowOpen(render_process_id)) {
*no_javascript_access = false;
return true;
}

View file

@ -40,8 +40,6 @@ class AtomBrowserClient : public brightray::BrowserClient,
// Don't force renderer process to restart for once.
static void SuppressRendererProcessRestartForOnce();
// Cancel reusing renderer process for new window.
static void CancelReuseRendererProcessForNewWindow();
// Custom schemes to be registered to handle service worker.
static void SetCustomServiceWorkerSchemes(