From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samuel Attard <sattard@slack-corp.com>
Date: Mon, 8 Mar 2021 16:27:39 -0800
Subject: moves background_color setter of WebView to blinks webprefs logic

background_color can be updated at runtime, as such we need to apply the
new background color to the WebView in the ApplyPreferences method.
There is no current way to attach an observer to these prefs so patching
is our only option.

Ideally we could add an embedder observer pattern here but that can be
done in future work.

diff --git a/third_party/blink/renderer/core/exported/web_view_impl.cc b/third_party/blink/renderer/core/exported/web_view_impl.cc
index 2e3c4a5b2d583fe8a19afbbc33a83daa74d90b18..3aec314cd0d603c14b7de59f20f938910c7931f5 100644
--- a/third_party/blink/renderer/core/exported/web_view_impl.cc
+++ b/third_party/blink/renderer/core/exported/web_view_impl.cc
@@ -154,6 +154,7 @@
 #include "third_party/blink/renderer/core/timing/dom_window_performance.h"
 #include "third_party/blink/renderer/core/timing/window_performance.h"
 #include "third_party/blink/renderer/platform/fonts/font_cache.h"
+#include "third_party/blink/renderer/platform/graphics/color.h"
 #include "third_party/blink/renderer/platform/graphics/image.h"
 #include "third_party/blink/renderer/platform/graphics/paint/cull_rect.h"
 #include "third_party/blink/renderer/platform/graphics/paint/paint_record_builder.h"
@@ -1752,6 +1753,14 @@ void WebView::ApplyWebPreferences(const web_pref::WebPreferences& prefs,
 
   RuntimeEnabledFeatures::SetTranslateServiceEnabled(
       prefs.translate_service_available);
+
+  SkColor color = SK_ColorTRANSPARENT;
+  if (!prefs.guest_instance_id) {  // not inside electron <webview /> tag, which is always transparent.
+    Color blink_color;
+    if (blink_color.SetFromString(WebString::FromASCII(prefs.background_color)))
+      color = static_cast<SkColor>(blink_color);
+  }
+  web_view->SetBaseBackgroundColor(color);
 }
 
 void WebViewImpl::ThemeChanged() {
