Skip to content

Commit a5ed8fb

Browse files
trop[bot]codebytere
authored andcommitted
fix: ensure that reloads retain modified window background colors (electron#19973)
1 parent bb63189 commit a5ed8fb

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

atom/browser/api/atom_api_browser_window.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,16 @@ void BrowserWindow::SetBackgroundColor(const std::string& color_name) {
309309
auto* view = web_contents()->GetRenderWidgetHostView();
310310
if (view)
311311
view->SetBackgroundColor(ParseHexColor(color_name));
312+
// Also update the web preferences object otherwise the view will be reset on
313+
// the next load URL call
314+
if (api_web_contents_) {
315+
auto* web_preferences =
316+
WebContentsPreferences::From(api_web_contents_->web_contents());
317+
if (web_preferences) {
318+
web_preferences->preference()->SetStringKey(options::kBackgroundColor,
319+
color_name);
320+
}
321+
}
312322
}
313323

314324
void BrowserWindow::SetBrowserView(v8::Local<v8::Value> value) {

0 commit comments

Comments
 (0)