Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from Nov 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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')
MarshallOfSound marked this conversation as resolved.
Show resolved Hide resolved
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