mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
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:
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
2
spec/fixtures/api/window-all-closed/main.js
vendored
2
spec/fixtures/api/window-all-closed/main.js
vendored
@@ -1,4 +1,6 @@
|
||||
const { app, BrowserWindow } = require('electron')
|
||||
// Suppress deprecation logs
|
||||
app.allowRendererProcessReuse = true
|
||||
|
||||
let handled = false
|
||||
|
||||
|
||||
Reference in New Issue
Block a user