| 
									
										
										
										
											2019-10-28 18:12:35 -04:00
										 |  |  | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | 
					
						
							| 
									
										
										
										
											2020-02-05 23:05:30 -08:00
										 |  |  | From: Shelley Vohr <shelley.vohr@gmail.com> | 
					
						
							|  |  |  | Date: Tue, 4 Feb 2020 08:59:32 -0700 | 
					
						
							| 
									
										
										
										
											2019-10-28 18:12:35 -04:00
										 |  |  | Subject: Revert "Remove ContentRendererClient::ShouldFork." | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-05 23:05:30 -08: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 18:12:35 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer/chrome_content_renderer_client.cc
 | 
					
						
							| 
									
										
										
										
											2021-03-04 09:27:05 -08:00
										 |  |  | index 092cb7aa6b5d1e2b516569eae8b9dabed6661dfc..963196951c0dce346220c11287ceeab32fec2e32 100644
 | 
					
						
							| 
									
										
										
										
											2019-10-28 18:12:35 -04:00
										 |  |  | --- a/chrome/renderer/chrome_content_renderer_client.cc
 | 
					
						
							|  |  |  | +++ b/chrome/renderer/chrome_content_renderer_client.cc
 | 
					
						
							| 
									
										
										
										
											2021-03-04 09:27:05 -08:00
										 |  |  | @@ -1266,6 +1266,25 @@ ChromeContentRendererClient::GetProtocolHandlerSecurityLevel() {
 | 
					
						
							| 
									
										
										
										
											2020-02-05 23:05:30 -08:00
										 |  |  |  #endif | 
					
						
							|  |  |  |  } | 
					
						
							| 
									
										
										
										
											2019-10-28 18:12:35 -04:00
										 |  |  |   | 
					
						
							| 
									
										
										
										
											2020-02-05 23:05:30 -08: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 18:12:35 -04: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-05 23:05:30 -08: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
 | 
					
						
							| 
									
										
										
										
											2021-01-25 08:46:00 -08:00
										 |  |  | index 30718f6b057fcca8eef7516cb48720c4137c3cb4..7a1f4ad8e73cf141ac7c60a9aced2b81cbc61812 100644
 | 
					
						
							| 
									
										
										
										
											2020-02-05 23:05:30 -08:00
										 |  |  | --- a/chrome/renderer/chrome_content_renderer_client.h
 | 
					
						
							|  |  |  | +++ b/chrome/renderer/chrome_content_renderer_client.h
 | 
					
						
							| 
									
										
										
										
											2020-10-27 17:33:04 -07:00
										 |  |  | @@ -122,6 +122,11 @@ class ChromeContentRendererClient
 | 
					
						
							| 
									
										
										
										
											2020-02-05 23:05:30 -08:00
										 |  |  |        base::SingleThreadTaskRunner* compositor_thread_task_runner) override; | 
					
						
							|  |  |  |    bool RunIdleHandlerWhenWidgetsHidden() override; | 
					
						
							|  |  |  |    bool AllowPopup() override; | 
					
						
							|  |  |  | +  bool ShouldFork(blink::WebLocalFrame* frame,
 | 
					
						
							| 
									
										
										
										
											2020-11-13 16:16:56 -08:00
										 |  |  | +                  const GURL& url,
 | 
					
						
							|  |  |  | +                  const std::string& http_method,
 | 
					
						
							|  |  |  | +                  bool is_initial_navigation,
 | 
					
						
							|  |  |  | +                  bool is_server_redirect) override;
 | 
					
						
							|  |  |  |    blink::ProtocolHandlerSecurityLevel GetProtocolHandlerSecurityLevel() | 
					
						
							|  |  |  |        override; | 
					
						
							| 
									
										
										
										
											2020-02-05 23:05:30 -08:00
										 |  |  |    void WillSendRequest(blink::WebLocalFrame* frame, | 
					
						
							|  |  |  | diff --git a/content/public/renderer/content_renderer_client.cc b/content/public/renderer/content_renderer_client.cc
 | 
					
						
							| 
									
										
										
										
											2021-01-25 08:46:00 -08:00
										 |  |  | index 18e13633bc5f2be2830f6c10f4a46783c57720d4..e9123e07996f511e66ce23e28bcfc2f8ecedd6c5 100644
 | 
					
						
							| 
									
										
										
										
											2020-02-05 23:05:30 -08:00
										 |  |  | --- a/content/public/renderer/content_renderer_client.cc
 | 
					
						
							|  |  |  | +++ b/content/public/renderer/content_renderer_client.cc
 | 
					
						
							| 
									
										
										
										
											2020-12-22 14:14:44 -08:00
										 |  |  | @@ -117,6 +117,14 @@ bool ContentRendererClient::HandleNavigation(
 | 
					
						
							| 
									
										
										
										
											2019-10-28 18:12:35 -04:00
										 |  |  |  } | 
					
						
							| 
									
										
										
										
											2020-02-05 23:05:30 -08:00
										 |  |  |  #endif | 
					
						
							| 
									
										
										
										
											2019-10-28 18:12:35 -04:00
										 |  |  |   | 
					
						
							| 
									
										
										
										
											2020-02-05 23:05:30 -08: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 18:12:35 -04:00
										 |  |  | +}
 | 
					
						
							|  |  |  | +
 | 
					
						
							| 
									
										
										
										
											2020-02-05 23:05:30 -08: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
 | 
					
						
							| 
									
										
										
										
											2021-01-25 08:46:00 -08:00
										 |  |  | index 357df68c64071ef7dca98ce4aab885dd936b1c49..f501a2ab0bd6d4664dad13913671c4d7d5a96c1e 100644
 | 
					
						
							| 
									
										
										
										
											2020-02-05 23:05:30 -08:00
										 |  |  | --- a/content/public/renderer/content_renderer_client.h
 | 
					
						
							|  |  |  | +++ b/content/public/renderer/content_renderer_client.h
 | 
					
						
							| 
									
										
										
										
											2020-10-27 17:33:04 -07:00
										 |  |  | @@ -210,6 +210,13 @@ class CONTENT_EXPORT ContentRendererClient {
 | 
					
						
							| 
									
										
										
										
											2020-02-05 23:05:30 -08:00
										 |  |  |                                  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 | 
					
						
							| 
									
										
										
										
											2020-12-14 10:57:36 -08:00
										 |  |  |    // updated to use it. | 
					
						
							| 
									
										
										
										
											2020-02-05 23:05:30 -08:00
										 |  |  | diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc
 | 
					
						
							| 
									
										
										
										
											2021-03-04 09:27:05 -08:00
										 |  |  | index 49b0d9012c43661a4fb4b9b8b8a68c156c7a76b6..db038990188455fc645c3c769a71e01af1ad3f0b 100644
 | 
					
						
							| 
									
										
										
										
											2020-02-05 23:05:30 -08:00
										 |  |  | --- a/content/renderer/render_frame_impl.cc
 | 
					
						
							|  |  |  | +++ b/content/renderer/render_frame_impl.cc
 | 
					
						
							| 
									
										
										
										
											2021-03-04 09:27:05 -08:00
										 |  |  | @@ -5313,6 +5313,23 @@ void RenderFrameImpl::BeginNavigation(
 | 
					
						
							| 
									
										
										
										
											2020-04-23 18:55:17 -07:00
										 |  |  |      // we can do a per-frame check here rather than a process-wide check. | 
					
						
							| 
									
										
										
										
											2020-02-05 23:05:30 -08:00
										 |  |  |      bool should_fork = HasWebUIScheme(url) || HasWebUIScheme(old_url) || | 
					
						
							| 
									
										
										
										
											2020-04-23 18:55:17 -07:00
										 |  |  |                         (enabled_bindings_ & kWebUIBindingsPolicyMask); | 
					
						
							| 
									
										
										
										
											2019-10-28 18:12:35 -04:00
										 |  |  | +
 | 
					
						
							| 
									
										
										
										
											2020-02-05 23:05:30 -08: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 18:12:35 -04:00
										 |  |  | +
 | 
					
						
							| 
									
										
										
										
											2020-02-05 23:05:30 -08: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 18:12:35 -04:00
										 |  |  | +
 | 
					
						
							| 
									
										
										
										
											2020-02-05 23:05:30 -08:00
										 |  |  |      if (should_fork) { | 
					
						
							|  |  |  |        OpenURL(std::move(info)); | 
					
						
							|  |  |  |        return;  // Suppress the load here. |