22a70eb803
* chore: bump chromium in DEPS to 91.0.4464.0 * chore: rebuild chromium/dcheck.patch with import-patches -3 Mechanical only; no code changes * chore: remove content_browser_main_loop.patch Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2725153 The function being patched (BrowserMainLoop::MainMessageLoopRun()) no longer exists. NB: if removing this introduces regressions the likely fix will be to add a similar patch for ShellBrowserMainParts::WillRunMainMessageLoop() which has similar code and was added at the same time this was removed. * chore: rebuild chromium/put_back_deleted_colors_for_autofill.patch with import-patches -3 Mechanical only; no code changes * chore: rebuild chromium/disable_color_correct_rendering.patch with import-patches -3 Mechanical only; no code changes * chore: rebuild chromium/eat_allow_disabling_blink_scheduler_throttling_per_renderview.patch with patch Mechanical only; no code changes * chore: rebuild chromium/gpu_notify_when_dxdiag_request_fails.patch with import-patches -3 Mechanical only; no code changes * chore: rebuild chromium/ui_gtk_public_header.patch manually no code changes * chore: rebuild chromium/web_contents.patch with import-patches -3 Mechanical only; no code changes * chore: remove v8/skip_global_registration_of_shared_arraybuffer_backing_stores.patch Refs: https://chromium-review.googlesource.com/c/v8/v8/+/2763874 This patch has been merged upstream * chore: export patches * chore: update add_trustedauthclient_to_urlloaderfactory.patch Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2757969 Sync with removal of render_frame_id_ * chore: sync chromium/put_back_deleted_colors_for_autofill.patch Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2785841 SkColorFromColorId() no longer takes theme, scheme args * chore: sync chromium/put_back_deleted_colors_for_autofill.patch Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2772143 Change new calls to GetDarkSchemeColor to fit our patched call signature * chore: update add_trustedauthclient_to_urlloaderfactory.patch Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2757969 Sync with removal of render_frame_id_ in our mojom * chore: update chromium/frame_host_manager.patch Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2740008 UrlInfo ctor now takes UrlInfo::OriginIsolationRequest instead of a bool * chore: update chromium/revert_remove_contentrendererclient_shouldfork.patch Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2755314 Upstream has removed `history_list_length_` which we were comparing to 0 to calculate our `is_initial_navigation` bool when calling ShouldFork(). ShouldFork() is ours and none of the code paths actually use that param, so this commit removes it altogether. * chore: update permissions_to_register Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2789074 Replace all uses of APIPermission::ID enum with Mojo type * refactor: update return type of PreMainMessageLoopRun() Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2725153 Used to return void; now returns an int errorcode. Note: 2725153 also has some nice doc updates about Browser's "stages" * refactor: sync ElectronBrowserMainParts to MainParts changes Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2725153 RunMainMessageLoopParts has been replaced with WillRunMainMessageLoop so `BrowserMainLoop::result_code_` is no longer available to us for our exit_code_ pointer. This variable held a dual role: (1) of course, hold the exit code, but also (2) was a nullptr before the message loop was ready, indicating to anyone calling SetExitCode() that we were still in startup and could just exit() without any extra steps. exit_code_ still fulfills these two roles but is now a base::Optional. * chore: update ElectronBrowserMainParts::PreDefaultMainMessageLoopRun Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2725153 BrowserMainParts::BrowsePreDefaultMainMesssageLoopRun() has been removed; move that work to the new WillRunMainMessageLoop(). * refactor: stop using CallbackList; it has been removed. Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2785973 * refactor: update use of threadpools. Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2773408 The upstream code is still in flux (e.g. reverts and re-lands) but the tl;dr for this commit is (1) include thread_pool.h if you're using it and (2) don't instantiate pools directly. * refactor: remove routing_id from CreateLoaderAndStart Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2762858 NB: One logic branch in ProxyingURLLoaderFactory::CreateLoaderAndStart calls std::make_unique<InProgressRequest>, which needs a routing_id. This PR uses the member field `routing_id_` since there's no longer one being passed into CreateLoaderAndStart. * refactor: sync to upstream ParittionOptions churn Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2771318 PartitionOptions' enums have changed. * refactor: update Manifest::Location usage Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2771320 tldr: s/Manifest::FOO/ManifestLocation::kFoo/ * chore: bump chromium in DEPS to 91.0.4465.0 * update patches * refactor: update extensions::Manifest to upstream Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2771320 - extensions::Manifest::COMPONENT + extensions::mojom::ManifestLocation::kExternalComponent * refactor: sync with upstream UrlInfo ctor changes Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2740008 UrlInfo ctor now takes UrlInfo::OriginIsolationRequest instead of a bool * chore: update invocation of convert_protocol_to_json.py Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2792623 python3 is being used in parts of the upstream build, but the copy of convert_protocol_to_json.py invoked in v8/third_party/inspector_protocol is not python3-friendly. Node has a py2+3-friendly version of it in its tools directory, so call it instead. * chore: use extensions::mojom::APIPermissionID Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2791122 tldr: - extensions::APIPermission::kFoo + extensions::mojom::APIPermissionID::kFoo * chore: Remove support for TLS1.0/1.1 in SSLVersionMin policy Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2765737 Remove TLS v1.0 & 1.1 from our SSLProtocolVersionFromString() function. This is the same change made upstream at https://chromium-review.googlesource.com/c/chromium/src/+/2765737/8/chrome/browser/ssl/ssl_config_service_manager_pref.cc * fixup! chore: update ElectronBrowserMainParts::PreDefaultMainMessageLoopRun * chore: Use IDType for permission change subscriptions. Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2791431 tldr: {Subscribe,Unsubscribe}PermissionStatusChange's tag type used to be an int; now it's the new SubscriptionId type (which is an IdType64). * chore: sync PowerMonitor code to upstream refactor Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2752635 tldr: PowerMonitor has been split into PowerStateObserver, PowerSuspendObserver, and PowerThermalObserver to reduce number of tasks posted to consumers who only need notifications for one of those things instead of all of them. * chore: use PartitionOptions's new Cookies field Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2771318 * Revert "refactor: remove routing_id from CreateLoaderAndStart" This reverts commit 8c9773b87a3c84f9073a47089eb2b6889d745245. 8c9773b was only a partial fix; reverting to start & try again. * update patches * chore: bump chromium in DEPS to 91.0.4466.0 * chore: update chromium/accelerator.patch Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2795472 tldr: sync patch with upstream renamed variable & macro names. * chore: update chromium/gtk_visibility.patch Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2796200 tldr: no code changes; just updating the diff to apply cleanly. note: ooh upstream Wayland hacking! * chore: update chromium/picture-in-picture.patch Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2710023 tldr: no code changes; just updating the diff to apply cleanly. * chore: update chromium/worker_feat_add_hook_to_notify_script_ready.patch Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2775573 tldr: no code changes; just updating the diff to apply cleanly. * chore: export_all_patches * chore: update chromium/feat_add_set_theme_source_to_allow_apps_to.patch Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2796511 tldr: NotifyObservers has been renamed to NotifyOnNativeThemeUpdated, so update the invocation in our patch. * chore: update ElectronBrowserClient w/upstream API Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2797454 tldr: GetDevToolsManagerDelegate() was returning an owned raw pointer. Replaced it with CreateDevToolsManagerDelegate() which uses unique_ptr<>. * chore: handle new content::PermissionType::FILE_HANDLING in toV8() Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2762201 `file-handling` string confirmed in https://chromium-review.googlesource.com/c/chromium/src/+/2762201/18/chrome/browser/ui/webui/settings/site_settings_helper.cc * refactor: remove routing_id from CreateLoaderAndStart pt 1 Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2762858 Part 1: the easiest ones * 2796724: Support Python3 https://chromium-review.googlesource.com/c/infra/luci/python-adb/+/2796724 * chore: bump chromium in DEPS to 91.0.4468.0 * 2668974: WebShare: Implement SharingServicePicker https://chromium-review.googlesource.com/c/chromium/src/+/2668974 * 2802766: Apply modernize-make-unique to media/ https://chromium-review.googlesource.com/c/chromium/src/+/2802766 * 2802823: Apply modernize-make-unique to gpu/ https://chromium-review.googlesource.com/c/chromium/src/+/2802823 * 2803041: Apply modernize-make-unique to remaining files https://chromium-review.googlesource.com/c/chromium/src/+/2803041 * 2798873: Convert GtkKeyBindingsHandler build checks to runtime checks https://chromium-review.googlesource.com/c/chromium/src/+/2798873 * 2733595: [ch-r] Parse ACCEPT_CH H2/3 frame and restart with new headers if needed https://chromium-review.googlesource.com/c/chromium/src/+/2733595 * chore: update patch indices * 2795107: Remove unused PermissionRequest IDs. https://chromium-review.googlesource.com/c/chromium/src/+/2795107 * chore: bump chromium in DEPS to 91.0.4469.0 * chore: fixup patch indices * chore: bump chromium in DEPS to 91.0.4469.5 * PiP 1.5: Add microphone, camera, and hang up buttons to the PiP window https://chromium-review.googlesource.com/c/chromium/src/+/2710023 * fixup! refactor: remove routing_id from CreateLoaderAndStart * refactor: use URLLoaderNetworkServiceObserver for auth requests from SimpleURLLoader * fixup! chore: fixup patch indices * 2724817: Expand scope of wasm-eval to all URLs https://chromium-review.googlesource.com/c/chromium/src/+/2724817 * Fixup patch after rebase * chore: bump chromium in DEPS to 91.0.4472.0 * 2797341: [ozone/x11] Enabled the global shortcut listener. https://chromium-review.googlesource.com/c/chromium/src/+/2797341 * 2805553: Reland Add GTK ColorMixers to ColorPipeline P1 https://chromium-review.googlesource.com/c/chromium/src/+/2805553 *2804366
: PiP 1.5: Label back to tab button with origin and center it https://chromium-review.googlesource.com/c/chromium/src/+/2804366 * 2784730: Fix crash on AX mode change in NativeViewHost without a Widget https://chromium-review.googlesource.com/c/chromium/src/+/2784730 * chore: update patch indices * 2810174: Add PdfAnnotationsEnabled policy. https://chromium-review.googlesource.com/c/chromium/src/+/2810174 * 2807829: Allow capturers to indicate if they want a WakeLock or not. https://chromium-review.googlesource.com/c/chromium/src/+/2807829 * chore: bump chromium in DEPS to 92.0.4473.0 * chore: bump chromium in DEPS to 92.0.4474.0 * chore: bump chromium in DEPS to 92.0.4475.0 * chore: update patches * chore: updates patches * chore: update is_media_key patch to handle new ozone impl Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2797341 * fix: ExecuteJavascript requests now need to be flagged as non-bf-aware Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2787195 * chore: icon_util_x11 is now icon_util_linux Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2791362 * build: update sysroots Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2628496 * build: fix missing symbols on linux build * use_ozone and use_x11 are not exclusive * new button view to build for pip Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2797341 Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2804366 * chore: fix broken gtk_util color patch * chore: remove patch conflict * build: update linux manifests * chore: build bttlb on all platforms for pip * chore: add thread_pool include for views delegate win * chore: fix lint * chore: add node patches for V8 changes * build: add missing base include on windows * fix: update frame host manager patch for new state transitions Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2714464 * chore: update windows zip manifests * chore: update mac zip manifests * chore: fix patch linting * refactor: implement missing URLLoaderNetworkServiceObserver methods It is against The Mojo Rules to leave hanging callbacks. These always have to be called. Refs:186528aab9
* spec: fix locale test on local linux * fix: pass the exit code correctly in new PreMainMessageLoopRun Refs:2622e91c44
* fix: ensure we early-exit when request_handler_ is not provided Refs:93077afbfb
* fix: strongly set result_code in the BrowserMainLoop * fix: invalid usage of non-targetted PostTask You must always either use a host threadpool or specify a target thread. In this case we did neither after this refactor. Refs:4e33ee0ad3
* chore: fix gn check * chore: remove stray .rej files in patch * chore: add mojo error code to url loader failure * build: ensure CI is truthy in arm test env * fix: handle windowCaptureMacV2 being enabled when fetching media source id Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2709931 Co-authored-by: Charles Kerr <charles@charleskerr.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> Co-authored-by: deepak1556 <hop2deep@gmail.com> Co-authored-by: Samuel Attard <samuel.r.attard@gmail.com> Co-authored-by: Samuel Attard <sattard@slack-corp.com>
322 lines
15 KiB
Diff
322 lines
15 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 30e374aeba7aceacdb58add9c79cb46c6b93af4d..3e34643c4e1d5561c6c7b01e3de8cdd46910afb0 100644
|
|
--- a/content/browser/browsing_instance.cc
|
|
+++ b/content/browser/browsing_instance.cc
|
|
@@ -61,6 +61,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(UrlInfo(url, UrlInfo::OriginIsolationRequest::kNone));
|
|
+ return instance;
|
|
+}
|
|
+
|
|
SiteInfo BrowsingInstance::GetSiteInfoForURL(const UrlInfo& url_info,
|
|
bool allow_default_instance) {
|
|
scoped_refptr<SiteInstanceImpl> site_instance =
|
|
diff --git a/content/browser/browsing_instance.h b/content/browser/browsing_instance.h
|
|
index f426d1ebdaa9d13c7e47f22ce617e2b61a862854..26907541dd4268e3f8c82676bdda892bd1ed04e7 100644
|
|
--- a/content/browser/browsing_instance.h
|
|
+++ b/content/browser/browsing_instance.h
|
|
@@ -151,6 +151,11 @@ class CONTENT_EXPORT BrowsingInstance final
|
|
const UrlInfo& url_info,
|
|
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/renderer_host/navigation_request.cc b/content/browser/renderer_host/navigation_request.cc
|
|
index 1f0b01cbf17267bd8c03deb4a28938566f7033ef..5ccf84c2b847e9d2cbc97f4b2390220324a807c3 100644
|
|
--- a/content/browser/renderer_host/navigation_request.cc
|
|
+++ b/content/browser/renderer_host/navigation_request.cc
|
|
@@ -1572,6 +1572,21 @@ void NavigationRequest::BeginNavigation() {
|
|
if (IsSameDocument()) {
|
|
render_frame_host_ = frame_tree_node_->current_frame_host();
|
|
} else {
|
|
+ // 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.
|
|
+ SetState(REUSE_SITE_INSTANCE);
|
|
+
|
|
// Select an appropriate RenderFrameHost.
|
|
std::string frame_host_choice_reason;
|
|
render_frame_host_ =
|
|
@@ -6152,6 +6167,7 @@ void NavigationRequest::CheckStateTransition(NavigationState state) const {
|
|
{WILL_START_REQUEST, {
|
|
WILL_REDIRECT_REQUEST,
|
|
WILL_PROCESS_RESPONSE,
|
|
+ REUSE_SITE_INSTANCE,
|
|
READY_TO_COMMIT,
|
|
DID_COMMIT,
|
|
CANCELING,
|
|
@@ -6165,10 +6181,15 @@ void NavigationRequest::CheckStateTransition(NavigationState state) const {
|
|
WILL_FAIL_REQUEST,
|
|
}},
|
|
{WILL_PROCESS_RESPONSE, {
|
|
+ REUSE_SITE_INSTANCE,
|
|
READY_TO_COMMIT,
|
|
CANCELING,
|
|
WILL_FAIL_REQUEST,
|
|
}},
|
|
+ {REUSE_SITE_INSTANCE, {
|
|
+ WILL_PROCESS_RESPONSE,
|
|
+ READY_TO_COMMIT,
|
|
+ }},
|
|
{READY_TO_COMMIT, {
|
|
NOT_STARTED,
|
|
DID_COMMIT,
|
|
diff --git a/content/browser/renderer_host/navigation_request.h b/content/browser/renderer_host/navigation_request.h
|
|
index 304de734c34efd3c4f6ab561d66ecf7d655387f8..6817bfd0ea8934b2b1a1d62415b5475d5c88d20b 100644
|
|
--- a/content/browser/renderer_host/navigation_request.h
|
|
+++ b/content/browser/renderer_host/navigation_request.h
|
|
@@ -140,6 +140,10 @@ class CONTENT_EXPORT NavigationRequest
|
|
// asynchronous.
|
|
WILL_PROCESS_RESPONSE,
|
|
|
|
+ // Electron: state that is between than WILL_PROCESS_RESPONSE and
|
|
+ // READY_TO_COMMIT to force reuse the same site instance.
|
|
+ REUSE_SITE_INSTANCE,
|
|
+
|
|
// The response started on the IO thread and is ready to be committed.
|
|
READY_TO_COMMIT,
|
|
|
|
diff --git a/content/browser/renderer_host/render_frame_host_manager.cc b/content/browser/renderer_host/render_frame_host_manager.cc
|
|
index af497e6916d72bfbd40fe9f131be6022482ef810..74f9fe3a0a0de20d48bc8b2d397109381ea66481 100644
|
|
--- a/content/browser/renderer_host/render_frame_host_manager.cc
|
|
+++ b/content/browser/renderer_host/render_frame_host_manager.cc
|
|
@@ -2859,6 +2859,16 @@ scoped_refptr<SiteInstance>
|
|
RenderFrameHostManager::GetSiteInstanceForNavigationRequest(
|
|
NavigationRequest* request,
|
|
std::string* reason) {
|
|
+ // 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
|
|
@@ -2886,10 +2896,59 @@ 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 = GetNavigationController().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
|
|
@@ -2922,6 +2981,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 8013a8606e4f01ef63b7b546fd7537f9232648c3..2f74a84667d7cf760642fb1577f22ad85ca00ecd 100644
|
|
--- a/content/browser/site_instance_impl.cc
|
|
+++ b/content/browser/site_instance_impl.cc
|
|
@@ -1135,6 +1135,10 @@ bool SiteInstanceImpl::HasRelatedSiteInstance(const SiteInfo& site_info) {
|
|
return browsing_instance_->HasSiteInstance(site_info);
|
|
}
|
|
|
|
+scoped_refptr<SiteInstance> SiteInstanceImpl::CreateRelatedSiteInstance(const GURL& url) {
|
|
+ return browsing_instance_->CreateSiteInstanceForURL(url);
|
|
+}
|
|
+
|
|
scoped_refptr<SiteInstance> SiteInstanceImpl::GetRelatedSiteInstance(
|
|
const GURL& url) {
|
|
return GetRelatedSiteInstanceImpl(
|
|
diff --git a/content/browser/site_instance_impl.h b/content/browser/site_instance_impl.h
|
|
index 40c314243ae5aa8540ce6528273ee2f0b7f0aca1..dce5cf6cde036d35c1b78b8fa768617628d380c2 100644
|
|
--- a/content/browser/site_instance_impl.h
|
|
+++ b/content/browser/site_instance_impl.h
|
|
@@ -501,6 +501,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 0d2eba4321ece3e9cfb2b16dead343dd51672714..45fe96cb01e4d6e2772f1304eb1c5ac274c4f713 100644
|
|
--- a/content/public/browser/content_browser_client.cc
|
|
+++ b/content/public/browser/content_browser_client.cc
|
|
@@ -72,6 +72,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 47befa844ca54f463b627864827aa670454dfed4..010a63958d094f65b0f1838888991ecd6679b086 100644
|
|
--- a/content/public/browser/content_browser_client.h
|
|
+++ b/content/public/browser/content_browser_client.h
|
|
@@ -261,8 +261,45 @@ class CONTENT_EXPORT ContentBrowserClient {
|
|
using IsClipboardPasteContentAllowedCallback =
|
|
base::OnceCallback<void(ClipboardPasteContentAllowed)>;
|
|
|
|
+ // 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() = default;
|
|
|
|
+ // 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 9b90d52cac2b6a0d15e1ec1f562f0e376ce6be7c..5bc69adfab68c45528ba8d5e81b03b3f6db934a7 100644
|
|
--- a/content/public/browser/site_instance.h
|
|
+++ b/content/public/browser/site_instance.h
|
|
@@ -135,6 +135,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
|