Browse Source

fix: enable spare renderer for site per process feature

deepak1556 1 year ago
parent
commit
a3aac40cb6

+ 14 - 0
shell/browser/electron_browser_client.cc

@@ -781,6 +781,20 @@ base::FilePath ElectronBrowserClient::GetLoggingFileName(
   return logging::GetLogFileName(cmd_line);
 }
 
+bool ElectronBrowserClient::ShouldUseSpareRenderProcessHost(
+    content::BrowserContext* browser_context,
+    const GURL& site_url) {
+#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
+  // Extensions should not use a spare process, because they require passing a
+  // command-line flag (switches::kExtensionProcess) to the renderer process
+  // when it launches. A spare process is launched earlier, before it is known
+  // which navigation will use it, so it lacks this flag.
+  return !site_url.SchemeIs(extensions::kExtensionScheme);
+#else
+  return true;
+#endif
+}
+
 std::unique_ptr<net::ClientCertStore>
 ElectronBrowserClient::CreateClientCertStore(
     content::BrowserContext* browser_context) {

+ 2 - 0
shell/browser/electron_browser_client.h

@@ -296,6 +296,8 @@ class ElectronBrowserClient : public content::ContentBrowserClient,
       const blink::StorageKey& storage_key,
       base::OnceCallback<void(bool, const std::string&)> callback) override;
   base::FilePath GetLoggingFileName(const base::CommandLine& cmd_line) override;
+  bool ShouldUseSpareRenderProcessHost(content::BrowserContext* browser_context,
+                                       const GURL& site_url) override;
 
   // content::RenderProcessHostObserver:
   void RenderProcessHostDestroyed(content::RenderProcessHost* host) override;

+ 0 - 7
shell/browser/feature_list.cc

@@ -30,13 +30,6 @@ void InitializeFeatureList() {
       cmd_line->GetSwitchValueASCII(::switches::kEnableFeatures);
   auto disable_features =
       cmd_line->GetSwitchValueASCII(::switches::kDisableFeatures);
-  // Disable creation of spare renderer process with site-per-process mode,
-  // it interferes with our process preference tracking for non sandboxed mode.
-  // Can be reenabled when our site instance policy is aligned with chromium
-  // when node integration is enabled.
-  disable_features +=
-      std::string(",") + features::kSpareRendererForSitePerProcess.name;
-
   // TODO(codebytere): Remove WebSQL support per crbug.com/695592.
   enable_features += std::string(",") + blink::features::kWebSQLAccess.name;