mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Add CefBrowserSettings.background_color for custom background color assignment on a per-browser basis and fix assignment of the default value (issue #1161).
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1656 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
@@ -6,7 +6,6 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#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;
|
||||
}
|
||||
|
@@ -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<CefBrowserHostImpl> 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(
|
||||
|
@@ -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;
|
||||
|
@@ -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<CefClient> 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<CefBrowserHostImpl> frontend_browser =
|
||||
CefBrowserHostImpl::Create(windowInfo, client, CefString(),
|
||||
settings,
|
||||
new_settings,
|
||||
inspected_browser->GetWindowHandle(), true,
|
||||
inspected_browser->GetRequestContext());
|
||||
|
||||
|
Reference in New Issue
Block a user