a4de915b74
* chore: bump chromium in DEPS to db7d7b3e7cb2bc925f2abfde526280cfdfc21a41 * Update patches * chore: bump chromium in DEPS to 5613e1b99a44fcbe22f3910f803ca76903a77ec1 * Update patches * Network service: Remove primary_network_context bool. https://chromium-review.googlesource.com/c/chromium/src/+/2204678 * WebContentsObserver now implements OnRendererResponsive https://chromium-review.googlesource.com/c/chromium/src/+/2211066 * update patches * Fixup printing patch * chore: bump chromium in DEPS to e387b972cdd7160c416fa6c64a724e2258aa0218 * update patches * [printing] Move PrintHostMsg_DidPrintContent_Params to print.mojom https://chromium-review.googlesource.com/c/chromium/src/+/2212110 * [XProto] Move items from ::x11::XProto to ::x11 https://chromium-review.googlesource.com/c/chromium/src/+/2218476 * revert Add IChromeAccessible This was added in https://chromium-review.googlesource.com/c/chromium/src/+/2206224 but it breaks WOA builds because third_party/win_build_output/midl/ui/accessibility/platform/arm64 does not exist. The link above says that the new interface is behind a feature flag which is disabled by default so it is safe to remove for now. * rebaseline ichromeaccessible for Windows arm64 This patch will not be needed once we get the next roll. * Update to 1b9e01844e8bf1aaafc4a52c0c62af7f56d9637b to get arm64 fix * update patches * chore: bump chromium in DEPS to 096aefa04092ea00f7b68d8d19345883f20db3c3 * chore: bump chromium in DEPS to a524a45ffd1d6fd46a7a86138fe2b22df5b6651a * chore: update patches * Window Placement: Gate cross-screen fullscreen behavior on permission https://chromium-review.googlesource.com/c/chromium/src/+/2203268 * chore: add spec for https://crbug.com/1085836 * chore: bump chromium in DEPS to ff6c4f4b826d66c2e32380bf5d1eb5e1fe37faef * update patches Co-authored-by: John Kleinschmidt <jkleinsc@github.com> Co-authored-by: Electron Bot <anonymous@electronjs.org> Co-authored-by: deepak1556 <hop2deep@gmail.com>
287 lines
13 KiB
Diff
287 lines
13 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: deepak1556 <hop2deep@gmail.com>
|
|
Date: Mon, 3 Jun 2019 14:20:05 -0700
|
|
Subject: frame_host_manager.patch
|
|
|
|
Allows embedder to intercept site instances chosen by chromium
|
|
and respond with custom instance. Also allows for us to at-runtime
|
|
enable or disable this patch.
|
|
|
|
diff --git a/content/browser/browsing_instance.cc b/content/browser/browsing_instance.cc
|
|
index 8da8fc97f141159811e24b51ee9bdd6be045d726..e756441aa7a871934be72be67f35351316b59245 100644
|
|
--- a/content/browser/browsing_instance.cc
|
|
+++ b/content/browser/browsing_instance.cc
|
|
@@ -84,6 +84,13 @@ scoped_refptr<SiteInstanceImpl> BrowsingInstance::GetSiteInstanceForURL(
|
|
return instance;
|
|
}
|
|
|
|
+scoped_refptr<SiteInstanceImpl> BrowsingInstance::CreateSiteInstanceForURL(
|
|
+ const GURL& url) {
|
|
+ scoped_refptr<SiteInstanceImpl> instance = new SiteInstanceImpl(this);
|
|
+ instance->SetSite(url);
|
|
+ return instance;
|
|
+}
|
|
+
|
|
void BrowsingInstance::GetSiteAndLockForURL(const GURL& url,
|
|
bool allow_default_instance,
|
|
GURL* site_url,
|
|
diff --git a/content/browser/browsing_instance.h b/content/browser/browsing_instance.h
|
|
index 06f0961e122f326e41610dd7a1b32fa752f0c68f..a041189f79cea5b59e1792b79c1348e316ca3f1e 100644
|
|
--- a/content/browser/browsing_instance.h
|
|
+++ b/content/browser/browsing_instance.h
|
|
@@ -136,6 +136,11 @@ class CONTENT_EXPORT BrowsingInstance final
|
|
const GURL& url,
|
|
bool allow_default_instance);
|
|
|
|
+ // Create a new SiteInstance for the given URL bound the current
|
|
+ // BrowsingInstance.
|
|
+ scoped_refptr<SiteInstanceImpl> CreateSiteInstanceForURL(
|
|
+ const GURL& url);
|
|
+
|
|
// Adds the given SiteInstance to our map, to ensure that we do not create
|
|
// another SiteInstance for the same site.
|
|
void RegisterSiteInstance(SiteInstanceImpl* site_instance);
|
|
diff --git a/content/browser/frame_host/navigation_request.cc b/content/browser/frame_host/navigation_request.cc
|
|
index fa3ed4e33b4fbe274738442f22e07ba233056ce8..e8e4eb7963b443b95e98a173df497d1662f9226b 100644
|
|
--- a/content/browser/frame_host/navigation_request.cc
|
|
+++ b/content/browser/frame_host/navigation_request.cc
|
|
@@ -1278,6 +1278,24 @@ void NavigationRequest::BeginNavigation() {
|
|
// it immediately.
|
|
EnterChildTraceEvent("ResponseStarted", this);
|
|
|
|
+ // In Electron, a new process is started for every navigation when node is
|
|
+ // integrated in the renderer. Since GetFrameHostForNavigation is called more
|
|
+ // than once per navigation, we want to return the same frame host once
|
|
+ // the response has started, otherwise if the frame host that started the response
|
|
+ // and the frame host that is available for commit don't match then request will
|
|
+ // be cancelled. We rely on the NavigationRequest::state_ to determine this
|
|
+ // factor
|
|
+ //
|
|
+ // bool has_response_started =
|
|
+ // (request->state() >= NavigationRequest::WILL_PROCESS_RESPONSE &&
|
|
+ // !speculative_render_frame_host_);
|
|
+ //
|
|
+ // Hence this call is necesary before the call to GetFrameHostForNavigation. Also
|
|
+ // the state_ here is anyway going to end up being READY_TO_COMMIT because of
|
|
+ // ReadyToCommitNavigation a few lines later, so will not affect normal chromium
|
|
+ // request cycle.
|
|
+ state_ = READY_TO_COMMIT;
|
|
+
|
|
// Select an appropriate RenderFrameHost.
|
|
render_frame_host_ =
|
|
frame_tree_node_->render_manager()->GetFrameHostForNavigation(this);
|
|
diff --git a/content/browser/frame_host/render_frame_host_manager.cc b/content/browser/frame_host/render_frame_host_manager.cc
|
|
index 829a14c0cc306fa74c80b7c123ddaa309c0c18c9..49a47e1f8d1fc4161684a13b6fdaceb6762234ad 100644
|
|
--- a/content/browser/frame_host/render_frame_host_manager.cc
|
|
+++ b/content/browser/frame_host/render_frame_host_manager.cc
|
|
@@ -2464,6 +2464,16 @@ bool RenderFrameHostManager::InitRenderView(
|
|
scoped_refptr<SiteInstance>
|
|
RenderFrameHostManager::GetSiteInstanceForNavigationRequest(
|
|
NavigationRequest* request) {
|
|
+ // Compute the SiteInstance that the navigation should use, which will be
|
|
+ // either the current SiteInstance or a new one.
|
|
+ //
|
|
+ // TODO(clamy): We should also consider as a candidate SiteInstance the
|
|
+ // speculative SiteInstance that was computed on redirects.
|
|
+ SiteInstanceImpl* candidate_site_instance =
|
|
+ speculative_render_frame_host_
|
|
+ ? speculative_render_frame_host_->GetSiteInstance()
|
|
+ : nullptr;
|
|
+
|
|
SiteInstance* current_site_instance = render_frame_host_->GetSiteInstance();
|
|
|
|
// All children of MHTML documents must be MHTML documents. They all live in
|
|
@@ -2483,10 +2493,60 @@ RenderFrameHostManager::GetSiteInstanceForNavigationRequest(
|
|
//
|
|
// TODO(clamy): We should also consider as a candidate SiteInstance the
|
|
// speculative SiteInstance that was computed on redirects.
|
|
- SiteInstanceImpl* candidate_site_instance =
|
|
- speculative_render_frame_host_
|
|
- ? speculative_render_frame_host_->GetSiteInstance()
|
|
- : nullptr;
|
|
+ if (!GetContentClient()->browser()->CanUseCustomSiteInstance() &&
|
|
+ frame_tree_node_->IsMainFrame()) {
|
|
+ BrowserContext* browser_context =
|
|
+ delegate_->GetControllerForRenderManager().GetBrowserContext();
|
|
+ bool has_navigation_started = request->state() != NavigationRequest::NOT_STARTED;
|
|
+ bool has_response_started =
|
|
+ (request->state() >= NavigationRequest::WILL_PROCESS_RESPONSE &&
|
|
+ !speculative_render_frame_host_);
|
|
+ // Gives user a chance to choose a custom site instance.
|
|
+ SiteInstance* affinity_site_instance = nullptr;
|
|
+ scoped_refptr<SiteInstance> overriden_site_instance;
|
|
+ bool should_register_site_instance = false;
|
|
+ ContentBrowserClient::SiteInstanceForNavigationType siteInstanceType =
|
|
+ GetContentClient()->browser()->ShouldOverrideSiteInstanceForNavigation(
|
|
+ current_frame_host(), speculative_frame_host(), browser_context,
|
|
+ request->common_params().url, has_navigation_started,
|
|
+ has_response_started, &affinity_site_instance);
|
|
+ switch (siteInstanceType) {
|
|
+ case ContentBrowserClient::SiteInstanceForNavigationType::
|
|
+ FORCE_CANDIDATE_OR_NEW:
|
|
+ overriden_site_instance =
|
|
+ candidate_site_instance
|
|
+ ? candidate_site_instance
|
|
+ : current_site_instance->CreateRelatedSiteInstance(
|
|
+ request->common_params().url);
|
|
+ should_register_site_instance = true;
|
|
+ break;
|
|
+ case ContentBrowserClient::SiteInstanceForNavigationType::FORCE_NEW:
|
|
+ overriden_site_instance = current_site_instance->CreateRelatedSiteInstance(
|
|
+ request->common_params().url);
|
|
+ should_register_site_instance = true;
|
|
+ break;
|
|
+ case ContentBrowserClient::SiteInstanceForNavigationType::FORCE_CURRENT:
|
|
+ overriden_site_instance = render_frame_host_->GetSiteInstance();
|
|
+ break;
|
|
+ case ContentBrowserClient::SiteInstanceForNavigationType::FORCE_AFFINITY:
|
|
+ DCHECK(affinity_site_instance);
|
|
+ overriden_site_instance =
|
|
+ scoped_refptr<SiteInstance>(affinity_site_instance);
|
|
+ break;
|
|
+ case ContentBrowserClient::SiteInstanceForNavigationType::ASK_CHROMIUM:
|
|
+ DCHECK(!affinity_site_instance);
|
|
+ break;
|
|
+ default:
|
|
+ break;
|
|
+ }
|
|
+ if (overriden_site_instance) {
|
|
+ if (should_register_site_instance) {
|
|
+ GetContentClient()->browser()->RegisterPendingSiteInstance(
|
|
+ render_frame_host_.get(), overriden_site_instance.get());
|
|
+ }
|
|
+ return overriden_site_instance;
|
|
+ }
|
|
+ }
|
|
|
|
// Account for renderer-initiated reload as well.
|
|
// Needed as a workaround for https://crbug.com/1045524, remove it when it is
|
|
@@ -2551,6 +2611,9 @@ RenderFrameHostManager::GetSiteInstanceForNavigationRequest(
|
|
request->ResetStateForSiteInstanceChange();
|
|
}
|
|
|
|
+ GetContentClient()->browser()->RegisterPendingSiteInstance(
|
|
+ render_frame_host_.get(), dest_site_instance.get());
|
|
+
|
|
return dest_site_instance;
|
|
}
|
|
|
|
diff --git a/content/browser/site_instance_impl.cc b/content/browser/site_instance_impl.cc
|
|
index e17d9239c65aac5d0038a2162405b9f8525603ba..44361c84ff6bdee12908d518a84ec773c067d614 100644
|
|
--- a/content/browser/site_instance_impl.cc
|
|
+++ b/content/browser/site_instance_impl.cc
|
|
@@ -456,6 +456,10 @@ bool SiteInstanceImpl::HasRelatedSiteInstance(const GURL& url) {
|
|
return browsing_instance_->HasSiteInstance(url);
|
|
}
|
|
|
|
+scoped_refptr<SiteInstance> SiteInstanceImpl::CreateRelatedSiteInstance(const GURL& url) {
|
|
+ return browsing_instance_->CreateSiteInstanceForURL(url);
|
|
+}
|
|
+
|
|
scoped_refptr<SiteInstance> SiteInstanceImpl::GetRelatedSiteInstance(
|
|
const GURL& url) {
|
|
return browsing_instance_->GetSiteInstanceForURL(
|
|
diff --git a/content/browser/site_instance_impl.h b/content/browser/site_instance_impl.h
|
|
index 10dd6f03af22bd7d0f7b65a58d4a58430c129b49..88504adb27e6461648f7dce48c93e2e1a7004fb8 100644
|
|
--- a/content/browser/site_instance_impl.h
|
|
+++ b/content/browser/site_instance_impl.h
|
|
@@ -98,6 +98,7 @@ class CONTENT_EXPORT SiteInstanceImpl final : public SiteInstance,
|
|
BrowserContext* GetBrowserContext() override;
|
|
const GURL& GetSiteURL() override;
|
|
scoped_refptr<SiteInstance> GetRelatedSiteInstance(const GURL& url) override;
|
|
+ scoped_refptr<SiteInstance> CreateRelatedSiteInstance(const GURL& url) override;
|
|
bool IsRelatedSiteInstance(const SiteInstance* instance) override;
|
|
size_t GetRelatedActiveContentsCount() override;
|
|
bool RequiresDedicatedProcess() override;
|
|
diff --git a/content/public/browser/content_browser_client.cc b/content/public/browser/content_browser_client.cc
|
|
index 8f36f7277a59d297a0700d1dfd5d8120f6a0ffa1..4858b868972c02f580789a6e396fd5db52154bad 100644
|
|
--- a/content/public/browser/content_browser_client.cc
|
|
+++ b/content/public/browser/content_browser_client.cc
|
|
@@ -59,6 +59,21 @@
|
|
|
|
namespace content {
|
|
|
|
+bool ContentBrowserClient::CanUseCustomSiteInstance() {
|
|
+ return false;
|
|
+}
|
|
+
|
|
+ContentBrowserClient::SiteInstanceForNavigationType ContentBrowserClient::ShouldOverrideSiteInstanceForNavigation(
|
|
+ content::RenderFrameHost* current_rfh,
|
|
+ content::RenderFrameHost* speculative_rfh,
|
|
+ content::BrowserContext* browser_context,
|
|
+ const GURL& url,
|
|
+ bool has_navigation_started,
|
|
+ bool has_request_started,
|
|
+ content::SiteInstance** affinity_site_instance) const {
|
|
+ return SiteInstanceForNavigationType::ASK_CHROMIUM;
|
|
+}
|
|
+
|
|
std::unique_ptr<BrowserMainParts> ContentBrowserClient::CreateBrowserMainParts(
|
|
const MainFunctionParams& parameters) {
|
|
return nullptr;
|
|
diff --git a/content/public/browser/content_browser_client.h b/content/public/browser/content_browser_client.h
|
|
index 463fcc56d05a2e18c1d3752b5e7e275c8797eca8..df1e5d1ed6e9e40ac14f1aef289801b6d63fa78d 100644
|
|
--- a/content/public/browser/content_browser_client.h
|
|
+++ b/content/public/browser/content_browser_client.h
|
|
@@ -236,8 +236,45 @@ class CONTENT_EXPORT ContentBrowserClient {
|
|
using IsClipboardPasteAllowedCallback =
|
|
base::OnceCallback<void(ClipboardPasteAllowed)>;
|
|
|
|
+ // Identifies the type of site instance to use for a navigation.
|
|
+ enum SiteInstanceForNavigationType {
|
|
+ // Use either the candidate site instance or, if it doesn't exist
|
|
+ // a new, unrelated site instance for the navigation.
|
|
+ FORCE_CANDIDATE_OR_NEW = 0,
|
|
+
|
|
+ // Use the current site instance for the navigation.
|
|
+ FORCE_CURRENT,
|
|
+
|
|
+ // Use a new, unrelated site instance.
|
|
+ FORCE_NEW,
|
|
+
|
|
+ // Use the provided affinity site instance for the navigation.
|
|
+ FORCE_AFFINITY,
|
|
+
|
|
+ // Delegate the site instance creation to Chromium.
|
|
+ ASK_CHROMIUM
|
|
+ };
|
|
+
|
|
virtual ~ContentBrowserClient() {}
|
|
|
|
+ // Electron: Allows disabling the below ShouldOverride patch
|
|
+ virtual bool CanUseCustomSiteInstance();
|
|
+
|
|
+ // Electron: Allows overriding the SiteInstance when navigating.
|
|
+ virtual SiteInstanceForNavigationType ShouldOverrideSiteInstanceForNavigation(
|
|
+ content::RenderFrameHost* current_rfh,
|
|
+ content::RenderFrameHost* speculative_rfh,
|
|
+ content::BrowserContext* browser_context,
|
|
+ const GURL& url,
|
|
+ bool has_navigation_started,
|
|
+ bool has_request_started,
|
|
+ content::SiteInstance** affinity_site_instance) const;
|
|
+
|
|
+ // Electron: Registers a pending site instance during a navigation.
|
|
+ virtual void RegisterPendingSiteInstance(
|
|
+ content::RenderFrameHost* rfh,
|
|
+ content::SiteInstance* pending_site_instance) {}
|
|
+
|
|
// Allows the embedder to set any number of custom BrowserMainParts
|
|
// implementations for the browser startup code. See comments in
|
|
// browser_main_parts.h.
|
|
diff --git a/content/public/browser/site_instance.h b/content/public/browser/site_instance.h
|
|
index 82b5d4c25adc7071dfcfe56047520fa2fa7b72f2..8535ed4ab3ca5a90f3de7ab9e80159b2082e7dfa 100644
|
|
--- a/content/public/browser/site_instance.h
|
|
+++ b/content/public/browser/site_instance.h
|
|
@@ -121,6 +121,11 @@ class CONTENT_EXPORT SiteInstance : public base::RefCounted<SiteInstance> {
|
|
// corresponds to a site URL with the host "example.com".
|
|
virtual const GURL& GetSiteURL() = 0;
|
|
|
|
+ // Create a SiteInstance for the given URL that shares the current
|
|
+ // BrowsingInstance.
|
|
+ virtual scoped_refptr<SiteInstance> CreateRelatedSiteInstance(
|
|
+ const GURL& url) = 0;
|
|
+
|
|
// Gets a SiteInstance for the given URL that shares the current
|
|
// BrowsingInstance, creating a new SiteInstance if necessary. This ensures
|
|
// that a BrowsingInstance only has one SiteInstance per site, so that pages
|