2018-10-24 18:24:11 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2018-09-21 00:30:26 +00:00
|
|
|
From: deepak1556 <hop2deep@gmail.com>
|
|
|
|
Date: Thu, 20 Sep 2018 17:45:59 -0700
|
|
|
|
Subject: frame_host_manager.patch
|
|
|
|
|
|
|
|
|
2018-09-14 05:02:16 +00:00
|
|
|
diff --git a/content/browser/frame_host/render_frame_host_manager.cc b/content/browser/frame_host/render_frame_host_manager.cc
|
2018-11-20 20:28:26 +00:00
|
|
|
index 872e4609c94f1e052d623ae57c1279c72eb2c3f4..a59676004f2411631418bf12e2978623b9b27b53 100644
|
2018-09-14 05:02:16 +00:00
|
|
|
--- a/content/browser/frame_host/render_frame_host_manager.cc
|
|
|
|
+++ b/content/browser/frame_host/render_frame_host_manager.cc
|
2018-11-20 20:28:26 +00:00
|
|
|
@@ -1960,6 +1960,18 @@ RenderFrameHostManager::GetSiteInstanceForNavigationRequest(
|
2018-09-14 05:02:16 +00:00
|
|
|
bool was_server_redirect = request.navigation_handle() &&
|
|
|
|
request.navigation_handle()->WasServerRedirect();
|
|
|
|
|
|
|
|
+ BrowserContext* browser_context =
|
|
|
|
+ delegate_->GetControllerForRenderManager().GetBrowserContext();
|
|
|
|
+ // If the navigation can swap SiteInstances, compute the SiteInstance it
|
|
|
|
+ // should use.
|
|
|
|
+ // TODO(clamy): We should also consider as a candidate SiteInstance the
|
|
|
|
+ // speculative SiteInstance that was computed on redirects.
|
|
|
|
+ scoped_refptr<SiteInstance> candidate_site_instance =
|
|
|
|
+ speculative_render_frame_host_
|
|
|
|
+ ? speculative_render_frame_host_->GetSiteInstance()
|
2018-11-20 20:28:26 +00:00
|
|
|
+ : content::SiteInstance::CreateForURL(browser_context,
|
|
|
|
+ request.common_params().url);
|
2018-09-14 05:02:16 +00:00
|
|
|
+
|
|
|
|
if (frame_tree_node_->IsMainFrame()) {
|
|
|
|
// Renderer-initiated main frame navigations that may require a
|
|
|
|
// SiteInstance swap are sent to the browser via the OpenURL IPC and are
|
2018-11-20 20:28:26 +00:00
|
|
|
@@ -1979,6 +1991,19 @@ RenderFrameHostManager::GetSiteInstanceForNavigationRequest(
|
2018-09-14 18:03:43 +00:00
|
|
|
request.common_params().url));
|
2018-09-14 05:02:16 +00:00
|
|
|
no_renderer_swap_allowed |=
|
|
|
|
request.from_begin_navigation() && !can_renderer_initiate_transfer;
|
|
|
|
+
|
|
|
|
+ bool has_response_started =
|
|
|
|
+ (request.state() == NavigationRequest::RESPONSE_STARTED ||
|
|
|
|
+ request.state() == NavigationRequest::FAILED) &&
|
|
|
|
+ !speculative_render_frame_host_;
|
|
|
|
+ // Gives user a chance to choose a custom site instance.
|
2018-11-20 20:28:26 +00:00
|
|
|
+ SiteInstance* client_custom_instance = nullptr;
|
|
|
|
+ GetContentClient()->browser()->OverrideSiteInstanceForNavigation(
|
|
|
|
+ render_frame_host_.get(), browser_context, request.common_params().url,
|
|
|
|
+ has_response_started, candidate_site_instance.get(),
|
|
|
|
+ &client_custom_instance);
|
|
|
|
+ if (client_custom_instance)
|
|
|
|
+ return scoped_refptr<SiteInstance>(client_custom_instance);
|
2018-09-14 05:02:16 +00:00
|
|
|
} else {
|
|
|
|
// Subframe navigations will use the current renderer, unless specifically
|
|
|
|
// allowed to swap processes.
|
2018-11-20 20:28:26 +00:00
|
|
|
@@ -1990,18 +2015,9 @@ RenderFrameHostManager::GetSiteInstanceForNavigationRequest(
|
2018-09-14 05:02:16 +00:00
|
|
|
if (no_renderer_swap_allowed)
|
|
|
|
return scoped_refptr<SiteInstance>(current_site_instance);
|
|
|
|
|
|
|
|
- // If the navigation can swap SiteInstances, compute the SiteInstance it
|
|
|
|
- // should use.
|
|
|
|
- // TODO(clamy): We should also consider as a candidate SiteInstance the
|
|
|
|
- // speculative SiteInstance that was computed on redirects.
|
|
|
|
- SiteInstance* candidate_site_instance =
|
|
|
|
- speculative_render_frame_host_
|
|
|
|
- ? speculative_render_frame_host_->GetSiteInstance()
|
|
|
|
- : nullptr;
|
|
|
|
-
|
|
|
|
scoped_refptr<SiteInstance> dest_site_instance = GetSiteInstanceForNavigation(
|
|
|
|
request.common_params().url, request.source_site_instance(),
|
|
|
|
- request.dest_site_instance(), candidate_site_instance,
|
|
|
|
+ request.dest_site_instance(), candidate_site_instance.get(),
|
|
|
|
request.common_params().transition,
|
2018-09-14 18:03:43 +00:00
|
|
|
request.state() == NavigationRequest::FAILED,
|
2018-09-14 05:02:16 +00:00
|
|
|
request.restore_type() != RestoreType::NONE, request.is_view_source(),
|
|
|
|
diff --git a/content/public/browser/content_browser_client.h b/content/public/browser/content_browser_client.h
|
2018-11-20 20:28:26 +00:00
|
|
|
index 3be31602689cb93b965729cc4e35cf6d23a8ec2f..2c22cb1cfe0dddc97c00e5f4ff89de6b18bc232f 100644
|
2018-09-14 05:02:16 +00:00
|
|
|
--- a/content/public/browser/content_browser_client.h
|
|
|
|
+++ b/content/public/browser/content_browser_client.h
|
2018-11-20 20:28:26 +00:00
|
|
|
@@ -196,6 +196,15 @@ class CONTENT_EXPORT ContentBrowserClient {
|
2018-09-14 05:02:16 +00:00
|
|
|
public:
|
|
|
|
virtual ~ContentBrowserClient() {}
|
|
|
|
|
|
|
|
+ // Electron: Allows overriding the SiteInstance when navigating.
|
2018-11-20 20:28:26 +00:00
|
|
|
+ virtual void OverrideSiteInstanceForNavigation(
|
2018-09-14 05:02:16 +00:00
|
|
|
+ RenderFrameHost* render_frame_host,
|
|
|
|
+ BrowserContext* browser_context,
|
|
|
|
+ const GURL& dest_url,
|
|
|
|
+ bool has_response_started,
|
2018-11-20 20:28:26 +00:00
|
|
|
+ SiteInstance* candidate_site_instance,
|
|
|
|
+ SiteInstance** new_instance) {}
|
2018-09-14 05:02:16 +00:00
|
|
|
+
|
|
|
|
// Allows the embedder to set any number of custom BrowserMainParts
|
|
|
|
// implementations for the browser startup code. See comments in
|
|
|
|
// browser_main_parts.h.
|