Skip to content

Commit

Permalink
chore: add deprecation warning for the default of allowRendererProces…
Browse files Browse the repository at this point in the history
…sReuse (#21287)

* chore: add deprecation warning for the default of allowRendererProcessReuse

* Update web-contents.js
  • Loading branch information
MarshallOfSound committed Nov 26, 2019
1 parent 5fdc24d commit 41e64d2
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 1 deletion.
2 changes: 2 additions & 0 deletions default_app/default_app.ts
Expand Up @@ -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()
Expand Down
6 changes: 6 additions & 0 deletions lib/browser/api/web-contents.js
Expand Up @@ -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)

Expand Down
7 changes: 6 additions & 1 deletion shell/browser/api/atom_api_app.cc
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions shell/browser/api/atom_api_app.h
Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions shell/browser/atom_browser_client.cc
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions shell/browser/atom_browser_client.h
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
};
Expand Down
2 changes: 2 additions & 0 deletions spec/fixtures/api/window-all-closed/main.js
@@ -1,4 +1,6 @@
const { app, BrowserWindow } = require('electron')
// Suppress deprecation logs
app.allowRendererProcessReuse = true

let handled = false

Expand Down

0 comments on commit 41e64d2

Please sign in to comment.