chore: add deprecation warning for the default of allowRendererProcessReuse (#21287)

* chore: add deprecation warning for the default of allowRendererProcessReuse

* Update web-contents.js
This commit is contained in:
Samuel Attard
2019-11-26 15:48:35 -08:00
committed by GitHub
parent 5fdc24d3bf
commit 41e64d2469
7 changed files with 24 additions and 1 deletions

View File

@@ -3,6 +3,8 @@ import * as path from 'path'
let mainWindow: BrowserWindow | null = null
app.allowRendererProcessReuse = true
// Quit when all windows are closed.
app.on('window-all-closed', () => {
app.quit()

View File

@@ -318,8 +318,14 @@ const addReturnValueToEvent = (event) => {
})
}
let warnedAboutRendererProcessReuse = false
// Add JavaScript wrappers for WebContents class.
WebContents.prototype._init = function () {
if (!process.noDeprecation && !warnedAboutRendererProcessReuse && app._allowRendererProcessReuseIsDefaultValue) {
deprecate.log('The default value of app.allowRendererProcessReuse is deprecated, it is currently "false". It will change to be "true" in Electron 9. For more information please check https://github.com/electron/electron/issues/18397')
warnedAboutRendererProcessReuse = true
}
// The navigation controller.
NavigationController.call(this, this)

View File

@@ -1326,6 +1326,9 @@ void App::SetBrowserClientCanUseCustomSiteInstance(bool should_disable) {
bool App::CanBrowserClientUseCustomSiteInstance() {
return AtomBrowserClient::Get()->CanUseCustomSiteInstance();
}
bool App::CanBrowserClientUseCustomSiteInstanceIsDefaultValue() {
return AtomBrowserClient::Get()->CanUseCustomSiteInstanceIsDefaultValue();
}
#if defined(OS_MACOSX)
bool App::MoveToApplicationsFolder(gin_helper::ErrorThrower thrower,
@@ -1518,7 +1521,9 @@ void App::BuildPrototype(v8::Isolate* isolate,
.SetMethod("enableSandbox", &App::EnableSandbox)
.SetProperty("allowRendererProcessReuse",
&App::CanBrowserClientUseCustomSiteInstance,
&App::SetBrowserClientCanUseCustomSiteInstance);
&App::SetBrowserClientCanUseCustomSiteInstance)
.SetProperty("_allowRendererProcessReuseIsDefaultValue",
&App::CanBrowserClientUseCustomSiteInstanceIsDefaultValue);
}
} // namespace api

View File

@@ -203,6 +203,7 @@ class App : public AtomBrowserClient::Delegate,
std::string GetUserAgentFallback();
void SetBrowserClientCanUseCustomSiteInstance(bool should_disable);
bool CanBrowserClientUseCustomSiteInstance();
bool CanBrowserClientUseCustomSiteInstanceIsDefaultValue();
#if defined(OS_MACOSX)
bool MoveToApplicationsFolder(gin_helper::ErrorThrower,

View File

@@ -422,12 +422,17 @@ void AtomBrowserClient::OverrideWebkitPrefs(content::RenderViewHost* host,
void AtomBrowserClient::SetCanUseCustomSiteInstance(bool should_disable) {
disable_process_restart_tricks_ = should_disable;
disable_process_restart_tricks_is_default_value_ = false;
}
bool AtomBrowserClient::CanUseCustomSiteInstance() {
return disable_process_restart_tricks_;
}
bool AtomBrowserClient::CanUseCustomSiteInstanceIsDefaultValue() {
return disable_process_restart_tricks_is_default_value_;
}
content::ContentBrowserClient::SiteInstanceForNavigationType
AtomBrowserClient::ShouldOverrideSiteInstanceForNavigation(
content::RenderFrameHost* current_rfh,

View File

@@ -73,6 +73,7 @@ class AtomBrowserClient : public content::ContentBrowserClient,
void SetCanUseCustomSiteInstance(bool should_disable);
bool CanUseCustomSiteInstance() override;
bool CanUseCustomSiteInstanceIsDefaultValue();
protected:
void RenderProcessWillLaunch(content::RenderProcessHost* host) override;
@@ -283,6 +284,7 @@ class AtomBrowserClient : public content::ContentBrowserClient,
std::string user_agent_override_ = "";
bool disable_process_restart_tricks_ = false;
bool disable_process_restart_tricks_is_default_value_ = true;
DISALLOW_COPY_AND_ASSIGN(AtomBrowserClient);
};

View File

@@ -1,4 +1,6 @@
const { app, BrowserWindow } = require('electron')
// Suppress deprecation logs
app.allowRendererProcessReuse = true
let handled = false