diff --git a/include/internal/cef_types.h b/include/internal/cef_types.h index e2b67de04..1df930179 100644 --- a/include/internal/cef_types.h +++ b/include/internal/cef_types.h @@ -559,6 +559,15 @@ typedef struct _cef_browser_settings_t { // "disable-accelerated-compositing" command-line switch. /// cef_state_t accelerated_compositing; + + /// + // Opaque background color used for the browser before a document is loaded + // and when no document color is specified. By default the background color + // will be the same as CefSettings.background_color. Only the RGB compontents + // of the specified value will be used. The alpha component must greater than + // 0 to enable use of the background color but will be otherwise ignored. + /// + cef_color_t background_color; } cef_browser_settings_t; /// diff --git a/include/internal/cef_types_wrappers.h b/include/internal/cef_types_wrappers.h index 3e7af2342..53296bd23 100644 --- a/include/internal/cef_types_wrappers.h +++ b/include/internal/cef_types_wrappers.h @@ -451,6 +451,8 @@ struct CefBrowserSettingsTraits { target->application_cache = src->application_cache; target->webgl = src->webgl; target->accelerated_compositing = src->accelerated_compositing; + + target->background_color = src->background_color; } }; diff --git a/libcef/browser/browser_settings.cc b/libcef/browser/browser_settings.cc index 0e9919457..d52658296 100644 --- a/libcef/browser/browser_settings.cc +++ b/libcef/browser/browser_settings.cc @@ -6,7 +6,6 @@ #include -#include "libcef/browser/context.h" #include "libcef/common/cef_switches.h" #include "base/command_line.h" @@ -127,6 +126,4 @@ void BrowserToWebSettings(const CefBrowserSettings& cef, WebPreferences& web) { web.experimental_webgl_enabled = false; if (cef.accelerated_compositing == STATE_DISABLED) web.accelerated_compositing_enabled = false; - - web.base_background_color = CefContext::Get()->settings().background_color; } diff --git a/libcef/browser/content_browser_client.cc b/libcef/browser/content_browser_client.cc index 2e67f8d3d..83e915e03 100644 --- a/libcef/browser/content_browser_client.cc +++ b/libcef/browser/content_browser_client.cc @@ -14,6 +14,7 @@ #include "libcef/browser/browser_message_filter.h" #include "libcef/browser/browser_settings.h" #include "libcef/browser/chrome_scheme_handler.h" +#include "libcef/browser/context.h" #include "libcef/browser/media_capture_devices_dispatcher.h" #include "libcef/browser/printing/printing_message_filter.h" #include "libcef/browser/resource_dispatcher_host_delegate.h" @@ -43,6 +44,7 @@ #include "third_party/WebKit/public/web/WebWindowFeatures.h" #include "ui/base/ui_base_switches.h" #include "url/gurl.h" +#include "webkit/common/webpreferences.h" #if defined(OS_POSIX) && !defined(OS_MACOSX) #include "base/debug/leak_annotations.h" @@ -863,6 +865,33 @@ void CefContentBrowserClient::OverrideWebkitPrefs( // Populate WebPreferences based on CefBrowserSettings. BrowserToWebSettings(browser->settings(), *prefs); + + prefs->base_background_color = GetBaseBackgroundColor(rvh); +} + +SkColor CefContentBrowserClient::GetBaseBackgroundColor( + content::RenderViewHost* rvh) { + CefRefPtr browser = + CefBrowserHostImpl::GetBrowserForHost(rvh); + DCHECK(browser.get()); + + const CefBrowserSettings& browser_settings = browser->settings(); + if (CefColorGetA(browser_settings.background_color) > 0) { + return SkColorSetRGB( + CefColorGetR(browser_settings.background_color), + CefColorGetG(browser_settings.background_color), + CefColorGetB(browser_settings.background_color)); + } else { + const CefSettings& settings = CefContext::Get()->settings(); + if (CefColorGetA(settings.background_color) > 0) { + return SkColorSetRGB( + CefColorGetR(settings.background_color), + CefColorGetG(settings.background_color), + CefColorGetB(settings.background_color)); + } + } + + return SK_ColorWHITE; } void CefContentBrowserClient::BrowserURLHandlerCreated( diff --git a/libcef/browser/content_browser_client.h b/libcef/browser/content_browser_client.h index 0ee555533..0d7901b59 100644 --- a/libcef/browser/content_browser_client.h +++ b/libcef/browser/content_browser_client.h @@ -135,6 +135,7 @@ class CefContentBrowserClient : public content::ContentBrowserClient { virtual void OverrideWebkitPrefs(content::RenderViewHost* rvh, const GURL& url, WebPreferences* prefs) OVERRIDE; + virtual SkColor GetBaseBackgroundColor(content::RenderViewHost* rvh) OVERRIDE; virtual void BrowserURLHandlerCreated( content::BrowserURLHandler* handler) OVERRIDE; virtual std::string GetDefaultDownloadName() OVERRIDE; diff --git a/libcef/browser/devtools_frontend.cc b/libcef/browser/devtools_frontend.cc index e0c753c34..99805392c 100644 --- a/libcef/browser/devtools_frontend.cc +++ b/libcef/browser/devtools_frontend.cc @@ -19,6 +19,7 @@ #include "content/public/browser/web_contents_view.h" #include "content/public/common/content_client.h" #include "net/base/net_util.h" +#include "third_party/skia/include/core/SkColor.h" // static CefDevToolsFrontend* CefDevToolsFrontend::Show( @@ -26,9 +27,16 @@ CefDevToolsFrontend* CefDevToolsFrontend::Show( const CefWindowInfo& windowInfo, CefRefPtr client, const CefBrowserSettings& settings) { + CefBrowserSettings new_settings = settings; + if (CefColorGetA(new_settings.background_color) == 0) { + // Use white as the default background color for DevTools instead of the + // CefSettings.background_color value. + new_settings.background_color = SK_ColorWHITE; + } + CefRefPtr frontend_browser = CefBrowserHostImpl::Create(windowInfo, client, CefString(), - settings, + new_settings, inspected_browser->GetWindowHandle(), true, inspected_browser->GetRequestContext()); diff --git a/patch/patch.cfg b/patch/patch.cfg index 16e0622d2..283871650 100644 --- a/patch/patch.cfg +++ b/patch/patch.cfg @@ -72,6 +72,12 @@ patches = [ 'name': 'renderer_host_1161', 'path': '../content/browser/renderer_host/', }, + { + # Allow customization of the background color with Aura. + # http://code.google.com/p/chromiumembedded/issues/detail?id=1161 + 'name': 'public_browser_1161', + 'path': '../content/public/browser/', + }, { # Allow customization of the WebView background color. # http://code.google.com/p/chromiumembedded/issues/detail?id=1161 diff --git a/patch/patches/prefs_webkit_1161.patch b/patch/patches/prefs_webkit_1161.patch index bc71621f8..b0620597b 100644 --- a/patch/patches/prefs_webkit_1161.patch +++ b/patch/patches/prefs_webkit_1161.patch @@ -18,7 +18,7 @@ Index: common/webpreferences.h bool use_solid_color_scrollbars; bool compositor_touch_hit_testing; bool navigate_on_drag_drop; -+ int base_background_color; ++ uint32_t base_background_color; // This flags corresponds to a Page's Settings' setCookieEnabled state. It // only controls whether or not the "document.cookie" field is properly diff --git a/patch/patches/public_browser_1161.patch b/patch/patches/public_browser_1161.patch new file mode 100644 index 000000000..c151d40e7 --- /dev/null +++ b/patch/patches/public_browser_1161.patch @@ -0,0 +1,37 @@ +Index: content_browser_client.cc +=================================================================== +--- content_browser_client.cc (revision 261035) ++++ content_browser_client.cc (working copy) +@@ -255,6 +255,10 @@ + return true; + } + ++SkColor ContentBrowserClient::GetBaseBackgroundColor(RenderViewHost* rvh) { ++ return SK_ColorWHITE; ++} ++ + base::FilePath ContentBrowserClient::GetDefaultDownloadDirectory() { + return base::FilePath(); + } +Index: content_browser_client.h +=================================================================== +--- content_browser_client.h (revision 261035) ++++ content_browser_client.h (working copy) +@@ -22,6 +22,7 @@ + #include "net/base/mime_util.h" + #include "net/cookies/canonical_cookie.h" + #include "net/url_request/url_request_job_factory.h" ++#include "third_party/skia/include/core/SkColor.h" + #include "third_party/WebKit/public/web/WebNotificationPresenter.h" + #include "ui/base/window_open_disposition.h" + #include "webkit/browser/fileapi/file_system_context.h" +@@ -542,6 +543,9 @@ + // Clears browser cookies. + virtual void ClearCookies(RenderViewHost* rvh) {} + ++ // Returns the base background color. ++ virtual SkColor GetBaseBackgroundColor(RenderViewHost* rvh); ++ + // Returns the default download directory. + // This can be called on any thread. + virtual base::FilePath GetDefaultDownloadDirectory(); diff --git a/patch/patches/renderer_host_1161.patch b/patch/patches/renderer_host_1161.patch index 0473c6067..e3773a90e 100644 --- a/patch/patches/renderer_host_1161.patch +++ b/patch/patches/renderer_host_1161.patch @@ -93,12 +93,16 @@ Index: render_widget_host_view_aura.cc =================================================================== --- render_widget_host_view_aura.cc (revision 261035) +++ render_widget_host_view_aura.cc (working copy) -@@ -2686,7 +2686,7 @@ +@@ -2685,8 +2685,10 @@ + // For non-opaque windows, we don't draw anything, since we depend on the // canvas coming from the compositor to already be initialized as // transparent. - if (window_->layer()->fills_bounds_opaquely()) +- if (window_->layer()->fills_bounds_opaquely()) - canvas->DrawColor(SK_ColorWHITE); -+ canvas->DrawColor(SK_ColorTRANSPARENT); ++ if (window_->layer()->fills_bounds_opaquely()) { ++ canvas->DrawColor(GetContentClient()->browser()->GetBaseBackgroundColor( ++ RenderViewHost::From(host_))); ++ } } }