8edc7a1fb1
* chore: bump chromium in DEPS to 53836640273c3d45b05ad74bdff7323ef0ffc610 * chore: bump chromium in DEPS to 17da1064b910f4170320ff37e971064916aed1dc * Rename attach_same_site_cookies param to force_ignore_site_for_cookies https://chromium-review.googlesource.com/c/chromium/src/+/2162209 * chore: update patch indices * Remove single argument HttpResponseHeaders::AddHeader() method https://chromium-review.googlesource.com/c/chromium/src/+/2155353 * Rename attach_same_site_cookies param to force_ignore_site_for_cookies https://chromium-review.googlesource.com/c/chromium/src/+/2162209 * fixup! Remove single argument HttpResponseHeaders::AddHeader() method * Exchange SandboxType::kInvalid for a CHECK. https://chromium-review.googlesource.com/c/chromium/src/+/2167995 * chore: fix string type on windows Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> Co-authored-by: deepak1556 <hop2deep@gmail.com>
121 lines
6 KiB
Diff
121 lines
6 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Shelley Vohr <shelley.vohr@gmail.com>
|
|
Date: Tue, 4 Feb 2020 08:59:32 -0700
|
|
Subject: Revert "Remove ContentRendererClient::ShouldFork."
|
|
|
|
This reverts the CL at https://chromium-review.googlesource.com/c/chromium/src/+/1812128.
|
|
We use it to force a new renderer process for navigations, and need to start a new renderer process
|
|
for every navigation to keep Node.js working properly. Once Native Modules in the renderer process
|
|
are required to be NAPI or context aware (Electron v11), this patch can be removed.
|
|
|
|
diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer/chrome_content_renderer_client.cc
|
|
index 4a1bbc64b3bcc27d742fff2b7a7b3de73e9c7426..c5505f99bed35f0eaf5b968555ed5c3be4ec1e47 100644
|
|
--- a/chrome/renderer/chrome_content_renderer_client.cc
|
|
+++ b/chrome/renderer/chrome_content_renderer_client.cc
|
|
@@ -1294,6 +1294,25 @@ bool ChromeContentRendererClient::AllowPopup() {
|
|
#endif
|
|
}
|
|
|
|
+bool ChromeContentRendererClient::ShouldFork(WebLocalFrame* frame,
|
|
+ const GURL& url,
|
|
+ const std::string& http_method,
|
|
+ bool is_initial_navigation,
|
|
+ bool is_server_redirect) {
|
|
+ DCHECK(!frame->Parent());
|
|
+
|
|
+ // If |url| matches one of the prerendered URLs, stop this navigation and try
|
|
+ // to swap in the prerendered page on the browser process. If the prerendered
|
|
+ // page no longer exists by the time the OpenURL IPC is handled, a normal
|
|
+ // navigation is attempted.
|
|
+ if (prerender_dispatcher_.get() &&
|
|
+ prerender_dispatcher_->IsPrerenderURL(url)) {
|
|
+ return true;
|
|
+ }
|
|
+
|
|
+ return false;
|
|
+}
|
|
+
|
|
void ChromeContentRendererClient::WillSendRequest(
|
|
WebLocalFrame* frame,
|
|
ui::PageTransition transition_type,
|
|
diff --git a/chrome/renderer/chrome_content_renderer_client.h b/chrome/renderer/chrome_content_renderer_client.h
|
|
index 7cea12e179544e5700e6cb393fafc8437166da9b..1042f99e33a75b76d5b59a97e813024487e31470 100644
|
|
--- a/chrome/renderer/chrome_content_renderer_client.h
|
|
+++ b/chrome/renderer/chrome_content_renderer_client.h
|
|
@@ -126,6 +126,11 @@ class ChromeContentRendererClient
|
|
base::SingleThreadTaskRunner* compositor_thread_task_runner) override;
|
|
bool RunIdleHandlerWhenWidgetsHidden() override;
|
|
bool AllowPopup() override;
|
|
+ bool ShouldFork(blink::WebLocalFrame* frame,
|
|
+ const GURL& url,
|
|
+ const std::string& http_method,
|
|
+ bool is_initial_navigation,
|
|
+ bool is_server_redirect) override;
|
|
void WillSendRequest(blink::WebLocalFrame* frame,
|
|
ui::PageTransition transition_type,
|
|
const blink::WebURL& url,
|
|
diff --git a/content/public/renderer/content_renderer_client.cc b/content/public/renderer/content_renderer_client.cc
|
|
index a1a8284038231e61d9f1d6302441e871abab4209..67a92523d1078cc7f47251614e27a6d9e9dcfb95 100644
|
|
--- a/content/public/renderer/content_renderer_client.cc
|
|
+++ b/content/public/renderer/content_renderer_client.cc
|
|
@@ -105,6 +105,14 @@ bool ContentRendererClient::HandleNavigation(
|
|
}
|
|
#endif
|
|
|
|
+bool ContentRendererClient::ShouldFork(blink::WebLocalFrame* frame,
|
|
+ const GURL& url,
|
|
+ const std::string& http_method,
|
|
+ bool is_initial_navigation,
|
|
+ bool is_server_redirect) {
|
|
+ return false;
|
|
+}
|
|
+
|
|
void ContentRendererClient::WillSendRequest(
|
|
blink::WebLocalFrame* frame,
|
|
ui::PageTransition transition_type,
|
|
diff --git a/content/public/renderer/content_renderer_client.h b/content/public/renderer/content_renderer_client.h
|
|
index b35f479d7ef121021a5df8dfb471aead9af3517b..4945bb1e132ac9b2f325850c51000b48ebd82c44 100644
|
|
--- a/content/public/renderer/content_renderer_client.h
|
|
+++ b/content/public/renderer/content_renderer_client.h
|
|
@@ -217,6 +217,13 @@ class CONTENT_EXPORT ContentRendererClient {
|
|
bool is_redirect);
|
|
#endif
|
|
|
|
+ // Returns true if we should fork a new process for the given navigation.
|
|
+ virtual bool ShouldFork(blink::WebLocalFrame* frame,
|
|
+ const GURL& url,
|
|
+ const std::string& http_method,
|
|
+ bool is_initial_navigation,
|
|
+ bool is_server_redirect);
|
|
+
|
|
// Notifies the embedder that the given frame is requesting the resource at
|
|
// |url|. If the function returns a valid |new_url|, the request must be
|
|
// updated to use it. The |force_ignore_site_for_cookies| output parameter
|
|
diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc
|
|
index 95e9039217f44dcaf770ffea2979976e79d276ab..1126ef0b8bd28142583d77261af6a9c8041d1538 100644
|
|
--- a/content/renderer/render_frame_impl.cc
|
|
+++ b/content/renderer/render_frame_impl.cc
|
|
@@ -5647,6 +5647,23 @@ void RenderFrameImpl::BeginNavigation(
|
|
// we can do a per-frame check here rather than a process-wide check.
|
|
bool should_fork = HasWebUIScheme(url) || HasWebUIScheme(old_url) ||
|
|
(enabled_bindings_ & kWebUIBindingsPolicyMask);
|
|
+
|
|
+ if (!should_fork && url.SchemeIs(url::kFileScheme)) {
|
|
+ // Fork non-file to file opens (see https://crbug.com/1031119). Note that
|
|
+ // this may fork unnecessarily if another tab (hosting a file or not)
|
|
+ // targeted this one before its initial navigation, but that shouldn't
|
|
+ // cause a problem.
|
|
+ should_fork = !old_url.SchemeIs(url::kFileScheme);
|
|
+ }
|
|
+
|
|
+ if (!should_fork) {
|
|
+ // Give the embedder a chance.
|
|
+ bool is_initial_navigation = render_view_->history_list_length_ == 0;
|
|
+ should_fork = GetContentClient()->renderer()->ShouldFork(
|
|
+ frame_, url, info->url_request.HttpMethod().Utf8(),
|
|
+ is_initial_navigation, false /* is_redirect */);
|
|
+ }
|
|
+
|
|
if (should_fork) {
|
|
OpenURL(std::move(info));
|
|
return; // Suppress the load here.
|