diff --git a/shell/browser/api/electron_api_browser_view.cc b/shell/browser/api/electron_api_browser_view.cc index 3cb2a6fa6a66..bc494baac03a 100644 --- a/shell/browser/api/electron_api_browser_view.cc +++ b/shell/browser/api/electron_api_browser_view.cc @@ -147,7 +147,11 @@ gfx::Rect BrowserView::GetBounds() { } void BrowserView::SetBackgroundColor(const std::string& color_name) { - view_->SetBackgroundColor(ParseHexColor(color_name)); + if (!web_contents()) + return; + + auto* wc = web_contents()->web_contents(); + wc->SetPageBaseBackgroundColor(ParseHexColor(color_name)); } v8::Local BrowserView::GetWebContents(v8::Isolate* isolate) { diff --git a/shell/browser/api/electron_api_web_contents.cc b/shell/browser/api/electron_api_web_contents.cc index bc1d5fa90165..324af7d25997 100644 --- a/shell/browser/api/electron_api_web_contents.cc +++ b/shell/browser/api/electron_api_web_contents.cc @@ -1457,8 +1457,9 @@ void WebContents::HandleNewRenderFrame( // Set the background color of RenderWidgetHostView. auto* web_preferences = WebContentsPreferences::From(web_contents()); if (web_preferences) { + bool guest = IsGuest() || type_ == Type::kBrowserView; absl::optional color = - IsGuest() ? SK_ColorTRANSPARENT : web_preferences->GetBackgroundColor(); + guest ? SK_ColorTRANSPARENT : web_preferences->GetBackgroundColor(); web_contents()->SetPageBaseBackgroundColor(color); rwhv->SetBackgroundColor(color.value_or(SK_ColorWHITE)); }