diff options
author | pfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-26 15:16:36 +0000 |
---|---|---|
committer | pfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-26 15:16:36 +0000 |
commit | d6fbe2cb293d3d1358d5f38baa3a85ce1c3e1a66 (patch) | |
tree | 477cadaf3d8337e3252589a84d80818a3e28181e /chrome | |
parent | bf15ea15db6a0391be532f697e30a9e4b8ecb0f9 (diff) | |
download | chromium_src-d6fbe2cb293d3d1358d5f38baa3a85ce1c3e1a66.zip chromium_src-d6fbe2cb293d3d1358d5f38baa3a85ce1c3e1a66.tar.gz chromium_src-d6fbe2cb293d3d1358d5f38baa3a85ce1c3e1a66.tar.bz2 |
DevTools: support themes.
Review URL: http://codereview.chromium.org/1584016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45578 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rwxr-xr-x | chrome/browser/debugger/devtools_window.cc | 40 | ||||
-rwxr-xr-x | chrome/browser/debugger/devtools_window.h | 1 |
2 files changed, 38 insertions, 3 deletions
diff --git a/chrome/browser/debugger/devtools_window.cc b/chrome/browser/debugger/devtools_window.cc index 19abd19..719f4a0 100755 --- a/chrome/browser/debugger/devtools_window.cc +++ b/chrome/browser/debugger/devtools_window.cc @@ -7,6 +7,7 @@ #include "chrome/browser/browser.h" #include "chrome/browser/browser_list.h" #include "chrome/browser/browser_process.h" +#include "chrome/browser/browser_theme_provider.h" #include "chrome/browser/browser_window.h" #include "chrome/browser/debugger/devtools_manager.h" #include "chrome/browser/debugger/devtools_window.h" @@ -75,7 +76,8 @@ DevToolsWindow::DevToolsWindow(Profile* profile, registrar_.Add(this, NotificationType::TAB_CLOSING, Source<NavigationController>(&tab_contents_->controller())); - + registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, + NotificationService::AllSources()); inspected_tab_ = inspected_rvh->delegate()->GetAsTabContents(); } @@ -156,9 +158,8 @@ void DevToolsWindow::Activate() { } void DevToolsWindow::SetDocked(bool docked) { - if (docked_ == docked) { + if (docked_ == docked) return; - } if (docked && !GetInspectedBrowserWindow()) { // Cannot dock, avoid window flashing due to close-reopen cycle. return; @@ -180,6 +181,7 @@ void DevToolsWindow::SetDocked(bool docked) { inspected_window = NULL; } } + UpdateTheme(); Show(false); } @@ -242,6 +244,7 @@ void DevToolsWindow::Observe(NotificationType type, if (type == NotificationType::LOAD_STOP) { SetAttachedWindow(); is_loaded_ = true; + UpdateTheme(); if (open_console_on_load_) { DoOpenConsole(); open_console_on_load_ = false; @@ -256,6 +259,8 @@ void DevToolsWindow::Observe(NotificationType type, NotifyCloseListener(); delete this; } + } else if (type == NotificationType::BROWSER_THEME_CHANGED) { + UpdateTheme(); } } @@ -271,6 +276,35 @@ void DevToolsWindow::DoOpenConsole() { ExecuteJavascriptInWebFrame(L"", L"WebInspector.showConsole();"); } +std::string SkColorToRGBAString(SkColor color) { + // We convert the alpha using DoubleToString because StringPrintf will use + // locale specific formatters (e.g., use , instead of . in German). + return StringPrintf("rgba(%d,%d,%d,%s)", SkColorGetR(color), + SkColorGetG(color), SkColorGetB(color), + DoubleToString(SkColorGetA(color) / 255.0).c_str()); +} + +void DevToolsWindow::UpdateTheme() { + BrowserThemeProvider* tp = profile_->GetThemeProvider(); + CHECK(tp); + std::string command; + if (tp->GetThemeID() == BrowserThemeProvider::kDefaultThemeID || !docked_) { + command = "WebInspector.resetToolbarColors()"; + } else { + SkColor color_toolbar = + tp->GetColor(BrowserThemeProvider::COLOR_TOOLBAR); + SkColor color_tab_text = + tp->GetColor(BrowserThemeProvider::COLOR_BOOKMARK_TEXT); + + command = StringPrintf( + "WebInspector.setToolbarColors(\"%s\", \"%s\")", + SkColorToRGBAString(color_toolbar).c_str(), + SkColorToRGBAString(color_tab_text).c_str()); + } + tab_contents_->render_view_host()-> + ExecuteJavascriptInWebFrame(L"", UTF8ToWide(command)); +} + bool DevToolsWindow::PreHandleKeyboardEvent( const NativeWebKeyboardEvent& event, bool* is_keyboard_shortcut) { if (docked_) { diff --git a/chrome/browser/debugger/devtools_window.h b/chrome/browser/debugger/devtools_window.h index 997a1b4..f799639 100755 --- a/chrome/browser/debugger/devtools_window.h +++ b/chrome/browser/debugger/devtools_window.h @@ -61,6 +61,7 @@ class DevToolsWindow void ScheduleOpenConsole(); void DoOpenConsole(); + void UpdateTheme(); // Overridden from TabContentsDelegate. virtual void OpenURLFromTab(TabContents* source, |