2019-10-28 22:12:35 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2020-02-06 07:05:30 +00:00
|
|
|
From: Shelley Vohr <shelley.vohr@gmail.com>
|
|
|
|
Date: Tue, 4 Feb 2020 08:59:32 -0700
|
2019-10-28 22:12:35 +00:00
|
|
|
Subject: Revert "Remove ContentRendererClient::ShouldFork."
|
|
|
|
|
2020-02-06 07:05:30 +00:00
|
|
|
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.
|
2019-10-28 22:12:35 +00:00
|
|
|
|
|
|
|
diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer/chrome_content_renderer_client.cc
|
2020-03-11 11:15:07 +00:00
|
|
|
index 6600de77c3f6c6a1a2409e0afe503d752038c9fa..9fa08ef75c82a75de4edad5694b8d07aae3fba83 100644
|
2019-10-28 22:12:35 +00:00
|
|
|
--- a/chrome/renderer/chrome_content_renderer_client.cc
|
|
|
|
+++ b/chrome/renderer/chrome_content_renderer_client.cc
|
2020-03-11 11:15:07 +00:00
|
|
|
@@ -1273,6 +1273,25 @@ bool ChromeContentRendererClient::AllowPopup() {
|
2020-02-06 07:05:30 +00:00
|
|
|
#endif
|
|
|
|
}
|
2019-10-28 22:12:35 +00:00
|
|
|
|
2020-02-06 07:05:30 +00:00
|
|
|
+bool ChromeContentRendererClient::ShouldFork(WebLocalFrame* frame,
|
|
|
|
+ const GURL& url,
|
|
|
|
+ const std::string& http_method,
|
|
|
|
+ bool is_initial_navigation,
|
|
|
|
+ bool is_server_redirect) {
|
2019-10-28 22:12:35 +00:00
|
|
|
+ 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;
|
|
|
|
+ }
|
|
|
|
+
|
2020-02-06 07:05:30 +00:00
|
|
|
+ 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
|
2020-03-11 11:15:07 +00:00
|
|
|
index 8969adb44800e925c9066e51793463c09eb78622..d11a4fdf04f7632fb1191c28c83f1d66ce0e5bf2 100644
|
2020-02-06 07:05:30 +00:00
|
|
|
--- a/chrome/renderer/chrome_content_renderer_client.h
|
|
|
|
+++ b/chrome/renderer/chrome_content_renderer_client.h
|
2020-03-11 11:15:07 +00:00
|
|
|
@@ -126,6 +126,11 @@ class ChromeContentRendererClient
|
2020-02-06 07:05:30 +00:00
|
|
|
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 c4c0e27127ff2976db4e78cf5a02bd22d1c667d3..a4318511d1081d4f101cb2f18ca5fa200fb9773c 100644
|
|
|
|
--- a/content/public/renderer/content_renderer_client.cc
|
|
|
|
+++ b/content/public/renderer/content_renderer_client.cc
|
|
|
|
@@ -104,6 +104,14 @@ bool ContentRendererClient::HandleNavigation(
|
2019-10-28 22:12:35 +00:00
|
|
|
}
|
2020-02-06 07:05:30 +00:00
|
|
|
#endif
|
2019-10-28 22:12:35 +00:00
|
|
|
|
2020-02-06 07:05:30 +00:00
|
|
|
+bool ContentRendererClient::ShouldFork(blink::WebLocalFrame* frame,
|
|
|
|
+ const GURL& url,
|
|
|
|
+ const std::string& http_method,
|
|
|
|
+ bool is_initial_navigation,
|
|
|
|
+ bool is_server_redirect) {
|
|
|
|
+ return false;
|
2019-10-28 22:12:35 +00:00
|
|
|
+}
|
|
|
|
+
|
2020-02-06 07:05:30 +00:00
|
|
|
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
|
2020-03-11 11:15:07 +00:00
|
|
|
index ee2079537feb23869fe4f812bcef33e1d7de29a7..93287ae0928b52f9df34834ad1a8ef0e54367882 100644
|
2020-02-06 07:05:30 +00:00
|
|
|
--- a/content/public/renderer/content_renderer_client.h
|
|
|
|
+++ b/content/public/renderer/content_renderer_client.h
|
|
|
|
@@ -213,6 +213,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 |attach_same_site_cookies| output parameter
|
|
|
|
diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc
|
2020-03-14 20:54:14 +00:00
|
|
|
index 6c6265561512d1700b6b77a84ba127511a65483a..bb2603e365438d0369ba301c09082154333f1105 100644
|
2020-02-06 07:05:30 +00:00
|
|
|
--- a/content/renderer/render_frame_impl.cc
|
|
|
|
+++ b/content/renderer/render_frame_impl.cc
|
2020-03-14 20:54:14 +00:00
|
|
|
@@ -5662,6 +5662,23 @@ void RenderFrameImpl::BeginNavigation(
|
2020-02-06 07:05:30 +00:00
|
|
|
int cumulative_bindings = RenderProcess::current()->GetEnabledBindings();
|
|
|
|
bool should_fork = HasWebUIScheme(url) || HasWebUIScheme(old_url) ||
|
|
|
|
(cumulative_bindings & kWebUIBindingsPolicyMask);
|
2019-10-28 22:12:35 +00:00
|
|
|
+
|
2020-02-06 07:05:30 +00:00
|
|
|
+ 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);
|
|
|
|
+ }
|
2019-10-28 22:12:35 +00:00
|
|
|
+
|
2020-02-06 07:05:30 +00:00
|
|
|
+ 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 */);
|
|
|
|
+ }
|
2019-10-28 22:12:35 +00:00
|
|
|
+
|
2020-02-06 07:05:30 +00:00
|
|
|
if (should_fork) {
|
|
|
|
OpenURL(std::move(info));
|
|
|
|
return; // Suppress the load here.
|