diff options
author | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-28 16:54:09 +0000 |
---|---|---|
committer | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-28 16:54:09 +0000 |
commit | 0d158050b7b13840ca87efc9fb00bab327a736d9 (patch) | |
tree | fc705fa25c978351f04a3c740d81885a3dc46dad /chrome | |
parent | 756499cf199d964b055dc76e7b2f1edfbd53a4f0 (diff) | |
download | chromium_src-0d158050b7b13840ca87efc9fb00bab327a736d9.zip chromium_src-0d158050b7b13840ca87efc9fb00bab327a736d9.tar.gz chromium_src-0d158050b7b13840ca87efc9fb00bab327a736d9.tar.bz2 |
Extensions: Listen for BROWSER_THEME_CHANGED and send updated CSS.
GTK: Listen for BROWSER_THEME_CHANGED and upload proper colors.
BUG=23031
Review URL: http://codereview.chromium.org/248006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27368 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/extensions/extension_host.cc | 20 | ||||
-rw-r--r-- | chrome/browser/gtk/extension_shelf_gtk.cc | 26 |
2 files changed, 34 insertions, 12 deletions
diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc index ea19514..9a1baa6 100644 --- a/chrome/browser/extensions/extension_host.cc +++ b/chrome/browser/extensions/extension_host.cc @@ -135,9 +135,14 @@ void ExtensionHost::NavigateToURL(const GURL& url) { void ExtensionHost::Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { - DCHECK(type == NotificationType::EXTENSION_BACKGROUND_PAGE_READY); - DCHECK(extension_->GetBackgroundPageReady()); - NavigateToURL(url_); + if (type == NotificationType::EXTENSION_BACKGROUND_PAGE_READY) { + DCHECK(extension_->GetBackgroundPageReady()); + NavigateToURL(url_); + } else if (type == NotificationType::BROWSER_THEME_CHANGED) { + InsertThemeCSS(); + } else { + NOTREACHED(); + } } void ExtensionHost::UpdatePreferredWidth(int pref_width) { @@ -241,10 +246,15 @@ void ExtensionHost::DidStopLoading(RenderViewHost* render_view_host) { void ExtensionHost::DocumentAvailableInMainFrame(RenderViewHost* rvh) { document_element_available_ = true; - if (is_background_page()) + if (is_background_page()) { extension_->SetBackgroundPageReady(); - else + } else { InsertThemeCSS(); + + // Listen for browser changes so we can resend the CSS. + registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, + NotificationService::AllSources()); + } } void ExtensionHost::RunJavaScriptMessage(const std::wstring& message, diff --git a/chrome/browser/gtk/extension_shelf_gtk.cc b/chrome/browser/gtk/extension_shelf_gtk.cc index d16d2b2..d0d7916 100644 --- a/chrome/browser/gtk/extension_shelf_gtk.cc +++ b/chrome/browser/gtk/extension_shelf_gtk.cc @@ -15,9 +15,6 @@ #include "grit/generated_resources.h" #include "grit/theme_resources.h" -// Background color of the shelf. -static const GdkColor kBackgroundColor = GDK_COLOR_RGB(230, 237, 244); - // Border color (the top pixel of the shelf). const GdkColor kBorderColor = GDK_COLOR_RGB(214, 214, 214); @@ -168,6 +165,18 @@ void ExtensionShelfGtk::Observe(NotificationType type, } else { gtk_widget_modify_bg(top_border_, GTK_STATE_NORMAL, &kBorderColor); } + + GdkColor color = theme_provider_->GetGdkColor( + BrowserThemeProvider::COLOR_TOOLBAR); + gtk_widget_modify_bg(event_box_.get(), GTK_STATE_NORMAL, &color); + + // Reset the background images on all the individual toolstrips + background_.reset(); + InitBackground(); + for (std::set<Toolstrip*>::iterator it = toolstrips_.begin(); + it != toolstrips_.end(); ++it) { + (*it)->SetBackground(*background_.get()); + } } void ExtensionShelfGtk::Init(Profile* profile) { @@ -178,7 +187,6 @@ void ExtensionShelfGtk::Init(Profile* profile) { // widget. event_box_.Own(gtk_event_box_new()); ViewIDUtil::SetID(event_box_.get(), VIEW_ID_DEV_EXTENSION_SHELF); - gtk_widget_modify_bg(event_box_.get(), GTK_STATE_NORMAL, &kBackgroundColor); shelf_hbox_ = gtk_hbox_new(FALSE, 0); @@ -199,12 +207,16 @@ void ExtensionShelfGtk::Init(Profile* profile) { void ExtensionShelfGtk::InitBackground() { if (background_.get()) return; + + GdkColor color = + theme_provider_->GetGdkColor(BrowserThemeProvider::COLOR_TOOLBAR); + background_.reset(new SkBitmap); background_->setConfig(SkBitmap::kARGB_8888_Config, 3, 3); background_->allocPixels(); - background_->eraseRGB(kBackgroundColor.red >> 8, - kBackgroundColor.green >> 8, - kBackgroundColor.blue >> 8); + background_->eraseRGB(color.red >> 8, + color.green >> 8, + color.blue >> 8); } void ExtensionShelfGtk::AdjustHeight() { |