diff options
160 files changed, 2023 insertions, 2051 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc index 390276e..9fba5cb 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc +++ b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc @@ -47,7 +47,7 @@ #include "views/events/event.h" #else #include "chrome/browser/autocomplete/autocomplete_popup_view_gtk.h" -#include "chrome/browser/ui/gtk/gtk_theme_provider.h" +#include "chrome/browser/ui/gtk/gtk_theme_service.h" #include "chrome/browser/ui/gtk/location_bar_view_gtk.h" #endif @@ -186,7 +186,7 @@ AutocompleteEditViewGtk::AutocompleteEditViewGtk( #if defined(TOOLKIT_VIEWS) location_bar_view_(location_bar), #else - theme_provider_(GtkThemeProvider::GetFrom(profile)), + theme_service_(GtkThemeService::GetFrom(profile)), #endif enter_was_pressed_(false), tab_was_pressed_(false), @@ -411,7 +411,7 @@ void AutocompleteEditViewGtk::Init() { registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, NotificationService::AllSources()); - theme_provider_->InitThemesFor(this); + theme_service_->InitThemesFor(this); #else // Manually invoke SetBaseColor() because TOOLKIT_VIEWS doesn't observe // themes. @@ -943,7 +943,7 @@ void AutocompleteEditViewGtk::SetBaseColor() { #if defined(TOOLKIT_VIEWS) bool use_gtk = false; #else - bool use_gtk = theme_provider_->UseGtkTheme(); + bool use_gtk = theme_service_->UseGtkTheme(); #endif if (use_gtk) { gtk_widget_modify_cursor(text_view_, NULL, NULL); @@ -986,19 +986,19 @@ void AutocompleteEditViewGtk::SetBaseColor() { // Override the selected colors so we don't leak colors from the current // gtk theme into the chrome-theme. c = gfx::SkColorToGdkColor( - theme_provider_->get_active_selection_bg_color()); + theme_service_->get_active_selection_bg_color()); gtk_widget_modify_base(text_view_, GTK_STATE_SELECTED, &c); c = gfx::SkColorToGdkColor( - theme_provider_->get_active_selection_fg_color()); + theme_service_->get_active_selection_fg_color()); gtk_widget_modify_text(text_view_, GTK_STATE_SELECTED, &c); c = gfx::SkColorToGdkColor( - theme_provider_->get_inactive_selection_bg_color()); + theme_service_->get_inactive_selection_bg_color()); gtk_widget_modify_base(text_view_, GTK_STATE_ACTIVE, &c); c = gfx::SkColorToGdkColor( - theme_provider_->get_inactive_selection_fg_color()); + theme_service_->get_inactive_selection_fg_color()); gtk_widget_modify_text(text_view_, GTK_STATE_ACTIVE, &c); #endif @@ -1021,7 +1021,7 @@ void AutocompleteEditViewGtk::UpdateInstantViewColors() { #if defined(TOOLKIT_VIEWS) bool use_gtk = false; #else - bool use_gtk = theme_provider_->UseGtkTheme(); + bool use_gtk = theme_service_->UseGtkTheme(); #endif if (use_gtk) { @@ -1048,9 +1048,9 @@ void AutocompleteEditViewGtk::UpdateInstantViewColors() { #else normal_bg = LocationBarViewGtk::kBackgroundColor; selection_text = - theme_provider_->get_active_selection_fg_color(); + theme_service_->get_active_selection_fg_color(); selection_bg = - theme_provider_->get_active_selection_bg_color(); + theme_service_->get_active_selection_bg_color(); #endif } @@ -1777,7 +1777,7 @@ gfx::Font AutocompleteEditViewGtk::GetFont() { #if defined(TOOLKIT_VIEWS) bool use_gtk = false; #else - bool use_gtk = theme_provider_->UseGtkTheme(); + bool use_gtk = theme_service_->UseGtkTheme(); #endif if (use_gtk) { diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.h b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.h index 60d83c3..8681b18 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.h +++ b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.h @@ -45,7 +45,7 @@ class View; } #if !defined(TOOLKIT_VIEWS) -class GtkThemeProvider; +class GtkThemeService; #endif class AutocompleteEditViewGtk : public AutocompleteEditView, @@ -465,7 +465,7 @@ class AutocompleteEditViewGtk : public AutocompleteEditView, views::View* location_bar_view_; #else // Supplies colors, et cetera. - GtkThemeProvider* theme_provider_; + GtkThemeService* theme_service_; NotificationRegistrar registrar_; #endif diff --git a/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc b/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc index 037d970..7d4c884 100644 --- a/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc +++ b/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc @@ -23,7 +23,7 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/search_engines/template_url.h" #include "chrome/browser/search_engines/template_url_model.h" -#include "chrome/browser/ui/gtk/gtk_theme_provider.h" +#include "chrome/browser/ui/gtk/gtk_theme_service.h" #include "chrome/browser/ui/gtk/gtk_util.h" #include "content/common/notification_service.h" #include "grit/theme_resources.h" @@ -276,7 +276,7 @@ AutocompletePopupViewGtk::AutocompletePopupViewGtk( location_bar_(location_bar), window_(gtk_window_new(GTK_WINDOW_POPUP)), layout_(NULL), - theme_provider_(GtkThemeProvider::GetFrom(profile)), + theme_service_(GtkThemeService::GetFrom(profile)), font_(font.DeriveFont(kEditFontAdjust)), ignore_mouse_drag_(false), opened_(false) { @@ -313,7 +313,7 @@ AutocompletePopupViewGtk::AutocompletePopupViewGtk( registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, NotificationService::AllSources()); - theme_provider_->InitThemesFor(this); + theme_service_->InitThemesFor(this); // TODO(erg): There appears to be a bug somewhere in something which shows // itself when we're in NX. Previously, we called @@ -393,10 +393,10 @@ void AutocompletePopupViewGtk::Observe(NotificationType type, const NotificationDetails& details) { DCHECK(type == NotificationType::BROWSER_THEME_CHANGED); - if (theme_provider_->UseGtkTheme()) { + if (theme_service_->UseGtkTheme()) { gtk_util::UndoForceFontSize(window_); - border_color_ = theme_provider_->GetBorderColor(); + border_color_ = theme_service_->GetBorderColor(); gtk_util::GetTextColors( &background_color_, &selected_background_color_, @@ -504,7 +504,7 @@ GdkPixbuf* AutocompletePopupViewGtk::IconForMatch( } // TODO(estade): Do we want to flip these for RTL? (Windows doesn't). - return theme_provider_->GetPixbufNamed(icon); + return theme_service_->GetPixbufNamed(icon); } gboolean AutocompletePopupViewGtk::HandleMotion(GtkWidget* widget, diff --git a/chrome/browser/autocomplete/autocomplete_popup_view_gtk.h b/chrome/browser/autocomplete/autocomplete_popup_view_gtk.h index 16fbc93..6597e9c 100644 --- a/chrome/browser/autocomplete/autocomplete_popup_view_gtk.h +++ b/chrome/browser/autocomplete/autocomplete_popup_view_gtk.h @@ -22,7 +22,7 @@ class AutocompleteEditModel; class AutocompleteEditView; class AutocompletePopupModel; -class GtkThemeProvider; +class GtkThemeService; class Profile; class SkBitmap; @@ -115,7 +115,7 @@ class AutocompletePopupViewGtk : public AutocompletePopupView, // The pango layout object created from the window, cached across exposes. PangoLayout* layout_; - GtkThemeProvider* theme_provider_; + GtkThemeService* theme_service_; NotificationRegistrar registrar_; // Font used for suggestions after being derived from the constructor's diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc index 81c0294..1e64656 100644 --- a/chrome/browser/automation/testing_automation_provider.cc +++ b/chrome/browser/automation/testing_automation_provider.cc @@ -59,8 +59,8 @@ #include "chrome/browser/search_engines/template_url_model.h" #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" #include "chrome/browser/tab_contents/link_infobar_delegate.h" -#include "chrome/browser/themes/browser_theme_provider.h" #include "chrome/browser/themes/theme_service.h" +#include "chrome/browser/themes/theme_service_factory.h" #include "chrome/browser/translate/translate_infobar_delegate.h" #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" diff --git a/chrome/browser/debugger/devtools_window.cc b/chrome/browser/debugger/devtools_window.cc index 0cabc18..345fadc 100644 --- a/chrome/browser/debugger/devtools_window.cc +++ b/chrome/browser/debugger/devtools_window.cc @@ -17,8 +17,8 @@ #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/tabs/tab_strip_model.h" -#include "chrome/browser/themes/browser_theme_provider.h" #include "chrome/browser/themes/theme_service.h" +#include "chrome/browser/themes/theme_service_factory.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/common/bindings_policy.h" @@ -378,13 +378,13 @@ std::string SkColorToRGBAString(SkColor color) { } GURL DevToolsWindow::GetDevToolsUrl() { - BrowserThemeProvider* tp = ThemeServiceFactory::GetForProfile(profile_); + ThemeService* tp = ThemeServiceFactory::GetForProfile(profile_); CHECK(tp); SkColor color_toolbar = - tp->GetColor(BrowserThemeProvider::COLOR_TOOLBAR); + tp->GetColor(ThemeService::COLOR_TOOLBAR); SkColor color_tab_text = - tp->GetColor(BrowserThemeProvider::COLOR_BOOKMARK_TEXT); + tp->GetColor(ThemeService::COLOR_BOOKMARK_TEXT); std::string url_string = StringPrintf( "%sdevtools.html?docked=%s&toolbar_color=%s&text_color=%s", @@ -396,13 +396,13 @@ GURL DevToolsWindow::GetDevToolsUrl() { } void DevToolsWindow::UpdateTheme() { - BrowserThemeProvider* tp = ThemeServiceFactory::GetForProfile(profile_); + ThemeService* tp = ThemeServiceFactory::GetForProfile(profile_); CHECK(tp); SkColor color_toolbar = - tp->GetColor(BrowserThemeProvider::COLOR_TOOLBAR); + tp->GetColor(ThemeService::COLOR_TOOLBAR); SkColor color_tab_text = - tp->GetColor(BrowserThemeProvider::COLOR_BOOKMARK_TEXT); + tp->GetColor(ThemeService::COLOR_BOOKMARK_TEXT); std::string command = StringPrintf( "WebInspector.setToolbarColors(\"%s\", \"%s\")", SkColorToRGBAString(color_toolbar).c_str(), diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc index 7af01a2..f4f979a 100644 --- a/chrome/browser/extensions/extension_host.cc +++ b/chrome/browser/extensions/extension_host.cc @@ -24,7 +24,6 @@ #include "chrome/browser/renderer_host/browser_render_process_host.h" #include "chrome/browser/renderer_preferences_util.h" #include "chrome/browser/tab_contents/popup_menu_helper_mac.h" -#include "chrome/browser/themes/browser_theme_provider.h" #include "chrome/browser/ui/app_modal_dialogs/message_box_handler.h" #include "chrome/browser/ui/browser.h" #include "chrome/common/chrome_constants.h" diff --git a/chrome/browser/extensions/extension_install_ui.cc b/chrome/browser/extensions/extension_install_ui.cc index ec50d16..41dacd3 100644 --- a/chrome/browser/extensions/extension_install_ui.cc +++ b/chrome/browser/extensions/extension_install_ui.cc @@ -20,7 +20,7 @@ #include "chrome/browser/platform_util.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/tabs/tab_strip_model.h" -#include "chrome/browser/themes/theme_service.h" +#include "chrome/browser/themes/theme_service_factory.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_dialogs.h" #include "chrome/common/extensions/extension.h" @@ -38,7 +38,7 @@ #if defined(TOOLKIT_GTK) #include "chrome/browser/extensions/gtk_theme_installed_infobar_delegate.h" -#include "chrome/browser/ui/gtk/gtk_theme_provider.h" +#include "chrome/browser/ui/gtk/gtk_theme_service.h" #endif // static @@ -113,7 +113,7 @@ ExtensionInstallUI::ExtensionInstallUI(Profile* profile) // On Linux, we also need to take the user's system settings into account // to undo theme installation. previous_use_system_theme_ = - GtkThemeProvider::GetFrom(profile_)->UseGtkTheme(); + GtkThemeService::GetFrom(profile_)->UseGtkTheme(); #else DCHECK(!previous_use_system_theme_); #endif diff --git a/chrome/browser/extensions/extension_install_ui_browsertest.cc b/chrome/browser/extensions/extension_install_ui_browsertest.cc index f353bb9..721685d 100644 --- a/chrome/browser/extensions/extension_install_ui_browsertest.cc +++ b/chrome/browser/extensions/extension_install_ui_browsertest.cc @@ -8,7 +8,7 @@ #include "chrome/browser/extensions/theme_installed_infobar_delegate.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" -#include "chrome/browser/themes/theme_service.h" +#include "chrome/browser/themes/theme_service_factory.h" #include "chrome/test/ui_test_utils.h" #include "content/browser/tab_contents/tab_contents.h" diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc index aebbcad..9e0145b 100644 --- a/chrome/browser/extensions/extension_service.cc +++ b/chrome/browser/extensions/extension_service.cc @@ -47,8 +47,8 @@ #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/search_engines/template_url_model.h" -#include "chrome/browser/themes/browser_theme_provider.h" #include "chrome/browser/themes/theme_service.h" +#include "chrome/browser/themes/theme_service_factory.h" #include "chrome/browser/ui/webui/shown_sections_handler.h" #include "chrome/common/child_process_logging.h" #include "chrome/common/chrome_switches.h" diff --git a/chrome/browser/extensions/gtk_theme_installed_infobar_delegate.cc b/chrome/browser/extensions/gtk_theme_installed_infobar_delegate.cc index 79f2d64..385f2c4 100644 --- a/chrome/browser/extensions/gtk_theme_installed_infobar_delegate.cc +++ b/chrome/browser/extensions/gtk_theme_installed_infobar_delegate.cc @@ -4,7 +4,7 @@ #include "chrome/browser/extensions/gtk_theme_installed_infobar_delegate.h" -#include "chrome/browser/themes/browser_theme_provider.h" +#include "chrome/browser/themes/theme_service.h" GtkThemeInstalledInfoBarDelegate::GtkThemeInstalledInfoBarDelegate( TabContents* tab_contents, @@ -17,7 +17,7 @@ GtkThemeInstalledInfoBarDelegate::GtkThemeInstalledInfoBarDelegate( bool GtkThemeInstalledInfoBarDelegate::Cancel() { if (previous_use_gtk_theme_) { - provider()->SetNativeTheme(); + theme_service()->SetNativeTheme(); return true; } else { return ThemeInstalledInfoBarDelegate::Cancel(); diff --git a/chrome/browser/extensions/theme_installed_infobar_delegate.cc b/chrome/browser/extensions/theme_installed_infobar_delegate.cc index c76f494..eaf7a7a 100644 --- a/chrome/browser/extensions/theme_installed_infobar_delegate.cc +++ b/chrome/browser/extensions/theme_installed_infobar_delegate.cc @@ -9,8 +9,8 @@ #include "base/utf_string_conversions.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/themes/browser_theme_provider.h" #include "chrome/browser/themes/theme_service.h" +#include "chrome/browser/themes/theme_service_factory.h" #include "chrome/common/extensions/extension.h" #include "content/browser/tab_contents/tab_contents.h" #include "content/common/notification_service.h" @@ -25,12 +25,12 @@ ThemeInstalledInfoBarDelegate::ThemeInstalledInfoBarDelegate( const std::string& previous_theme_id) : ConfirmInfoBarDelegate(tab_contents), profile_(tab_contents->profile()), - provider_(ThemeServiceFactory::GetForProfile(profile_)), + theme_service_(ThemeServiceFactory::GetForProfile(profile_)), name_(new_theme->name()), theme_id_(new_theme->id()), previous_theme_id_(previous_theme_id), tab_contents_(tab_contents) { - provider_->OnInfobarDisplayed(); + theme_service_->OnInfobarDisplayed(); registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, NotificationService::AllSources()); } @@ -43,7 +43,7 @@ ThemeInstalledInfoBarDelegate::~ThemeInstalledInfoBarDelegate() { // We don't want any notifications while we're running our destructor. registrar_.RemoveAll(); - provider_->OnInfobarDestroyed(); + theme_service_->OnInfobarDestroyed(); } bool ThemeInstalledInfoBarDelegate::Cancel() { @@ -53,13 +53,13 @@ bool ThemeInstalledInfoBarDelegate::Cancel() { const Extension* previous_theme = service->GetExtensionById(previous_theme_id_, true); if (previous_theme) { - provider_->SetTheme(previous_theme); + theme_service_->SetTheme(previous_theme); return true; } } } - provider_->UseDefaultTheme(); + theme_service_->UseDefaultTheme(); return true; } diff --git a/chrome/browser/extensions/theme_installed_infobar_delegate.h b/chrome/browser/extensions/theme_installed_infobar_delegate.h index 1288a55..072a572 100644 --- a/chrome/browser/extensions/theme_installed_infobar_delegate.h +++ b/chrome/browser/extensions/theme_installed_infobar_delegate.h @@ -9,7 +9,7 @@ #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" #include "content/common/notification_registrar.h" -class BrowserThemeProvider; +class ThemeService; class Extension; class SkBitmap; class TabContents; @@ -30,7 +30,7 @@ class ThemeInstalledInfoBarDelegate : public ConfirmInfoBarDelegate, protected: virtual ~ThemeInstalledInfoBarDelegate(); - BrowserThemeProvider* provider() { return provider_; } + ThemeService* theme_service() { return theme_service_; } // ConfirmInfoBarDelegate: virtual bool Cancel(); @@ -50,7 +50,7 @@ class ThemeInstalledInfoBarDelegate : public ConfirmInfoBarDelegate, const NotificationDetails& details); Profile* profile_; - BrowserThemeProvider* provider_; + ThemeService* theme_service_; // Name of theme that's just been installed. std::string name_; diff --git a/chrome/browser/ntp_background_util.cc b/chrome/browser/ntp_background_util.cc index 5cd3f95..5dc0d6f 100644 --- a/chrome/browser/ntp_background_util.cc +++ b/chrome/browser/ntp_background_util.cc @@ -1,11 +1,11 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/ntp_background_util.h" #include "base/logging.h" -#include "chrome/browser/themes/browser_theme_provider.h" +#include "chrome/browser/themes/theme_service.h" #include "grit/theme_resources.h" #include "third_party/skia/include/core/SkBitmap.h" #include "ui/gfx/canvas.h" @@ -22,26 +22,26 @@ void PaintThemeBackground( int width = area.width() + ntp_background->width(); int height = area.height() + ntp_background->height(); - if (alignment & BrowserThemeProvider::ALIGN_BOTTOM) + if (alignment & ThemeService::ALIGN_BOTTOM) y_pos += area.height() + tab_contents_height - ntp_background->height(); - if (alignment & BrowserThemeProvider::ALIGN_RIGHT) { + if (alignment & ThemeService::ALIGN_RIGHT) { x_pos += area.width() - ntp_background->width(); - } else if (alignment & BrowserThemeProvider::ALIGN_LEFT) { + } else if (alignment & ThemeService::ALIGN_LEFT) { // no op } else { // ALIGN_CENTER x_pos += area.width() / 2 - ntp_background->width() / 2; } - if (tiling != BrowserThemeProvider::REPEAT && - tiling != BrowserThemeProvider::REPEAT_X) { + if (tiling != ThemeService::REPEAT && + tiling != ThemeService::REPEAT_X) { width = ntp_background->width(); } else if (x_pos > 0) { x_pos = x_pos % ntp_background->width() - ntp_background->width(); } - if (tiling != BrowserThemeProvider::REPEAT && - tiling != BrowserThemeProvider::REPEAT_Y) { + if (tiling != ThemeService::REPEAT && + tiling != ThemeService::REPEAT_Y) { height = ntp_background->height(); } else if (y_pos > 0) { y_pos = y_pos % ntp_background->height() - ntp_background->height(); @@ -60,15 +60,15 @@ void NtpBackgroundUtil::PaintBackgroundDetachedMode( ui::ThemeProvider* tp, gfx::Canvas* canvas, const gfx::Rect& area, int tab_contents_height) { // Draw the background to match the new tab page. - canvas->FillRectInt(tp->GetColor(BrowserThemeProvider::COLOR_NTP_BACKGROUND), + canvas->FillRectInt(tp->GetColor(ThemeService::COLOR_NTP_BACKGROUND), area.x(), area.y(), area.width(), area.height()); if (tp->HasCustomImage(IDR_THEME_NTP_BACKGROUND)) { - int tiling = BrowserThemeProvider::NO_REPEAT; - tp->GetDisplayProperty(BrowserThemeProvider::NTP_BACKGROUND_TILING, + int tiling = ThemeService::NO_REPEAT; + tp->GetDisplayProperty(ThemeService::NTP_BACKGROUND_TILING, &tiling); int alignment; - if (tp->GetDisplayProperty(BrowserThemeProvider::NTP_BACKGROUND_ALIGNMENT, + if (tp->GetDisplayProperty(ThemeService::NTP_BACKGROUND_ALIGNMENT, &alignment)) { SkBitmap* ntp_background = tp->GetBitmapNamed(IDR_THEME_NTP_BACKGROUND); diff --git a/chrome/browser/profiles/profile.cc b/chrome/browser/profiles/profile.cc index 74c4222..ef51e6a 100644 --- a/chrome/browser/profiles/profile.cc +++ b/chrome/browser/profiles/profile.cc @@ -29,7 +29,7 @@ #include "chrome/browser/profiles/off_the_record_profile_io_data.h" #include "chrome/browser/ssl/ssl_host_state.h" #include "chrome/browser/sync/profile_sync_service.h" -#include "chrome/browser/themes/browser_theme_provider.h" +#include "chrome/browser/themes/theme_service.h" #include "chrome/browser/ui/find_bar/find_bar_state.h" #include "chrome/browser/ui/webui/chrome_url_data_manager.h" #include "chrome/browser/ui/webui/extension_icon_source.h" @@ -53,7 +53,7 @@ #include "webkit/database/database_tracker.h" #if defined(TOOLKIT_USES_GTK) -#include "chrome/browser/ui/gtk/gtk_theme_provider.h" +#include "chrome/browser/ui/gtk/gtk_theme_service.h" #endif #if defined(OS_WIN) @@ -104,11 +104,11 @@ void Profile::RegisterUserPrefs(PrefService* prefs) { prefs->RegisterBooleanPref(prefs::kEnableAutoSpellCorrect, true); #if defined(TOOLKIT_USES_GTK) prefs->RegisterBooleanPref(prefs::kUsesSystemTheme, - GtkThemeProvider::DefaultUsesSystemTheme()); + GtkThemeService::DefaultUsesSystemTheme()); #endif prefs->RegisterFilePathPref(prefs::kCurrentThemePackFilename, FilePath()); prefs->RegisterStringPref(prefs::kCurrentThemeID, - BrowserThemeProvider::kDefaultThemeID); + ThemeService::kDefaultThemeID); prefs->RegisterDictionaryPref(prefs::kCurrentThemeImages); prefs->RegisterDictionaryPref(prefs::kCurrentThemeColors); prefs->RegisterDictionaryPref(prefs::kCurrentThemeTints); diff --git a/chrome/browser/profiles/profile.h b/chrome/browser/profiles/profile.h index 35f8e5488..a1ac13e 100644 --- a/chrome/browser/profiles/profile.h +++ b/chrome/browser/profiles/profile.h @@ -45,7 +45,6 @@ class AutocompleteClassifier; class BackgroundContentsService; class BookmarkModel; class BrowserSignin; -class BrowserThemeProvider; class ChromeAppCacheService; class ChromeBlobStorageContext; class ChromeURLDataManager; diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc index 28eb99a..cc8eb7d 100644 --- a/chrome/browser/profiles/profile_impl.cc +++ b/chrome/browser/profiles/profile_impl.cc @@ -67,7 +67,6 @@ #include "chrome/browser/sync/profile_sync_factory_impl.h" #include "chrome/browser/sync/profile_sync_service.h" #include "chrome/browser/tabs/pinned_tab_service.h" -#include "chrome/browser/themes/browser_theme_provider.h" #include "chrome/browser/transport_security_persister.h" #include "chrome/browser/ui/find_bar/find_bar_state.h" #include "chrome/browser/ui/webui/chrome_url_data_manager.h" diff --git a/chrome/browser/renderer_preferences_util.cc b/chrome/browser/renderer_preferences_util.cc index e487b93..34ce27f 100644 --- a/chrome/browser/renderer_preferences_util.cc +++ b/chrome/browser/renderer_preferences_util.cc @@ -7,7 +7,7 @@ #include "chrome/browser/profiles/profile.h" #if defined(TOOLKIT_USES_GTK) -#include "chrome/browser/ui/gtk/gtk_theme_provider.h" +#include "chrome/browser/ui/gtk/gtk_theme_service.h" #include "chrome/browser/ui/gtk/gtk_util.h" #endif @@ -18,18 +18,20 @@ void UpdateFromSystemSettings(RendererPreferences* prefs, Profile* profile) { gtk_util::UpdateGtkFontSettings(prefs); #if !defined(OS_CHROMEOS) - GtkThemeProvider* provider = GtkThemeProvider::GetFrom(profile); - - prefs->focus_ring_color = provider->get_focus_ring_color(); - prefs->thumb_active_color = provider->get_thumb_active_color(); - prefs->thumb_inactive_color = provider->get_thumb_inactive_color(); - prefs->track_color = provider->get_track_color(); - prefs->active_selection_bg_color = provider->get_active_selection_bg_color(); - prefs->active_selection_fg_color = provider->get_active_selection_fg_color(); + GtkThemeService* theme_service = GtkThemeService::GetFrom(profile); + + prefs->focus_ring_color = theme_service->get_focus_ring_color(); + prefs->thumb_active_color = theme_service->get_thumb_active_color(); + prefs->thumb_inactive_color = theme_service->get_thumb_inactive_color(); + prefs->track_color = theme_service->get_track_color(); + prefs->active_selection_bg_color = + theme_service->get_active_selection_bg_color(); + prefs->active_selection_fg_color = + theme_service->get_active_selection_fg_color(); prefs->inactive_selection_bg_color = - provider->get_inactive_selection_bg_color(); + theme_service->get_inactive_selection_bg_color(); prefs->inactive_selection_fg_color = - provider->get_inactive_selection_fg_color(); + theme_service->get_inactive_selection_fg_color(); #else prefs->focus_ring_color = SkColorSetRGB(0x50, 0x7A, 0xD5); prefs->active_selection_bg_color = SkColorSetRGB(0xDC, 0xE4, 0xFA); diff --git a/chrome/browser/speech/speech_input_bubble_gtk.cc b/chrome/browser/speech/speech_input_bubble_gtk.cc index 6c602fc..ec82451 100644 --- a/chrome/browser/speech/speech_input_bubble_gtk.cc +++ b/chrome/browser/speech/speech_input_bubble_gtk.cc @@ -6,7 +6,7 @@ #include "base/utf_string_conversions.h" #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h" -#include "chrome/browser/ui/gtk/gtk_theme_provider.h" +#include "chrome/browser/ui/gtk/gtk_theme_service.h" #include "chrome/browser/ui/gtk/gtk_util.h" #include "chrome/browser/ui/gtk/info_bubble_gtk.h" #include "chrome/browser/ui/gtk/owned_widget_gtk.h" @@ -164,7 +164,7 @@ void SpeechInputBubbleGtk::Show() { kBubbleControlHorizontalSpacing, kBubbleControlHorizontalSpacing); gtk_container_add(GTK_CONTAINER(content), vbox); - GtkThemeProvider* theme_provider = GtkThemeProvider::GetFrom( + GtkThemeService* theme_provider = GtkThemeService::GetFrom( tab_contents()->profile()); gfx::Rect rect( element_rect_.x() + element_rect_.width() - kBubbleTargetOffsetX, diff --git a/chrome/browser/sync/glue/theme_change_processor.cc b/chrome/browser/sync/glue/theme_change_processor.cc index 53b20c7..458270d 100644 --- a/chrome/browser/sync/glue/theme_change_processor.cc +++ b/chrome/browser/sync/glue/theme_change_processor.cc @@ -9,8 +9,8 @@ #include "chrome/browser/sync/engine/syncapi.h" #include "chrome/browser/sync/glue/theme_util.h" #include "chrome/browser/sync/protocol/theme_specifics.pb.h" -#include "chrome/browser/themes/browser_theme_provider.h" #include "chrome/browser/themes/theme_service.h" +#include "chrome/browser/themes/theme_service_factory.h" #include "chrome/common/extensions/extension.h" #include "content/common/notification_details.h" #include "content/common/notification_source.h" @@ -46,7 +46,7 @@ void ThemeChangeProcessor::Observe(NotificationType type, } else { extension = Details<const Extension>(details).ptr(); } - BrowserThemeProvider* theme_provider = + ThemeService* theme_provider = ThemeServiceFactory::GetForProfile(profile_); std::string current_or_future_theme_id = theme_provider->GetThemeID(); const Extension* current_theme = @@ -61,7 +61,7 @@ void ThemeChangeProcessor::Observe(NotificationType type, // and loaded (and we get an EXTENSION_LOADED notification). VLOG(1) << "Got BROWSER_THEME_CHANGED notification for theme " << GetThemeId(extension); - DCHECK_EQ(Source<BrowserThemeProvider>(source).ptr(), + DCHECK_EQ(Source<ThemeService>(source).ptr(), theme_provider); if (extension != NULL) { DCHECK(extension->is_theme()); @@ -205,7 +205,7 @@ void ThemeChangeProcessor::StartObserving() { "EXTENSION_UNLOADED"; notification_registrar_.Add( this, NotificationType::BROWSER_THEME_CHANGED, - Source<BrowserThemeProvider>( + Source<ThemeService>( ThemeServiceFactory::GetForProfile(profile_))); notification_registrar_.Add( this, NotificationType::EXTENSION_LOADED, diff --git a/chrome/browser/sync/glue/theme_change_processor.h b/chrome/browser/sync/glue/theme_change_processor.h index 9253746..7a94c92 100644 --- a/chrome/browser/sync/glue/theme_change_processor.h +++ b/chrome/browser/sync/glue/theme_change_processor.h @@ -22,7 +22,7 @@ namespace browser_sync { class UnrecoverableErrorHandler; // This class is responsible for taking changes from the -// BrowserThemeProvider and applying them to the sync_api 'syncable' +// ThemeService and applying them to the sync_api 'syncable' // model, and vice versa. All operations and use of this class are // from the UI thread. class ThemeChangeProcessor : public ChangeProcessor, @@ -32,13 +32,13 @@ class ThemeChangeProcessor : public ChangeProcessor, virtual ~ThemeChangeProcessor(); // NotificationObserver implementation. - // BrowserThemeProvider -> sync_api model change application. + // ThemeService -> sync_api model change application. virtual void Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details); // ChangeProcessor implementation. - // sync_api model -> BrowserThemeProvider change application. + // sync_api model -> ThemeService change application. virtual void ApplyChangesFromSyncModel( const sync_api::BaseTransaction* trans, const sync_api::SyncManager::ChangeRecord* changes, @@ -54,7 +54,7 @@ class ThemeChangeProcessor : public ChangeProcessor, void StopObserving(); NotificationRegistrar notification_registrar_; - // Owner of the BrowserThemeProvider. Non-NULL iff |running()| is + // Profile associated with the ThemeService. Non-NULL iff |running()| is // true. Profile* profile_; diff --git a/chrome/browser/sync/glue/theme_model_associator.cc b/chrome/browser/sync/glue/theme_model_associator.cc index 6b51af2..73808bd 100644 --- a/chrome/browser/sync/glue/theme_model_associator.cc +++ b/chrome/browser/sync/glue/theme_model_associator.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -12,7 +12,6 @@ #include "chrome/browser/sync/glue/theme_util.h" #include "chrome/browser/sync/profile_sync_service.h" #include "chrome/browser/sync/protocol/theme_specifics.pb.h" -#include "chrome/browser/themes/browser_theme_provider.h" namespace browser_sync { diff --git a/chrome/browser/sync/glue/theme_util.cc b/chrome/browser/sync/glue/theme_util.cc index 306c9a7..9ec1fc4 100644 --- a/chrome/browser/sync/glue/theme_util.cc +++ b/chrome/browser/sync/glue/theme_util.cc @@ -12,12 +12,12 @@ #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_updater.h" #if defined(TOOLKIT_USES_GTK) -#include "chrome/browser/ui/gtk/gtk_theme_provider.h" +#include "chrome/browser/ui/gtk/gtk_theme_service.h" #endif #include "chrome/browser/profiles/profile.h" #include "chrome/browser/sync/protocol/theme_specifics.pb.h" -#include "chrome/browser/themes/browser_theme_provider.h" #include "chrome/browser/themes/theme_service.h" +#include "chrome/browser/themes/theme_service_factory.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/extensions/extension_constants.h" #include "googleurl/src/gurl.h" @@ -38,7 +38,7 @@ bool IsSystemThemeDistinctFromDefaultTheme() { bool UseSystemTheme(Profile* profile) { #if defined(TOOLKIT_USES_GTK) - return GtkThemeProvider::GetFrom(profile)->UseGtkTheme(); + return GtkThemeService::GetFrom(profile)->UseGtkTheme(); #else return false; #endif diff --git a/chrome/browser/sync/glue/theme_util_unittest.cc b/chrome/browser/sync/glue/theme_util_unittest.cc index 119c4ba..f9548ce 100644 --- a/chrome/browser/sync/glue/theme_util_unittest.cc +++ b/chrome/browser/sync/glue/theme_util_unittest.cc @@ -8,8 +8,8 @@ #include "base/values.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/sync/protocol/theme_specifics.pb.h" -#include "chrome/browser/themes/browser_theme_provider.h" #include "chrome/browser/themes/theme_service.h" +#include "chrome/browser/themes/theme_service_factory.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/extensions/extension_constants.h" #include "chrome/test/testing_profile.h" @@ -90,7 +90,7 @@ TEST_F(ThemeUtilTest, AreThemeSpecificsEqualHelper) { EXPECT_TRUE(AreThemeSpecificsEqualHelper(a, b, true)); } -class MockBrowserThemeProvider : public BrowserThemeProvider { +class MockThemeService : public ThemeService { public: MOCK_METHOD0(SetNativeTheme, void()); MOCK_METHOD0(UseDefaultTheme, void()); @@ -100,10 +100,10 @@ class MockBrowserThemeProvider : public BrowserThemeProvider { TEST_F(ThemeUtilTest, SetCurrentThemeDefaultTheme) { sync_pb::ThemeSpecifics theme_specifics; TestingProfile profile; - MockBrowserThemeProvider* mock_provider = new MockBrowserThemeProvider; - ThemeServiceFactory::ForceAssociationBetween(&profile, mock_provider); + MockThemeService* mock_theme_service = new MockThemeService; + ThemeServiceFactory::ForceAssociationBetween(&profile, mock_theme_service); - EXPECT_CALL(*mock_provider, UseDefaultTheme()).Times(1); + EXPECT_CALL(*mock_theme_service, UseDefaultTheme()).Times(1); SetCurrentThemeFromThemeSpecifics(theme_specifics, &profile); } @@ -113,10 +113,10 @@ TEST_F(ThemeUtilTest, SetCurrentThemeSystemTheme) { theme_specifics.set_use_system_theme_by_default(true); TestingProfile profile; - MockBrowserThemeProvider* mock_provider = new MockBrowserThemeProvider; - ThemeServiceFactory::ForceAssociationBetween(&profile, mock_provider); + MockThemeService* mock_theme_service = new MockThemeService; + ThemeServiceFactory::ForceAssociationBetween(&profile, mock_theme_service); - EXPECT_CALL(*mock_provider, SetNativeTheme()).Times(1); + EXPECT_CALL(*mock_theme_service, SetNativeTheme()).Times(1); SetCurrentThemeFromThemeSpecifics(theme_specifics, &profile); } @@ -213,11 +213,11 @@ TEST_F(ThemeUtilTest, GetThemeSpecificsHelperCustomThemeDistinct) { TEST_F(ThemeUtilTest, SetCurrentThemeIfNecessaryDefaultThemeNotNecessary) { TestingProfile profile; - MockBrowserThemeProvider* mock_provider = new MockBrowserThemeProvider; - ThemeServiceFactory::ForceAssociationBetween(&profile, mock_provider); + MockThemeService* mock_theme_service = new MockThemeService; + ThemeServiceFactory::ForceAssociationBetween(&profile, mock_theme_service); - EXPECT_CALL(*mock_provider, GetThemeID()).WillRepeatedly(Return( - BrowserThemeProvider::kDefaultThemeID)); + EXPECT_CALL(*mock_theme_service, GetThemeID()).WillRepeatedly(Return( + ThemeService::kDefaultThemeID)); // TODO(akalin): Mock out call to GetPrefs() under TOOLKIT_USES_GTK. diff --git a/chrome/browser/tab_contents/tab_contents_view_gtk.cc b/chrome/browser/tab_contents/tab_contents_view_gtk.cc index cd75a9e..e952e4e 100644 --- a/chrome/browser/tab_contents/tab_contents_view_gtk.cc +++ b/chrome/browser/tab_contents/tab_contents_view_gtk.cc @@ -21,7 +21,6 @@ #include "chrome/browser/ui/gtk/constrained_window_gtk.h" #include "chrome/browser/ui/gtk/gtk_expanded_container.h" #include "chrome/browser/ui/gtk/gtk_floating_container.h" -#include "chrome/browser/ui/gtk/gtk_theme_provider.h" #include "chrome/browser/ui/gtk/gtk_util.h" #include "chrome/browser/ui/gtk/sad_tab_gtk.h" #include "chrome/browser/ui/gtk/tab_contents_drag_source.h" diff --git a/chrome/browser/themes/browser_theme_pack.cc b/chrome/browser/themes/browser_theme_pack.cc index 71c6116..93633a9 100644 --- a/chrome/browser/themes/browser_theme_pack.cc +++ b/chrome/browser/themes/browser_theme_pack.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -9,7 +9,7 @@ #include "base/threading/thread_restrictions.h" #include "base/utf_string_conversions.h" #include "base/values.h" -#include "chrome/browser/themes/browser_theme_provider.h" +#include "chrome/browser/themes/theme_service.h" #include "content/browser/browser_thread.h" #include "grit/app_resources.h" #include "grit/theme_resources.h" @@ -174,57 +174,57 @@ struct StringToIntTable { // Strings used by themes to identify tints in the JSON. StringToIntTable kTintTable[] = { - { "buttons", BrowserThemeProvider::TINT_BUTTONS }, - { "frame", BrowserThemeProvider::TINT_FRAME }, - { "frame_inactive", BrowserThemeProvider::TINT_FRAME_INACTIVE }, - { "frame_incognito", BrowserThemeProvider::TINT_FRAME_INCOGNITO }, + { "buttons", ThemeService::TINT_BUTTONS }, + { "frame", ThemeService::TINT_FRAME }, + { "frame_inactive", ThemeService::TINT_FRAME_INACTIVE }, + { "frame_incognito", ThemeService::TINT_FRAME_INCOGNITO }, { "frame_incognito_inactive", - BrowserThemeProvider::TINT_FRAME_INCOGNITO_INACTIVE }, - { "background_tab", BrowserThemeProvider::TINT_BACKGROUND_TAB }, + ThemeService::TINT_FRAME_INCOGNITO_INACTIVE }, + { "background_tab", ThemeService::TINT_BACKGROUND_TAB }, { NULL, 0 } }; // Strings used by themes to identify colors in the JSON. StringToIntTable kColorTable[] = { - { "frame", BrowserThemeProvider::COLOR_FRAME }, - { "frame_inactive", BrowserThemeProvider::COLOR_FRAME_INACTIVE }, - { "frame_incognito", BrowserThemeProvider::COLOR_FRAME_INCOGNITO }, + { "frame", ThemeService::COLOR_FRAME }, + { "frame_inactive", ThemeService::COLOR_FRAME_INACTIVE }, + { "frame_incognito", ThemeService::COLOR_FRAME_INCOGNITO }, { "frame_incognito_inactive", - BrowserThemeProvider::COLOR_FRAME_INCOGNITO_INACTIVE }, - { "toolbar", BrowserThemeProvider::COLOR_TOOLBAR }, - { "tab_text", BrowserThemeProvider::COLOR_TAB_TEXT }, - { "tab_background_text", BrowserThemeProvider::COLOR_BACKGROUND_TAB_TEXT }, - { "bookmark_text", BrowserThemeProvider::COLOR_BOOKMARK_TEXT }, - { "ntp_background", BrowserThemeProvider::COLOR_NTP_BACKGROUND }, - { "ntp_text", BrowserThemeProvider::COLOR_NTP_TEXT }, - { "ntp_link", BrowserThemeProvider::COLOR_NTP_LINK }, - { "ntp_link_underline", BrowserThemeProvider::COLOR_NTP_LINK_UNDERLINE }, - { "ntp_header", BrowserThemeProvider::COLOR_NTP_HEADER }, - { "ntp_section", BrowserThemeProvider::COLOR_NTP_SECTION }, - { "ntp_section_text", BrowserThemeProvider::COLOR_NTP_SECTION_TEXT }, - { "ntp_section_link", BrowserThemeProvider::COLOR_NTP_SECTION_LINK }, + ThemeService::COLOR_FRAME_INCOGNITO_INACTIVE }, + { "toolbar", ThemeService::COLOR_TOOLBAR }, + { "tab_text", ThemeService::COLOR_TAB_TEXT }, + { "tab_background_text", ThemeService::COLOR_BACKGROUND_TAB_TEXT }, + { "bookmark_text", ThemeService::COLOR_BOOKMARK_TEXT }, + { "ntp_background", ThemeService::COLOR_NTP_BACKGROUND }, + { "ntp_text", ThemeService::COLOR_NTP_TEXT }, + { "ntp_link", ThemeService::COLOR_NTP_LINK }, + { "ntp_link_underline", ThemeService::COLOR_NTP_LINK_UNDERLINE }, + { "ntp_header", ThemeService::COLOR_NTP_HEADER }, + { "ntp_section", ThemeService::COLOR_NTP_SECTION }, + { "ntp_section_text", ThemeService::COLOR_NTP_SECTION_TEXT }, + { "ntp_section_link", ThemeService::COLOR_NTP_SECTION_LINK }, { "ntp_section_link_underline", - BrowserThemeProvider::COLOR_NTP_SECTION_LINK_UNDERLINE }, - { "control_background", BrowserThemeProvider::COLOR_CONTROL_BACKGROUND }, - { "button_background", BrowserThemeProvider::COLOR_BUTTON_BACKGROUND }, + ThemeService::COLOR_NTP_SECTION_LINK_UNDERLINE }, + { "control_background", ThemeService::COLOR_CONTROL_BACKGROUND }, + { "button_background", ThemeService::COLOR_BUTTON_BACKGROUND }, { NULL, 0 } }; // Strings used by themes to identify display properties keys in JSON. StringToIntTable kDisplayProperties[] = { { "ntp_background_alignment", - BrowserThemeProvider::NTP_BACKGROUND_ALIGNMENT }, - { "ntp_background_repeat", BrowserThemeProvider::NTP_BACKGROUND_TILING }, - { "ntp_logo_alternate", BrowserThemeProvider::NTP_LOGO_ALTERNATE }, + ThemeService::NTP_BACKGROUND_ALIGNMENT }, + { "ntp_background_repeat", ThemeService::NTP_BACKGROUND_TILING }, + { "ntp_logo_alternate", ThemeService::NTP_LOGO_ALTERNATE }, { NULL, 0 } }; // Strings used by the tiling values in JSON. StringToIntTable kTilingStrings[] = { - { "no-repeat", BrowserThemeProvider::NO_REPEAT }, - { "repeat-x", BrowserThemeProvider::REPEAT_X }, - { "repeat-y", BrowserThemeProvider::REPEAT_Y }, - { "repeat", BrowserThemeProvider::REPEAT }, + { "no-repeat", ThemeService::NO_REPEAT }, + { "repeat-x", ThemeService::REPEAT_X }, + { "repeat-y", ThemeService::REPEAT_Y }, + { "repeat", ThemeService::REPEAT }, { NULL, 0 } }; @@ -246,14 +246,14 @@ struct IntToIntTable { // Mapping used in GenerateFrameImages() to associate frame images with the // tint ID that should maybe be applied to it. IntToIntTable kFrameTintMap[] = { - { PRS_THEME_FRAME, BrowserThemeProvider::TINT_FRAME }, - { PRS_THEME_FRAME_INACTIVE, BrowserThemeProvider::TINT_FRAME_INACTIVE }, - { PRS_THEME_FRAME_OVERLAY, BrowserThemeProvider::TINT_FRAME }, + { PRS_THEME_FRAME, ThemeService::TINT_FRAME }, + { PRS_THEME_FRAME_INACTIVE, ThemeService::TINT_FRAME_INACTIVE }, + { PRS_THEME_FRAME_OVERLAY, ThemeService::TINT_FRAME }, { PRS_THEME_FRAME_OVERLAY_INACTIVE, - BrowserThemeProvider::TINT_FRAME_INACTIVE }, - { PRS_THEME_FRAME_INCOGNITO, BrowserThemeProvider::TINT_FRAME_INCOGNITO }, + ThemeService::TINT_FRAME_INACTIVE }, + { PRS_THEME_FRAME_INCOGNITO, ThemeService::TINT_FRAME_INCOGNITO }, { PRS_THEME_FRAME_INCOGNITO_INACTIVE, - BrowserThemeProvider::TINT_FRAME_INCOGNITO_INACTIVE } + ThemeService::TINT_FRAME_INCOGNITO_INACTIVE } }; // Mapping used in GenerateTabBackgroundImages() to associate what frame image @@ -355,7 +355,7 @@ BrowserThemePack* BrowserThemePack::BuildFromExtension( // OSX uses its own special buttons that are PDFs that do odd sorts of vector // graphics tricks. Other platforms use bitmaps and we must pre-tint them. pack->GenerateTintedButtons( - pack->GetTintInternal(BrowserThemeProvider::TINT_BUTTONS), + pack->GetTintInternal(ThemeService::TINT_BUTTONS), &pack->prepared_images_); #endif @@ -705,56 +705,56 @@ void BrowserThemePack::ReadColorsFromJSON( void BrowserThemePack::GenerateMissingColors( std::map<int, SkColor>* colors) { // Generate link colors, if missing. (See GetColor()). - if (!colors->count(BrowserThemeProvider::COLOR_NTP_HEADER) && - colors->count(BrowserThemeProvider::COLOR_NTP_SECTION)) { - (*colors)[BrowserThemeProvider::COLOR_NTP_HEADER] = - (*colors)[BrowserThemeProvider::COLOR_NTP_SECTION]; + if (!colors->count(ThemeService::COLOR_NTP_HEADER) && + colors->count(ThemeService::COLOR_NTP_SECTION)) { + (*colors)[ThemeService::COLOR_NTP_HEADER] = + (*colors)[ThemeService::COLOR_NTP_SECTION]; } - if (!colors->count(BrowserThemeProvider::COLOR_NTP_SECTION_LINK_UNDERLINE) && - colors->count(BrowserThemeProvider::COLOR_NTP_SECTION_LINK)) { + if (!colors->count(ThemeService::COLOR_NTP_SECTION_LINK_UNDERLINE) && + colors->count(ThemeService::COLOR_NTP_SECTION_LINK)) { SkColor color_section_link = - (*colors)[BrowserThemeProvider::COLOR_NTP_SECTION_LINK]; - (*colors)[BrowserThemeProvider::COLOR_NTP_SECTION_LINK_UNDERLINE] = + (*colors)[ThemeService::COLOR_NTP_SECTION_LINK]; + (*colors)[ThemeService::COLOR_NTP_SECTION_LINK_UNDERLINE] = SkColorSetA(color_section_link, SkColorGetA(color_section_link) / 3); } - if (!colors->count(BrowserThemeProvider::COLOR_NTP_LINK_UNDERLINE) && - colors->count(BrowserThemeProvider::COLOR_NTP_LINK)) { - SkColor color_link = (*colors)[BrowserThemeProvider::COLOR_NTP_LINK]; - (*colors)[BrowserThemeProvider::COLOR_NTP_LINK_UNDERLINE] = + if (!colors->count(ThemeService::COLOR_NTP_LINK_UNDERLINE) && + colors->count(ThemeService::COLOR_NTP_LINK)) { + SkColor color_link = (*colors)[ThemeService::COLOR_NTP_LINK]; + (*colors)[ThemeService::COLOR_NTP_LINK_UNDERLINE] = SkColorSetA(color_link, SkColorGetA(color_link) / 3); } // Generate frame colors, if missing. (See GenerateFrameColors()). SkColor frame; std::map<int, SkColor>::const_iterator it = - colors->find(BrowserThemeProvider::COLOR_FRAME); + colors->find(ThemeService::COLOR_FRAME); if (it != colors->end()) { frame = it->second; } else { - frame = BrowserThemeProvider::GetDefaultColor( - BrowserThemeProvider::COLOR_FRAME); + frame = ThemeService::GetDefaultColor( + ThemeService::COLOR_FRAME); } - if (!colors->count(BrowserThemeProvider::COLOR_FRAME)) { - (*colors)[BrowserThemeProvider::COLOR_FRAME] = - HSLShift(frame, GetTintInternal(BrowserThemeProvider::TINT_FRAME)); + if (!colors->count(ThemeService::COLOR_FRAME)) { + (*colors)[ThemeService::COLOR_FRAME] = + HSLShift(frame, GetTintInternal(ThemeService::TINT_FRAME)); } - if (!colors->count(BrowserThemeProvider::COLOR_FRAME_INACTIVE)) { - (*colors)[BrowserThemeProvider::COLOR_FRAME_INACTIVE] = + if (!colors->count(ThemeService::COLOR_FRAME_INACTIVE)) { + (*colors)[ThemeService::COLOR_FRAME_INACTIVE] = HSLShift(frame, GetTintInternal( - BrowserThemeProvider::TINT_FRAME_INACTIVE)); + ThemeService::TINT_FRAME_INACTIVE)); } - if (!colors->count(BrowserThemeProvider::COLOR_FRAME_INCOGNITO)) { - (*colors)[BrowserThemeProvider::COLOR_FRAME_INCOGNITO] = + if (!colors->count(ThemeService::COLOR_FRAME_INCOGNITO)) { + (*colors)[ThemeService::COLOR_FRAME_INCOGNITO] = HSLShift(frame, GetTintInternal( - BrowserThemeProvider::TINT_FRAME_INCOGNITO)); + ThemeService::TINT_FRAME_INCOGNITO)); } - if (!colors->count(BrowserThemeProvider::COLOR_FRAME_INCOGNITO_INACTIVE)) { - (*colors)[BrowserThemeProvider::COLOR_FRAME_INCOGNITO_INACTIVE] = + if (!colors->count(ThemeService::COLOR_FRAME_INCOGNITO_INACTIVE)) { + (*colors)[ThemeService::COLOR_FRAME_INCOGNITO_INACTIVE] = HSLShift(frame, GetTintInternal( - BrowserThemeProvider::TINT_FRAME_INCOGNITO_INACTIVE)); + ThemeService::TINT_FRAME_INCOGNITO_INACTIVE)); } } @@ -775,26 +775,26 @@ void BrowserThemePack::BuildDisplayPropertiesFromJSON( iter != display_properties_value->end_keys(); ++iter) { int property_id = GetIntForString(*iter, kDisplayProperties); switch (property_id) { - case BrowserThemeProvider::NTP_BACKGROUND_ALIGNMENT: { + case ThemeService::NTP_BACKGROUND_ALIGNMENT: { std::string val; if (display_properties_value->GetString(*iter, &val)) { - temp_properties[BrowserThemeProvider::NTP_BACKGROUND_ALIGNMENT] = - BrowserThemeProvider::StringToAlignment(val); + temp_properties[ThemeService::NTP_BACKGROUND_ALIGNMENT] = + ThemeService::StringToAlignment(val); } break; } - case BrowserThemeProvider::NTP_BACKGROUND_TILING: { + case ThemeService::NTP_BACKGROUND_TILING: { std::string val; if (display_properties_value->GetString(*iter, &val)) { - temp_properties[BrowserThemeProvider::NTP_BACKGROUND_TILING] = + temp_properties[ThemeService::NTP_BACKGROUND_TILING] = GetIntForString(val, kTilingStrings); } break; } - case BrowserThemeProvider::NTP_LOGO_ALTERNATE: { + case ThemeService::NTP_LOGO_ALTERNATE: { int val = 0; if (display_properties_value->GetInteger(*iter, &val)) - temp_properties[BrowserThemeProvider::NTP_LOGO_ALTERNATE] = val; + temp_properties[ThemeService::NTP_LOGO_ALTERNATE] = val; break; } } @@ -945,7 +945,7 @@ void BrowserThemePack::GenerateTintedButtons( if (button_tint.h != -1 || button_tint.s != -1 || button_tint.l != -1) { ResourceBundle& rb = ResourceBundle::GetSharedInstance(); const std::set<int>& idr_ids = - BrowserThemeProvider::GetTintableToolbarButtons(); + ThemeService::GetTintableToolbarButtons(); for (std::set<int>::const_iterator it = idr_ids.begin(); it != idr_ids.end(); ++it) { int prs_id = GetPersistentIDByIDR(*it); @@ -973,7 +973,7 @@ void BrowserThemePack::GenerateTabBackgroundImages(ImageCache* bitmaps) const { if (it != bitmaps->end()) { SkBitmap bg_tint = SkBitmapOperations::CreateHSLShiftedBitmap( *(it->second), GetTintInternal( - BrowserThemeProvider::TINT_BACKGROUND_TAB)); + ThemeService::TINT_BACKGROUND_TAB)); int vertical_offset = bitmaps->count(prs_id) ? kRestoredTabVerticalOffset : 0; SkBitmap* bg_tab = new SkBitmap(SkBitmapOperations::CreateTiledBitmap( @@ -1046,5 +1046,5 @@ color_utils::HSL BrowserThemePack::GetTintInternal(int id) const { } } - return BrowserThemeProvider::GetDefaultTint(id); + return ThemeService::GetDefaultTint(id); } diff --git a/chrome/browser/themes/browser_theme_pack_unittest.cc b/chrome/browser/themes/browser_theme_pack_unittest.cc index 72219f0..7eb8b5f 100644 --- a/chrome/browser/themes/browser_theme_pack_unittest.cc +++ b/chrome/browser/themes/browser_theme_pack_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -10,7 +10,7 @@ #include "base/path_service.h" #include "base/scoped_temp_dir.h" #include "base/values.h" -#include "chrome/browser/themes/browser_theme_provider.h" +#include "chrome/browser/themes/theme_service.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/json_value_serializer.h" #include "content/browser/browser_thread.h" @@ -35,9 +35,9 @@ class BrowserThemePackTest : public ::testing::Test { void GenerateDefaultFrameColor(std::map<int, SkColor>* colors, int color, int tint) { (*colors)[color] = HSLShift( - BrowserThemeProvider::GetDefaultColor( - BrowserThemeProvider::COLOR_FRAME), - BrowserThemeProvider::GetDefaultTint(tint)); + ThemeService::GetDefaultColor( + ThemeService::COLOR_FRAME), + ThemeService::GetDefaultTint(tint)); } // Returns a mapping from each COLOR_* constant to the default value for this @@ -45,23 +45,23 @@ class BrowserThemePackTest : public ::testing::Test { // run the resulting thing through VerifyColorMap(). std::map<int, SkColor> GetDefaultColorMap() { std::map<int, SkColor> colors; - for (int i = BrowserThemeProvider::COLOR_FRAME; - i <= BrowserThemeProvider::COLOR_BUTTON_BACKGROUND; ++i) { - colors[i] = BrowserThemeProvider::GetDefaultColor(i); + for (int i = ThemeService::COLOR_FRAME; + i <= ThemeService::COLOR_BUTTON_BACKGROUND; ++i) { + colors[i] = ThemeService::GetDefaultColor(i); } - GenerateDefaultFrameColor(&colors, BrowserThemeProvider::COLOR_FRAME, - BrowserThemeProvider::TINT_FRAME); + GenerateDefaultFrameColor(&colors, ThemeService::COLOR_FRAME, + ThemeService::TINT_FRAME); GenerateDefaultFrameColor(&colors, - BrowserThemeProvider::COLOR_FRAME_INACTIVE, - BrowserThemeProvider::TINT_FRAME_INACTIVE); + ThemeService::COLOR_FRAME_INACTIVE, + ThemeService::TINT_FRAME_INACTIVE); GenerateDefaultFrameColor(&colors, - BrowserThemeProvider::COLOR_FRAME_INCOGNITO, - BrowserThemeProvider::TINT_FRAME_INCOGNITO); + ThemeService::COLOR_FRAME_INCOGNITO, + ThemeService::TINT_FRAME_INCOGNITO); GenerateDefaultFrameColor( &colors, - BrowserThemeProvider::COLOR_FRAME_INCOGNITO_INACTIVE, - BrowserThemeProvider::TINT_FRAME_INCOGNITO_INACTIVE); + ThemeService::COLOR_FRAME_INCOGNITO_INACTIVE, + ThemeService::TINT_FRAME_INCOGNITO_INACTIVE); return colors; } @@ -69,7 +69,7 @@ class BrowserThemePackTest : public ::testing::Test { void VerifyColorMap(const std::map<int, SkColor>& color_map) { for (std::map<int, SkColor>::const_iterator it = color_map.begin(); it != color_map.end(); ++it) { - SkColor color = BrowserThemeProvider::GetDefaultColor(it->first); + SkColor color = ThemeService::GetDefaultColor(it->first); theme_pack_->GetColor(it->first, &color); EXPECT_EQ(it->second, color) << "Color id = " << it->first; } @@ -148,25 +148,25 @@ class BrowserThemePackTest : public ::testing::Test { void VerifyStarGazing(BrowserThemePack* pack) { // First check that values we know exist, exist. SkColor color; - EXPECT_TRUE(pack->GetColor(BrowserThemeProvider::COLOR_BOOKMARK_TEXT, + EXPECT_TRUE(pack->GetColor(ThemeService::COLOR_BOOKMARK_TEXT, &color)); EXPECT_EQ(SK_ColorBLACK, color); - EXPECT_TRUE(pack->GetColor(BrowserThemeProvider::COLOR_NTP_BACKGROUND, + EXPECT_TRUE(pack->GetColor(ThemeService::COLOR_NTP_BACKGROUND, &color)); EXPECT_EQ(SkColorSetRGB(57, 137, 194), color); color_utils::HSL expected = { 0.6, 0.553, 0.5 }; color_utils::HSL actual; - EXPECT_TRUE(pack->GetTint(BrowserThemeProvider::TINT_BUTTONS, &actual)); + EXPECT_TRUE(pack->GetTint(ThemeService::TINT_BUTTONS, &actual)); EXPECT_DOUBLE_EQ(expected.h, actual.h); EXPECT_DOUBLE_EQ(expected.s, actual.s); EXPECT_DOUBLE_EQ(expected.l, actual.l); int val; EXPECT_TRUE(pack->GetDisplayProperty( - BrowserThemeProvider::NTP_BACKGROUND_ALIGNMENT, &val)); - EXPECT_EQ(BrowserThemeProvider::ALIGN_TOP, val); + ThemeService::NTP_BACKGROUND_ALIGNMENT, &val)); + EXPECT_EQ(ThemeService::ALIGN_TOP, val); // The stargazing theme defines the following images: EXPECT_TRUE(pack->HasCustomImage(IDR_THEME_BUTTON_BACKGROUND)); @@ -185,9 +185,9 @@ class BrowserThemePackTest : public ::testing::Test { EXPECT_FALSE(pack->HasCustomImage(IDR_THEME_TAB_BACKGROUND_INCOGNITO)); // Make sure we don't have phantom data. - EXPECT_FALSE(pack->GetColor(BrowserThemeProvider::COLOR_CONTROL_BACKGROUND, + EXPECT_FALSE(pack->GetColor(ThemeService::COLOR_CONTROL_BACKGROUND, &color)); - EXPECT_FALSE(pack->GetTint(BrowserThemeProvider::TINT_FRAME, &actual)); + EXPECT_FALSE(pack->GetTint(ThemeService::TINT_FRAME, &actual)); } MessageLoop message_loop; @@ -207,11 +207,11 @@ TEST_F(BrowserThemePackTest, DeriveUnderlineLinkColor) { std::map<int, SkColor> colors = GetDefaultColorMap(); SkColor link_color = SkColorSetRGB(128, 128, 128); - colors[BrowserThemeProvider::COLOR_NTP_LINK] = link_color; - colors[BrowserThemeProvider::COLOR_NTP_LINK_UNDERLINE] = + colors[ThemeService::COLOR_NTP_LINK] = link_color; + colors[ThemeService::COLOR_NTP_LINK_UNDERLINE] = BuildThirdOpacity(link_color); - colors[BrowserThemeProvider::COLOR_NTP_SECTION_LINK] = link_color; - colors[BrowserThemeProvider::COLOR_NTP_SECTION_LINK_UNDERLINE] = + colors[ThemeService::COLOR_NTP_SECTION_LINK] = link_color; + colors[ThemeService::COLOR_NTP_SECTION_LINK_UNDERLINE] = BuildThirdOpacity(link_color); VerifyColorMap(colors); @@ -229,10 +229,10 @@ TEST_F(BrowserThemePackTest, ProvideUnderlineLinkColor) { std::map<int, SkColor> colors = GetDefaultColorMap(); SkColor link_color = SkColorSetRGB(128, 128, 128); SkColor underline_color = SkColorSetRGB(255, 255, 255); - colors[BrowserThemeProvider::COLOR_NTP_LINK] = link_color; - colors[BrowserThemeProvider::COLOR_NTP_LINK_UNDERLINE] = underline_color; - colors[BrowserThemeProvider::COLOR_NTP_SECTION_LINK] = link_color; - colors[BrowserThemeProvider::COLOR_NTP_SECTION_LINK_UNDERLINE] = + colors[ThemeService::COLOR_NTP_LINK] = link_color; + colors[ThemeService::COLOR_NTP_LINK_UNDERLINE] = underline_color; + colors[ThemeService::COLOR_NTP_SECTION_LINK] = link_color; + colors[ThemeService::COLOR_NTP_SECTION_LINK_UNDERLINE] = underline_color; VerifyColorMap(colors); @@ -244,8 +244,8 @@ TEST_F(BrowserThemePackTest, UseSectionColorAsNTPHeader) { std::map<int, SkColor> colors = GetDefaultColorMap(); SkColor ntp_color = SkColorSetRGB(190, 190, 190); - colors[BrowserThemeProvider::COLOR_NTP_HEADER] = ntp_color; - colors[BrowserThemeProvider::COLOR_NTP_SECTION] = ntp_color; + colors[ThemeService::COLOR_NTP_HEADER] = ntp_color; + colors[ThemeService::COLOR_NTP_SECTION] = ntp_color; VerifyColorMap(colors); } @@ -257,8 +257,8 @@ TEST_F(BrowserThemePackTest, ProvideNtpHeaderColor) { std::map<int, SkColor> colors = GetDefaultColorMap(); SkColor ntp_header = SkColorSetRGB(120, 120, 120); SkColor ntp_section = SkColorSetRGB(190, 190, 190); - colors[BrowserThemeProvider::COLOR_NTP_HEADER] = ntp_header; - colors[BrowserThemeProvider::COLOR_NTP_SECTION] = ntp_section; + colors[ThemeService::COLOR_NTP_HEADER] = ntp_header; + colors[ThemeService::COLOR_NTP_SECTION] = ntp_section; VerifyColorMap(colors); } @@ -269,7 +269,7 @@ TEST_F(BrowserThemePackTest, CanReadTints) { color_utils::HSL expected = { 0.5, 0.5, 0.5 }; color_utils::HSL actual = { -1, -1, -1 }; EXPECT_TRUE(theme_pack_->GetTint( - BrowserThemeProvider::TINT_BUTTONS, &actual)); + ThemeService::TINT_BUTTONS, &actual)); EXPECT_DOUBLE_EQ(expected.h, actual.h); EXPECT_DOUBLE_EQ(expected.s, actual.s); EXPECT_DOUBLE_EQ(expected.l, actual.l); @@ -283,15 +283,15 @@ TEST_F(BrowserThemePackTest, CanReadDisplayProperties) { int out_val; EXPECT_TRUE(theme_pack_->GetDisplayProperty( - BrowserThemeProvider::NTP_BACKGROUND_ALIGNMENT, &out_val)); - EXPECT_EQ(BrowserThemeProvider::ALIGN_BOTTOM, out_val); + ThemeService::NTP_BACKGROUND_ALIGNMENT, &out_val)); + EXPECT_EQ(ThemeService::ALIGN_BOTTOM, out_val); EXPECT_TRUE(theme_pack_->GetDisplayProperty( - BrowserThemeProvider::NTP_BACKGROUND_TILING, &out_val)); - EXPECT_EQ(BrowserThemeProvider::REPEAT_X, out_val); + ThemeService::NTP_BACKGROUND_TILING, &out_val)); + EXPECT_EQ(ThemeService::REPEAT_X, out_val); EXPECT_TRUE(theme_pack_->GetDisplayProperty( - BrowserThemeProvider::NTP_LOGO_ALTERNATE, &out_val)); + ThemeService::NTP_LOGO_ALTERNATE, &out_val)); EXPECT_EQ(0, out_val); } @@ -335,7 +335,7 @@ TEST_F(BrowserThemePackTest, InvalidTints) { // We shouldn't have a buttons tint, as it was invalid. color_utils::HSL actual = { -1, -1, -1 }; - EXPECT_FALSE(theme_pack_->GetTint(BrowserThemeProvider::TINT_BUTTONS, + EXPECT_FALSE(theme_pack_->GetTint(ThemeService::TINT_BUTTONS, &actual)); } @@ -346,7 +346,7 @@ TEST_F(BrowserThemePackTest, InvalidDisplayProperties) { int out_val; EXPECT_FALSE(theme_pack_->GetDisplayProperty( - BrowserThemeProvider::NTP_BACKGROUND_ALIGNMENT, &out_val)); + ThemeService::NTP_BACKGROUND_ALIGNMENT, &out_val)); } // These three tests should just not cause a segmentation fault. diff --git a/chrome/browser/themes/browser_theme_provider.cc b/chrome/browser/themes/browser_theme_provider.cc deleted file mode 100644 index 3c8ee4a..0000000 --- a/chrome/browser/themes/browser_theme_provider.cc +++ /dev/null @@ -1,644 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/themes/browser_theme_provider.h" - -#include "base/string_split.h" -#include "base/string_util.h" -#include "base/utf_string_conversions.h" -#include "chrome/browser/extensions/extension_service.h" -#include "chrome/browser/metrics/user_metrics.h" -#include "chrome/browser/profiles/profile.h" -#include "chrome/browser/themes/browser_theme_pack.h" -#include "chrome/common/chrome_constants.h" -#include "chrome/common/pref_names.h" -#include "content/common/notification_service.h" -#include "content/common/notification_type.h" -#include "grit/app_resources.h" -#include "grit/theme_resources.h" -#include "ui/base/resource/resource_bundle.h" - -#if defined(OS_WIN) -#include "views/widget/widget_win.h" -#endif - -// Strings used in alignment properties. -const char* BrowserThemeProvider::kAlignmentTop = "top"; -const char* BrowserThemeProvider::kAlignmentBottom = "bottom"; -const char* BrowserThemeProvider::kAlignmentLeft = "left"; -const char* BrowserThemeProvider::kAlignmentRight = "right"; - -// Strings used in background tiling repetition properties. -const char* BrowserThemeProvider::kTilingNoRepeat = "no-repeat"; -const char* BrowserThemeProvider::kTilingRepeatX = "repeat-x"; -const char* BrowserThemeProvider::kTilingRepeatY = "repeat-y"; -const char* BrowserThemeProvider::kTilingRepeat = "repeat"; - -// The default theme if we haven't installed a theme yet or if we've clicked -// the "Use Classic" button. -const char* BrowserThemeProvider::kDefaultThemeID = ""; - -namespace { - -// The default theme if we've gone to the theme gallery and installed the -// "Default" theme. We have to detect this case specifically. (By the time we -// realize we've installed the default theme, we already have an extension -// unpacked on the filesystem.) -const char* kDefaultThemeGalleryID = "hkacjpbfdknhflllbcmjibkdeoafencn"; - -SkColor TintForUnderline(SkColor input) { - return SkColorSetA(input, SkColorGetA(input) / 3); -} - -SkColor IncreaseLightness(SkColor color, double percent) { - color_utils::HSL result; - color_utils::SkColorToHSL(color, &result); - result.l += (1 - result.l) * percent; - return color_utils::HSLToSkColor(result, SkColorGetA(color)); -} - -// Default colors. -const SkColor kDefaultColorFrame = SkColorSetRGB(66, 116, 201); -const SkColor kDefaultColorFrameInactive = SkColorSetRGB(161, 182, 228); -const SkColor kDefaultColorFrameIncognito = SkColorSetRGB(83, 106, 139); -const SkColor kDefaultColorFrameIncognitoInactive = - SkColorSetRGB(126, 139, 156); -#if defined(OS_MACOSX) -const SkColor kDefaultColorToolbar = SkColorSetRGB(230, 230, 230); -#else -const SkColor kDefaultColorToolbar = SkColorSetRGB(223, 223, 223); -#endif -const SkColor kDefaultColorTabText = SK_ColorBLACK; -#if defined(OS_MACOSX) -const SkColor kDefaultColorBackgroundTabText = SK_ColorBLACK; -const SkColor kDefaultColorBookmarkText = SK_ColorBLACK; -#else -const SkColor kDefaultColorBackgroundTabText = SkColorSetRGB(64, 64, 64); -const SkColor kDefaultColorBookmarkText = SkColorSetRGB(18, 50, 114); -#endif -#if defined(OS_WIN) -const SkColor kDefaultColorNTPBackground = - color_utils::GetSysSkColor(COLOR_WINDOW); -const SkColor kDefaultColorNTPText = - color_utils::GetSysSkColor(COLOR_WINDOWTEXT); -const SkColor kDefaultColorNTPLink = - color_utils::GetSysSkColor(COLOR_HOTLIGHT); -#else -// TODO(beng): source from theme provider. -const SkColor kDefaultColorNTPBackground = SK_ColorWHITE; -const SkColor kDefaultColorNTPText = SK_ColorBLACK; -const SkColor kDefaultColorNTPLink = SkColorSetRGB(6, 55, 116); -#endif -const SkColor kDefaultColorNTPHeader = SkColorSetRGB(150, 150, 150); -const SkColor kDefaultColorNTPSection = SkColorSetRGB(229, 229, 229); -const SkColor kDefaultColorNTPSectionText = SK_ColorBLACK; -const SkColor kDefaultColorNTPSectionLink = SkColorSetRGB(6, 55, 116); -const SkColor kDefaultColorControlBackground = SkColorSetARGB(0, 0, 0, 0); -const SkColor kDefaultColorButtonBackground = SkColorSetARGB(0, 0, 0, 0); -#if defined(OS_MACOSX) -const SkColor kDefaultColorToolbarButtonStroke = SkColorSetARGB(75, 81, 81, 81); -const SkColor kDefaultColorToolbarButtonStrokeInactive = - SkColorSetARGB(75, 99, 99, 99); -const SkColor kDefaultColorToolbarBezel = SkColorSetRGB(247, 247, 247); -const SkColor kDefaultColorToolbarStroke = SkColorSetRGB(103, 103, 103); -const SkColor kDefaultColorToolbarStrokeInactive = SkColorSetRGB(123, 123, 123); -#endif - -// Default tints. -const color_utils::HSL kDefaultTintButtons = { -1, -1, -1 }; -const color_utils::HSL kDefaultTintFrame = { -1, -1, -1 }; -const color_utils::HSL kDefaultTintFrameInactive = { -1, -1, 0.75f }; -const color_utils::HSL kDefaultTintFrameIncognito = { -1, 0.2f, 0.35f }; -const color_utils::HSL kDefaultTintFrameIncognitoInactive = { -1, 0.3f, 0.6f }; -const color_utils::HSL kDefaultTintBackgroundTab = { -1, 0.5, 0.75 }; - -// Default display properties. -const int kDefaultDisplayPropertyNTPAlignment = - BrowserThemeProvider::ALIGN_BOTTOM; -const int kDefaultDisplayPropertyNTPTiling = - BrowserThemeProvider::NO_REPEAT; -const int kDefaultDisplayPropertyNTPInverseLogo = 0; - -// The sum of kFrameBorderThickness and kNonClientRestoredExtraThickness from -// OpaqueBrowserFrameView. -const int kRestoredTabVerticalOffset = 15; - -// The image resources we will allow people to theme. -const int kThemeableImages[] = { - IDR_THEME_FRAME, - IDR_THEME_FRAME_INACTIVE, - IDR_THEME_FRAME_INCOGNITO, - IDR_THEME_FRAME_INCOGNITO_INACTIVE, - IDR_THEME_TOOLBAR, - IDR_THEME_TAB_BACKGROUND, - IDR_THEME_TAB_BACKGROUND_INCOGNITO, - IDR_THEME_TAB_BACKGROUND_V, - IDR_THEME_NTP_BACKGROUND, - IDR_THEME_FRAME_OVERLAY, - IDR_THEME_FRAME_OVERLAY_INACTIVE, - IDR_THEME_BUTTON_BACKGROUND, - IDR_THEME_NTP_ATTRIBUTION, - IDR_THEME_WINDOW_CONTROL_BACKGROUND -}; - -bool HasThemeableImage(int themeable_image_id) { - static std::set<int> themeable_images; - if (themeable_images.empty()) { - themeable_images.insert( - kThemeableImages, kThemeableImages + arraysize(kThemeableImages)); - } - return themeable_images.count(themeable_image_id) > 0; -} - -// The image resources that will be tinted by the 'button' tint value. -// If you change this list, you must increment the version number in -// browser_theme_pack.cc, and you should assign persistent IDs to the -// data table at the start of said file or else tinted versions of -// these resources will not be created. -const int kToolbarButtonIDs[] = { - IDR_BACK, IDR_BACK_D, IDR_BACK_H, IDR_BACK_P, - IDR_FORWARD, IDR_FORWARD_D, IDR_FORWARD_H, IDR_FORWARD_P, - IDR_HOME, IDR_HOME_H, IDR_HOME_P, - IDR_RELOAD, IDR_RELOAD_H, IDR_RELOAD_P, - IDR_STOP, IDR_STOP_D, IDR_STOP_H, IDR_STOP_P, - IDR_LOCATIONBG_C, IDR_LOCATIONBG_L, IDR_LOCATIONBG_R, - IDR_BROWSER_ACTIONS_OVERFLOW, IDR_BROWSER_ACTIONS_OVERFLOW_H, - IDR_BROWSER_ACTIONS_OVERFLOW_P, - IDR_TOOLS, IDR_TOOLS_H, IDR_TOOLS_P, - IDR_MENU_DROPARROW, - IDR_THROBBER, IDR_THROBBER_WAITING, IDR_THROBBER_LIGHT, -}; - -// Writes the theme pack to disk on a separate thread. -class WritePackToDiskTask : public Task { - public: - WritePackToDiskTask(BrowserThemePack* pack, const FilePath& path) - : theme_pack_(pack), pack_path_(path) {} - - virtual void Run() { - if (!theme_pack_->WriteToDisk(pack_path_)) { - NOTREACHED() << "Could not write theme pack to disk"; - } - } - - private: - scoped_refptr<BrowserThemePack> theme_pack_; - FilePath pack_path_; -}; - -} // namespace - -bool BrowserThemeProvider::IsThemeableImage(int resource_id) { - return HasThemeableImage(resource_id); -} - -BrowserThemeProvider::BrowserThemeProvider() - : rb_(ResourceBundle::GetSharedInstance()), - profile_(NULL), - number_of_infobars_(0) { - // Initialize the themeable image map so we can use it on other threads. - HasThemeableImage(0); -} - -BrowserThemeProvider::~BrowserThemeProvider() { - FreePlatformCaches(); -} - -void BrowserThemeProvider::Init(Profile* profile) { - DCHECK(CalledOnValidThread()); - profile_ = profile; - - LoadThemePrefs(); -} - -SkBitmap* BrowserThemeProvider::GetBitmapNamed(int id) const { - DCHECK(CalledOnValidThread()); - - SkBitmap* bitmap = NULL; - - if (theme_pack_.get()) - bitmap = theme_pack_->GetBitmapNamed(id); - - if (!bitmap) - bitmap = rb_.GetBitmapNamed(id); - - return bitmap; -} - -SkColor BrowserThemeProvider::GetColor(int id) const { - DCHECK(CalledOnValidThread()); - - SkColor color; - if (theme_pack_.get() && theme_pack_->GetColor(id, &color)) - return color; - - // For backward compat with older themes, some newer colors are generated from - // older ones if they are missing. - switch (id) { - case COLOR_NTP_SECTION_HEADER_TEXT: - return IncreaseLightness(GetColor(COLOR_NTP_TEXT), 0.30); - case COLOR_NTP_SECTION_HEADER_TEXT_HOVER: - return GetColor(COLOR_NTP_TEXT); - case COLOR_NTP_SECTION_HEADER_RULE: - return IncreaseLightness(GetColor(COLOR_NTP_TEXT), 0.70); - case COLOR_NTP_SECTION_HEADER_RULE_LIGHT: - return IncreaseLightness(GetColor(COLOR_NTP_TEXT), 0.86); - case COLOR_NTP_TEXT_LIGHT: - return IncreaseLightness(GetColor(COLOR_NTP_TEXT), 0.40); - } - - return GetDefaultColor(id); -} - -bool BrowserThemeProvider::GetDisplayProperty(int id, int* result) const { - if (theme_pack_.get()) - return theme_pack_->GetDisplayProperty(id, result); - - return GetDefaultDisplayProperty(id, result); -} - -bool BrowserThemeProvider::ShouldUseNativeFrame() const { - if (HasCustomImage(IDR_THEME_FRAME)) - return false; -#if defined(OS_WIN) - return views::WidgetWin::IsAeroGlassEnabled(); -#else - return false; -#endif -} - -bool BrowserThemeProvider::HasCustomImage(int id) const { - if (!HasThemeableImage(id)) - return false; - - if (theme_pack_) - return theme_pack_->HasCustomImage(id); - - return false; -} - -RefCountedMemory* BrowserThemeProvider::GetRawData(int id) const { - // Check to see whether we should substitute some images. - int ntp_alternate; - GetDisplayProperty(NTP_LOGO_ALTERNATE, &ntp_alternate); - if (id == IDR_PRODUCT_LOGO && ntp_alternate != 0) - id = IDR_PRODUCT_LOGO_WHITE; - - RefCountedMemory* data = NULL; - if (theme_pack_.get()) - data = theme_pack_->GetRawData(id); - if (!data) - data = rb_.LoadDataResourceBytes(id); - - return data; -} - -void BrowserThemeProvider::SetTheme(const Extension* extension) { - // Clear our image cache. - FreePlatformCaches(); - - DCHECK(extension); - DCHECK(extension->is_theme()); - - BuildFromExtension(extension); - SaveThemeID(extension->id()); - - NotifyThemeChanged(extension); - UserMetrics::RecordAction(UserMetricsAction("Themes_Installed"), profile_); -} - -void BrowserThemeProvider::RemoveUnusedThemes() { - if (!profile_) - return; - ExtensionService* service = profile_->GetExtensionService(); - if (!service) - return; - std::string current_theme = GetThemeID(); - std::vector<std::string> remove_list; - const ExtensionList* extensions = service->extensions(); - for (ExtensionList::const_iterator it = extensions->begin(); - it != extensions->end(); ++it) { - if ((*it)->is_theme() && (*it)->id() != current_theme) { - remove_list.push_back((*it)->id()); - } - } - for (size_t i = 0; i < remove_list.size(); ++i) - service->UninstallExtension(remove_list[i], false); -} - -void BrowserThemeProvider::UseDefaultTheme() { - ClearAllThemeData(); - NotifyThemeChanged(NULL); - UserMetrics::RecordAction(UserMetricsAction("Themes_Reset"), profile_); -} - -void BrowserThemeProvider::SetNativeTheme() { - UseDefaultTheme(); -} - -bool BrowserThemeProvider::UsingDefaultTheme() { - std::string id = GetThemeID(); - return id == BrowserThemeProvider::kDefaultThemeID || - id == kDefaultThemeGalleryID; -} - -std::string BrowserThemeProvider::GetThemeID() const { - return profile_->GetPrefs()->GetString(prefs::kCurrentThemeID); -} - -// static -std::string BrowserThemeProvider::AlignmentToString(int alignment) { - // Convert from an AlignmentProperty back into a string. - std::string vertical_string; - std::string horizontal_string; - - if (alignment & BrowserThemeProvider::ALIGN_TOP) - vertical_string = kAlignmentTop; - else if (alignment & BrowserThemeProvider::ALIGN_BOTTOM) - vertical_string = kAlignmentBottom; - - if (alignment & BrowserThemeProvider::ALIGN_LEFT) - horizontal_string = kAlignmentLeft; - else if (alignment & BrowserThemeProvider::ALIGN_RIGHT) - horizontal_string = kAlignmentRight; - - if (vertical_string.empty()) - return horizontal_string; - if (horizontal_string.empty()) - return vertical_string; - return vertical_string + " " + horizontal_string; -} - -// static -int BrowserThemeProvider::StringToAlignment(const std::string& alignment) { - std::vector<std::wstring> split; - base::SplitStringAlongWhitespace(UTF8ToWide(alignment), &split); - - int alignment_mask = 0; - for (std::vector<std::wstring>::iterator alignments(split.begin()); - alignments != split.end(); ++alignments) { - std::string comp = WideToUTF8(*alignments); - const char* component = comp.c_str(); - - if (base::strcasecmp(component, kAlignmentTop) == 0) - alignment_mask |= BrowserThemeProvider::ALIGN_TOP; - else if (base::strcasecmp(component, kAlignmentBottom) == 0) - alignment_mask |= BrowserThemeProvider::ALIGN_BOTTOM; - - if (base::strcasecmp(component, kAlignmentLeft) == 0) - alignment_mask |= BrowserThemeProvider::ALIGN_LEFT; - else if (base::strcasecmp(component, kAlignmentRight) == 0) - alignment_mask |= BrowserThemeProvider::ALIGN_RIGHT; - } - return alignment_mask; -} - -// static -std::string BrowserThemeProvider::TilingToString(int tiling) { - // Convert from a TilingProperty back into a string. - if (tiling == BrowserThemeProvider::REPEAT_X) - return kTilingRepeatX; - if (tiling == BrowserThemeProvider::REPEAT_Y) - return kTilingRepeatY; - if (tiling == BrowserThemeProvider::REPEAT) - return kTilingRepeat; - return kTilingNoRepeat; -} - -// static -int BrowserThemeProvider::StringToTiling(const std::string& tiling) { - const char* component = tiling.c_str(); - - if (base::strcasecmp(component, kTilingRepeatX) == 0) - return BrowserThemeProvider::REPEAT_X; - if (base::strcasecmp(component, kTilingRepeatY) == 0) - return BrowserThemeProvider::REPEAT_Y; - if (base::strcasecmp(component, kTilingRepeat) == 0) - return BrowserThemeProvider::REPEAT; - // NO_REPEAT is the default choice. - return BrowserThemeProvider::NO_REPEAT; -} - -// static -color_utils::HSL BrowserThemeProvider::GetDefaultTint(int id) { - switch (id) { - case TINT_FRAME: - return kDefaultTintFrame; - case TINT_FRAME_INACTIVE: - return kDefaultTintFrameInactive; - case TINT_FRAME_INCOGNITO: - return kDefaultTintFrameIncognito; - case TINT_FRAME_INCOGNITO_INACTIVE: - return kDefaultTintFrameIncognitoInactive; - case TINT_BUTTONS: - return kDefaultTintButtons; - case TINT_BACKGROUND_TAB: - return kDefaultTintBackgroundTab; - default: - color_utils::HSL result = {-1, -1, -1}; - return result; - } -} - -// static -SkColor BrowserThemeProvider::GetDefaultColor(int id) { - switch (id) { - case COLOR_FRAME: - return kDefaultColorFrame; - case COLOR_FRAME_INACTIVE: - return kDefaultColorFrameInactive; - case COLOR_FRAME_INCOGNITO: - return kDefaultColorFrameIncognito; - case COLOR_FRAME_INCOGNITO_INACTIVE: - return kDefaultColorFrameIncognitoInactive; - case COLOR_TOOLBAR: - return kDefaultColorToolbar; - case COLOR_TAB_TEXT: - return kDefaultColorTabText; - case COLOR_BACKGROUND_TAB_TEXT: - return kDefaultColorBackgroundTabText; - case COLOR_BOOKMARK_TEXT: - return kDefaultColorBookmarkText; - case COLOR_NTP_BACKGROUND: - return kDefaultColorNTPBackground; - case COLOR_NTP_TEXT: - return kDefaultColorNTPText; - case COLOR_NTP_LINK: - return kDefaultColorNTPLink; - case COLOR_NTP_LINK_UNDERLINE: - return TintForUnderline(kDefaultColorNTPLink); - case COLOR_NTP_HEADER: - return kDefaultColorNTPHeader; - case COLOR_NTP_SECTION: - return kDefaultColorNTPSection; - case COLOR_NTP_SECTION_TEXT: - return kDefaultColorNTPSectionText; - case COLOR_NTP_SECTION_LINK: - return kDefaultColorNTPSectionLink; - case COLOR_NTP_SECTION_LINK_UNDERLINE: - return TintForUnderline(kDefaultColorNTPSectionLink); - case COLOR_CONTROL_BACKGROUND: - return kDefaultColorControlBackground; - case COLOR_BUTTON_BACKGROUND: - return kDefaultColorButtonBackground; -#if defined(OS_MACOSX) - case COLOR_TOOLBAR_BUTTON_STROKE: - return kDefaultColorToolbarButtonStroke; - case COLOR_TOOLBAR_BUTTON_STROKE_INACTIVE: - return kDefaultColorToolbarButtonStrokeInactive; - case COLOR_TOOLBAR_BEZEL: - return kDefaultColorToolbarBezel; - case COLOR_TOOLBAR_STROKE: - return kDefaultColorToolbarStroke; - case COLOR_TOOLBAR_STROKE_INACTIVE: - return kDefaultColorToolbarStrokeInactive; -#endif - default: - // Return a debugging red color. - return 0xffff0000; - } -} - -// static -bool BrowserThemeProvider::GetDefaultDisplayProperty(int id, int* result) { - switch (id) { - case NTP_BACKGROUND_ALIGNMENT: - *result = kDefaultDisplayPropertyNTPAlignment; - return true; - case NTP_BACKGROUND_TILING: - *result = kDefaultDisplayPropertyNTPTiling; - return true; - case NTP_LOGO_ALTERNATE: - *result = kDefaultDisplayPropertyNTPInverseLogo; - return true; - } - - return false; -} - -// static -const std::set<int>& BrowserThemeProvider::GetTintableToolbarButtons() { - static std::set<int> button_set; - if (button_set.empty()) { - button_set = std::set<int>( - kToolbarButtonIDs, - kToolbarButtonIDs + arraysize(kToolbarButtonIDs)); - } - - return button_set; -} - -color_utils::HSL BrowserThemeProvider::GetTint(int id) const { - DCHECK(CalledOnValidThread()); - - color_utils::HSL hsl; - if (theme_pack_.get() && theme_pack_->GetTint(id, &hsl)) - return hsl; - - return GetDefaultTint(id); -} - -void BrowserThemeProvider::ClearAllThemeData() { - // Clear our image cache. - FreePlatformCaches(); - theme_pack_ = NULL; - - profile_->GetPrefs()->ClearPref(prefs::kCurrentThemePackFilename); - SaveThemeID(kDefaultThemeID); -} - -void BrowserThemeProvider::LoadThemePrefs() { - PrefService* prefs = profile_->GetPrefs(); - - std::string current_id = GetThemeID(); - if (current_id != kDefaultThemeID) { - bool loaded_pack = false; - - // If we don't have a file pack, we're updating from an old version. - FilePath path = prefs->GetFilePath(prefs::kCurrentThemePackFilename); - if (path != FilePath()) { - theme_pack_ = BrowserThemePack::BuildFromDataPack(path, current_id); - loaded_pack = theme_pack_.get() != NULL; - } - - if (loaded_pack) { - UserMetrics::RecordAction(UserMetricsAction("Themes.Loaded"), profile_); - } else { - // TODO(erg): We need to pop up a dialog informing the user that their - // theme is being migrated. - ExtensionService* service = profile_->GetExtensionService(); - if (service) { - const Extension* extension = - service->GetExtensionById(current_id, false); - if (extension) { - DLOG(ERROR) << "Migrating theme"; - BuildFromExtension(extension); - UserMetrics::RecordAction(UserMetricsAction("Themes.Migrated"), - profile_); - } else { - DLOG(ERROR) << "Theme is mysteriously gone."; - ClearAllThemeData(); - UserMetrics::RecordAction(UserMetricsAction("Themes.Gone"), profile_); - } - } - } - } -} - -void BrowserThemeProvider::NotifyThemeChanged(const Extension* extension) { - VLOG(1) << "Sending BROWSER_THEME_CHANGED"; - // Redraw! - NotificationService* service = NotificationService::current(); - service->Notify(NotificationType::BROWSER_THEME_CHANGED, - Source<BrowserThemeProvider>(this), - Details<const Extension>(extension)); -#if defined(OS_MACOSX) - NotifyPlatformThemeChanged(); -#endif // OS_MACOSX -} - -#if defined(OS_WIN) -void BrowserThemeProvider::FreePlatformCaches() { - // Views (Skia) has no platform image cache to clear. -} -#endif - -void BrowserThemeProvider::SavePackName(const FilePath& pack_path) { - profile_->GetPrefs()->SetFilePath( - prefs::kCurrentThemePackFilename, pack_path); -} - -void BrowserThemeProvider::SaveThemeID(const std::string& id) { - profile_->GetPrefs()->SetString(prefs::kCurrentThemeID, id); -} - -void BrowserThemeProvider::BuildFromExtension(const Extension* extension) { - scoped_refptr<BrowserThemePack> pack( - BrowserThemePack::BuildFromExtension(extension)); - if (!pack.get()) { - // TODO(erg): We've failed to install the theme; perhaps we should tell the - // user? http://crbug.com/34780 - LOG(ERROR) << "Could not load theme."; - return; - } - - // Write the packed file to disk. - FilePath pack_path = extension->path().Append(chrome::kThemePackFilename); - BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, - new WritePackToDiskTask(pack, pack_path)); - - SavePackName(pack_path); - theme_pack_ = pack; -} - -void BrowserThemeProvider::OnInfobarDisplayed() { - number_of_infobars_++; -} - -void BrowserThemeProvider::OnInfobarDestroyed() { - number_of_infobars_--; - - if (number_of_infobars_ == 0) - RemoveUnusedThemes(); -} diff --git a/chrome/browser/themes/browser_theme_provider.h b/chrome/browser/themes/browser_theme_provider.h deleted file mode 100644 index 92a5c57..0000000 --- a/chrome/browser/themes/browser_theme_provider.h +++ /dev/null @@ -1,288 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_THEMES_BROWSER_THEME_PROVIDER_H_ -#define CHROME_BROWSER_THEMES_BROWSER_THEME_PROVIDER_H_ -#pragma once - -#include <map> -#include <set> -#include <string> - -#include "base/ref_counted.h" -#include "base/threading/non_thread_safe.h" -#include "ui/base/theme_provider.h" - -class BrowserThemePack; -class BrowserThemeProviderTest; -class Extension; -class FilePath; -class Profile; - -namespace color_utils { -struct HSL; -} - -namespace ui { -class ResourceBundle; -} -using ui::ResourceBundle; - -#ifdef __OBJC__ -@class NSString; -// Sent whenever the browser theme changes. Object => NSValue wrapping the -// BrowserThemeProvider that changed. -extern "C" NSString* const kBrowserThemeDidChangeNotification; -#endif // __OBJC__ - -class BrowserThemeProvider : public base::NonThreadSafe, - public ui::ThemeProvider { - public: - // Public constants used in BrowserThemeProvider and its subclasses: - - // Strings used in alignment properties. - static const char* kAlignmentTop; - static const char* kAlignmentBottom; - static const char* kAlignmentLeft; - static const char* kAlignmentRight; - - // Strings used in tiling properties. - static const char* kTilingNoRepeat; - static const char* kTilingRepeatX; - static const char* kTilingRepeatY; - static const char* kTilingRepeat; - - static const char* kDefaultThemeID; - - // Returns true if the image is themeable. Safe to call on any thread. - static bool IsThemeableImage(int resource_id); - - BrowserThemeProvider(); - virtual ~BrowserThemeProvider(); - - enum { - COLOR_FRAME, - COLOR_FRAME_INACTIVE, - COLOR_FRAME_INCOGNITO, - COLOR_FRAME_INCOGNITO_INACTIVE, - COLOR_TOOLBAR, - COLOR_TAB_TEXT, - COLOR_BACKGROUND_TAB_TEXT, - COLOR_BOOKMARK_TEXT, - COLOR_NTP_BACKGROUND, - COLOR_NTP_TEXT, - COLOR_NTP_LINK, - COLOR_NTP_LINK_UNDERLINE, - COLOR_NTP_HEADER, - COLOR_NTP_SECTION, - COLOR_NTP_SECTION_TEXT, - COLOR_NTP_SECTION_LINK, - COLOR_NTP_SECTION_LINK_UNDERLINE, - COLOR_CONTROL_BACKGROUND, - COLOR_BUTTON_BACKGROUND, - - // These colors don't have constant default values. They are derived from - // the runtime value of other colors. - COLOR_NTP_SECTION_HEADER_TEXT, - COLOR_NTP_SECTION_HEADER_TEXT_HOVER, - COLOR_NTP_SECTION_HEADER_RULE, - COLOR_NTP_SECTION_HEADER_RULE_LIGHT, - COLOR_NTP_TEXT_LIGHT, - - TINT_BUTTONS, - TINT_FRAME, - TINT_FRAME_INACTIVE, - TINT_FRAME_INCOGNITO, - TINT_FRAME_INCOGNITO_INACTIVE, - TINT_BACKGROUND_TAB, - NTP_BACKGROUND_ALIGNMENT, - NTP_BACKGROUND_TILING, - NTP_LOGO_ALTERNATE -#if defined(OS_MACOSX) - , - COLOR_TOOLBAR_BEZEL = 1000, - COLOR_TOOLBAR_STROKE, - COLOR_TOOLBAR_STROKE_INACTIVE, - COLOR_TOOLBAR_BUTTON_STROKE, - COLOR_TOOLBAR_BUTTON_STROKE_INACTIVE, - GRADIENT_FRAME_INCOGNITO, - GRADIENT_FRAME_INCOGNITO_INACTIVE, - GRADIENT_TOOLBAR, - GRADIENT_TOOLBAR_INACTIVE, - GRADIENT_TOOLBAR_BUTTON, - GRADIENT_TOOLBAR_BUTTON_INACTIVE, - GRADIENT_TOOLBAR_BUTTON_PRESSED, - GRADIENT_TOOLBAR_BUTTON_PRESSED_INACTIVE -#endif // OS_MACOSX - }; - - // A bitfield mask for alignments. - typedef enum { - ALIGN_CENTER = 0x0, - ALIGN_LEFT = 0x1, - ALIGN_TOP = 0x2, - ALIGN_RIGHT = 0x4, - ALIGN_BOTTOM = 0x8, - } AlignmentMasks; - - // Background tiling choices. - typedef enum { - NO_REPEAT = 0, - REPEAT_X = 1, - REPEAT_Y = 2, - REPEAT = 3 - } Tiling; - - // ui::ThemeProvider implementation. - virtual void Init(Profile* profile); - virtual SkBitmap* GetBitmapNamed(int id) const; - virtual SkColor GetColor(int id) const; - virtual bool GetDisplayProperty(int id, int* result) const; - virtual bool ShouldUseNativeFrame() const; - virtual bool HasCustomImage(int id) const; - virtual RefCountedMemory* GetRawData(int id) const; -#if defined(TOOLKIT_USES_GTK) - // GdkPixbufs returned by GetPixbufNamed and GetRTLEnabledPixbufNamed are - // shared instances owned by the theme provider and should not be freed. - virtual GdkPixbuf* GetPixbufNamed(int id) const; - virtual GdkPixbuf* GetRTLEnabledPixbufNamed(int id) const; -#elif defined(OS_MACOSX) - virtual NSImage* GetNSImageNamed(int id, bool allow_default) const; - virtual NSColor* GetNSImageColorNamed(int id, bool allow_default) const; - virtual NSColor* GetNSColor(int id, bool allow_default) const; - virtual NSColor* GetNSColorTint(int id, bool allow_default) const; - virtual NSGradient* GetNSGradient(int id) const; -#endif - - // Set the current theme to the theme defined in |extension|. - virtual void SetTheme(const Extension* extension); - - // Reset the theme to default. - virtual void UseDefaultTheme(); - - // Set the current theme to the native theme. On some platforms, the native - // theme is the default theme. - virtual void SetNativeTheme(); - - // Whether we're using the chrome default theme. Virtual so linux can check - // if we're using the GTK theme. - virtual bool UsingDefaultTheme(); - - // Gets the id of the last installed theme. (The theme may have been further - // locally customized.) - virtual std::string GetThemeID() const; - - // This class needs to keep track of the number of theme infobars so that we - // clean up unused themes. - void OnInfobarDisplayed(); - - // Decrements the number of theme infobars. If the last infobar has been - // destroyed, uninstalls all themes that aren't the currently selected. - void OnInfobarDestroyed(); - - // Convert a bitfield alignment into a string like "top left". Public so that - // it can be used to generate CSS values. Takes a bitfield of AlignmentMasks. - static std::string AlignmentToString(int alignment); - - // Parse alignments from something like "top left" into a bitfield of - // AlignmentMasks - static int StringToAlignment(const std::string& alignment); - - // Convert a tiling value into a string like "no-repeat". Public - // so that it can be used to generate CSS values. Takes a Tiling. - static std::string TilingToString(int tiling); - - // Parse tiling values from something like "no-repeat" into a Tiling value. - static int StringToTiling(const std::string& tiling); - - // Returns the default tint for the given tint |id| TINT_* enum value. - static color_utils::HSL GetDefaultTint(int id); - - // Returns the default color for the given color |id| COLOR_* enum value. - static SkColor GetDefaultColor(int id); - - // Returns true and sets |result| to the requested default property, if |id| - // is valid. - static bool GetDefaultDisplayProperty(int id, int* result); - - // Returns the set of IDR_* resources that should be tinted. - static const std::set<int>& GetTintableToolbarButtons(); - - // Remove preference values for themes that are no longer in use. - void RemoveUnusedThemes(); - - // Save the images to be written to disk, mapping file path to id. - typedef std::map<FilePath, int> ImagesDiskCache; - - protected: - // Get the specified tint - |id| is one of the TINT_* enum values. - color_utils::HSL GetTint(int id) const; - - // Clears all the override fields and saves the dictionary. - virtual void ClearAllThemeData(); - - // Load theme data from preferences. - virtual void LoadThemePrefs(); - - // Let all the browser views know that themes have changed. - // extension is NULL iff the theme is being set to the - // default/system theme. - virtual void NotifyThemeChanged(const Extension* extension); - -#if defined(OS_MACOSX) - // Let all the browser views know that themes have changed in a platform way. - virtual void NotifyPlatformThemeChanged(); -#endif // OS_MACOSX - - // Clears the platform-specific caches. Do not call directly; it's called - // from ClearCaches(). - virtual void FreePlatformCaches(); - - Profile* profile() { return profile_; } - - private: - friend class BrowserThemeProviderTest; - - // Saves the filename of the cached theme pack. - void SavePackName(const FilePath& pack_path); - - // Save the id of the last theme installed. - void SaveThemeID(const std::string& id); - - // Implementation of SetTheme() (and the fallback from LoadThemePrefs() in - // case we don't have a theme pack). - void BuildFromExtension(const Extension* extension); - -#if defined(TOOLKIT_USES_GTK) - // Loads an image and flips it horizontally if |rtl_enabled| is true. - GdkPixbuf* GetPixbufImpl(int id, bool rtl_enabled) const; -#endif - -#if defined(TOOLKIT_USES_GTK) - typedef std::map<int, GdkPixbuf*> GdkPixbufMap; - mutable GdkPixbufMap gdk_pixbufs_; -#elif defined(OS_MACOSX) - typedef std::map<int, NSImage*> NSImageMap; - mutable NSImageMap nsimage_cache_; - - // The bool member of the pair is whether the color is a default color. - typedef std::map<int, std::pair<NSColor*, bool> > NSColorMap; - mutable NSColorMap nscolor_cache_; - - typedef std::map<int, NSGradient*> NSGradientMap; - mutable NSGradientMap nsgradient_cache_; -#endif - - ResourceBundle& rb_; - Profile* profile_; - - scoped_refptr<BrowserThemePack> theme_pack_; - - // The number of infobars currently displayed. - int number_of_infobars_; - - DISALLOW_COPY_AND_ASSIGN(BrowserThemeProvider); -}; - -#endif // CHROME_BROWSER_THEMES_BROWSER_THEME_PROVIDER_H_ diff --git a/chrome/browser/themes/browser_theme_provider_unittest.cc b/chrome/browser/themes/browser_theme_provider_unittest.cc deleted file mode 100644 index c99a946..0000000 --- a/chrome/browser/themes/browser_theme_provider_unittest.cc +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/themes/browser_theme_provider.h" - -#include "testing/gtest/include/gtest/gtest.h" -#include "base/json/json_reader.h" - -TEST(BrowserThemeProviderTest, AlignmentConversion) { - // Verify that we get out what we put in. - std::string top_left = "top left"; - int alignment = BrowserThemeProvider::StringToAlignment(top_left); - EXPECT_EQ(BrowserThemeProvider::ALIGN_TOP | BrowserThemeProvider::ALIGN_LEFT, - alignment); - EXPECT_EQ(top_left, BrowserThemeProvider::AlignmentToString(alignment)); - - alignment = BrowserThemeProvider::StringToAlignment("top"); - EXPECT_EQ(BrowserThemeProvider::ALIGN_TOP, alignment); - EXPECT_EQ("top", BrowserThemeProvider::AlignmentToString(alignment)); - - alignment = BrowserThemeProvider::StringToAlignment("left"); - EXPECT_EQ(BrowserThemeProvider::ALIGN_LEFT, alignment); - EXPECT_EQ("left", BrowserThemeProvider::AlignmentToString(alignment)); - - alignment = BrowserThemeProvider::StringToAlignment("right"); - EXPECT_EQ(BrowserThemeProvider::ALIGN_RIGHT, alignment); - EXPECT_EQ("right", BrowserThemeProvider::AlignmentToString(alignment)); - - alignment = BrowserThemeProvider::StringToAlignment("righttopbottom"); - EXPECT_EQ(BrowserThemeProvider::ALIGN_CENTER, alignment); - EXPECT_EQ("", BrowserThemeProvider::AlignmentToString(alignment)); -} - -TEST(BrowserThemeProviderTest, AlignmentConversionInput) { - // Verify that we output in an expected format. - int alignment = BrowserThemeProvider::StringToAlignment("right bottom"); - EXPECT_EQ("bottom right", BrowserThemeProvider::AlignmentToString(alignment)); - - // Verify that bad strings don't cause explosions. - alignment = BrowserThemeProvider::StringToAlignment("new zealand"); - EXPECT_EQ("", BrowserThemeProvider::AlignmentToString(alignment)); - - // Verify that bad strings don't cause explosions. - alignment = BrowserThemeProvider::StringToAlignment("new zealand top"); - EXPECT_EQ("top", BrowserThemeProvider::AlignmentToString(alignment)); - - // Verify that bad strings don't cause explosions. - alignment = BrowserThemeProvider::StringToAlignment("new zealandtop"); - EXPECT_EQ("", BrowserThemeProvider::AlignmentToString(alignment)); -} diff --git a/chrome/browser/themes/theme_service.cc b/chrome/browser/themes/theme_service.cc index eae2b76..1731b47 100644 --- a/chrome/browser/themes/theme_service.cc +++ b/chrome/browser/themes/theme_service.cc @@ -4,106 +4,641 @@ #include "chrome/browser/themes/theme_service.h" -#include "base/logging.h" +#include "base/string_split.h" +#include "base/string_util.h" +#include "base/utf_string_conversions.h" #include "chrome/browser/extensions/extension_service.h" +#include "chrome/browser/metrics/user_metrics.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/themes/browser_theme_provider.h" +#include "chrome/browser/themes/browser_theme_pack.h" +#include "chrome/common/chrome_constants.h" +#include "chrome/common/pref_names.h" #include "content/common/notification_service.h" +#include "content/common/notification_type.h" +#include "grit/app_resources.h" +#include "grit/theme_resources.h" +#include "ui/base/resource/resource_bundle.h" -#if defined(TOOLKIT_USES_GTK) -#include "chrome/browser/ui/gtk/gtk_theme_provider.h" +#if defined(OS_WIN) +#include "views/widget/widget_win.h" #endif -// static -BrowserThemeProvider* ThemeServiceFactory::GetForProfile(Profile* top_profile) { - // We may be asked for the Theme of an incognito profile. Make sure we're - // operating on the real profile. - Profile* profile = top_profile->GetOriginalProfile(); +// Strings used in alignment properties. +const char* ThemeService::kAlignmentTop = "top"; +const char* ThemeService::kAlignmentBottom = "bottom"; +const char* ThemeService::kAlignmentLeft = "left"; +const char* ThemeService::kAlignmentRight = "right"; + +// Strings used in background tiling repetition properties. +const char* ThemeService::kTilingNoRepeat = "no-repeat"; +const char* ThemeService::kTilingRepeatX = "repeat-x"; +const char* ThemeService::kTilingRepeatY = "repeat-y"; +const char* ThemeService::kTilingRepeat = "repeat"; + +// The default theme if we haven't installed a theme yet or if we've clicked +// the "Use Classic" button. +const char* ThemeService::kDefaultThemeID = ""; + +namespace { - ThemeServiceFactory* service = GetInstance(); +// The default theme if we've gone to the theme gallery and installed the +// "Default" theme. We have to detect this case specifically. (By the time we +// realize we've installed the default theme, we already have an extension +// unpacked on the filesystem.) +const char* kDefaultThemeGalleryID = "hkacjpbfdknhflllbcmjibkdeoafencn"; - std::map<Profile*, BrowserThemeProvider*>::const_iterator it = - service->mapping_.find(profile); - if (it != service->mapping_.end()) - return it->second; +SkColor TintForUnderline(SkColor input) { + return SkColorSetA(input, SkColorGetA(input) / 3); +} + +SkColor IncreaseLightness(SkColor color, double percent) { + color_utils::HSL result; + color_utils::SkColorToHSL(color, &result); + result.l += (1 - result.l) * percent; + return color_utils::HSLToSkColor(result, SkColorGetA(color)); +} - BrowserThemeProvider* provider = NULL; -#if defined(TOOLKIT_USES_GTK) - provider = new GtkThemeProvider; +// Default colors. +const SkColor kDefaultColorFrame = SkColorSetRGB(66, 116, 201); +const SkColor kDefaultColorFrameInactive = SkColorSetRGB(161, 182, 228); +const SkColor kDefaultColorFrameIncognito = SkColorSetRGB(83, 106, 139); +const SkColor kDefaultColorFrameIncognitoInactive = + SkColorSetRGB(126, 139, 156); +#if defined(OS_MACOSX) +const SkColor kDefaultColorToolbar = SkColorSetRGB(230, 230, 230); +#else +const SkColor kDefaultColorToolbar = SkColorSetRGB(223, 223, 223); +#endif +const SkColor kDefaultColorTabText = SK_ColorBLACK; +#if defined(OS_MACOSX) +const SkColor kDefaultColorBackgroundTabText = SK_ColorBLACK; +const SkColor kDefaultColorBookmarkText = SK_ColorBLACK; +#else +const SkColor kDefaultColorBackgroundTabText = SkColorSetRGB(64, 64, 64); +const SkColor kDefaultColorBookmarkText = SkColorSetRGB(18, 50, 114); +#endif +#if defined(OS_WIN) +const SkColor kDefaultColorNTPBackground = + color_utils::GetSysSkColor(COLOR_WINDOW); +const SkColor kDefaultColorNTPText = + color_utils::GetSysSkColor(COLOR_WINDOWTEXT); +const SkColor kDefaultColorNTPLink = + color_utils::GetSysSkColor(COLOR_HOTLIGHT); #else - provider = new BrowserThemeProvider; +// TODO(beng): source from theme provider. +const SkColor kDefaultColorNTPBackground = SK_ColorWHITE; +const SkColor kDefaultColorNTPText = SK_ColorBLACK; +const SkColor kDefaultColorNTPLink = SkColorSetRGB(6, 55, 116); +#endif +const SkColor kDefaultColorNTPHeader = SkColorSetRGB(150, 150, 150); +const SkColor kDefaultColorNTPSection = SkColorSetRGB(229, 229, 229); +const SkColor kDefaultColorNTPSectionText = SK_ColorBLACK; +const SkColor kDefaultColorNTPSectionLink = SkColorSetRGB(6, 55, 116); +const SkColor kDefaultColorControlBackground = SkColorSetARGB(0, 0, 0, 0); +const SkColor kDefaultColorButtonBackground = SkColorSetARGB(0, 0, 0, 0); +#if defined(OS_MACOSX) +const SkColor kDefaultColorToolbarButtonStroke = SkColorSetARGB(75, 81, 81, 81); +const SkColor kDefaultColorToolbarButtonStrokeInactive = + SkColorSetARGB(75, 99, 99, 99); +const SkColor kDefaultColorToolbarBezel = SkColorSetRGB(247, 247, 247); +const SkColor kDefaultColorToolbarStroke = SkColorSetRGB(103, 103, 103); +const SkColor kDefaultColorToolbarStrokeInactive = SkColorSetRGB(123, 123, 123); #endif - provider->Init(profile); - service->Associate(profile, provider); - return provider; +// Default tints. +const color_utils::HSL kDefaultTintButtons = { -1, -1, -1 }; +const color_utils::HSL kDefaultTintFrame = { -1, -1, -1 }; +const color_utils::HSL kDefaultTintFrameInactive = { -1, -1, 0.75f }; +const color_utils::HSL kDefaultTintFrameIncognito = { -1, 0.2f, 0.35f }; +const color_utils::HSL kDefaultTintFrameIncognitoInactive = { -1, 0.3f, 0.6f }; +const color_utils::HSL kDefaultTintBackgroundTab = { -1, 0.5, 0.75 }; + +// Default display properties. +const int kDefaultDisplayPropertyNTPAlignment = + ThemeService::ALIGN_BOTTOM; +const int kDefaultDisplayPropertyNTPTiling = + ThemeService::NO_REPEAT; +const int kDefaultDisplayPropertyNTPInverseLogo = 0; + +// The sum of kFrameBorderThickness and kNonClientRestoredExtraThickness from +// OpaqueBrowserFrameView. +const int kRestoredTabVerticalOffset = 15; + +// The image resources we will allow people to theme. +const int kThemeableImages[] = { + IDR_THEME_FRAME, + IDR_THEME_FRAME_INACTIVE, + IDR_THEME_FRAME_INCOGNITO, + IDR_THEME_FRAME_INCOGNITO_INACTIVE, + IDR_THEME_TOOLBAR, + IDR_THEME_TAB_BACKGROUND, + IDR_THEME_TAB_BACKGROUND_INCOGNITO, + IDR_THEME_TAB_BACKGROUND_V, + IDR_THEME_NTP_BACKGROUND, + IDR_THEME_FRAME_OVERLAY, + IDR_THEME_FRAME_OVERLAY_INACTIVE, + IDR_THEME_BUTTON_BACKGROUND, + IDR_THEME_NTP_ATTRIBUTION, + IDR_THEME_WINDOW_CONTROL_BACKGROUND +}; + +bool HasThemeableImage(int themeable_image_id) { + static std::set<int> themeable_images; + if (themeable_images.empty()) { + themeable_images.insert( + kThemeableImages, kThemeableImages + arraysize(kThemeableImages)); + } + return themeable_images.count(themeable_image_id) > 0; +} + +// The image resources that will be tinted by the 'button' tint value. +// If you change this list, you must increment the version number in +// browser_theme_pack.cc, and you should assign persistent IDs to the +// data table at the start of said file or else tinted versions of +// these resources will not be created. +const int kToolbarButtonIDs[] = { + IDR_BACK, IDR_BACK_D, IDR_BACK_H, IDR_BACK_P, + IDR_FORWARD, IDR_FORWARD_D, IDR_FORWARD_H, IDR_FORWARD_P, + IDR_HOME, IDR_HOME_H, IDR_HOME_P, + IDR_RELOAD, IDR_RELOAD_H, IDR_RELOAD_P, + IDR_STOP, IDR_STOP_D, IDR_STOP_H, IDR_STOP_P, + IDR_LOCATIONBG_C, IDR_LOCATIONBG_L, IDR_LOCATIONBG_R, + IDR_BROWSER_ACTIONS_OVERFLOW, IDR_BROWSER_ACTIONS_OVERFLOW_H, + IDR_BROWSER_ACTIONS_OVERFLOW_P, + IDR_TOOLS, IDR_TOOLS_H, IDR_TOOLS_P, + IDR_MENU_DROPARROW, + IDR_THROBBER, IDR_THROBBER_WAITING, IDR_THROBBER_LIGHT, +}; + +// Writes the theme pack to disk on a separate thread. +class WritePackToDiskTask : public Task { + public: + WritePackToDiskTask(BrowserThemePack* pack, const FilePath& path) + : theme_pack_(pack), pack_path_(path) {} + + virtual void Run() { + if (!theme_pack_->WriteToDisk(pack_path_)) { + NOTREACHED() << "Could not write theme pack to disk"; + } + } + + private: + scoped_refptr<BrowserThemePack> theme_pack_; + FilePath pack_path_; +}; + +} // namespace + +bool ThemeService::IsThemeableImage(int resource_id) { + return HasThemeableImage(resource_id); +} + +ThemeService::ThemeService() + : rb_(ResourceBundle::GetSharedInstance()), + profile_(NULL), + number_of_infobars_(0) { + // Initialize the themeable image map so we can use it on other threads. + HasThemeableImage(0); +} + +ThemeService::~ThemeService() { + FreePlatformCaches(); +} + +void ThemeService::Init(Profile* profile) { + DCHECK(CalledOnValidThread()); + profile_ = profile; + + LoadThemePrefs(); } -const Extension* ThemeServiceFactory::GetThemeForProfile(Profile* profile) { - std::string id = GetForProfile(profile)->GetThemeID(); - if (id == BrowserThemeProvider::kDefaultThemeID) - return NULL; +SkBitmap* ThemeService::GetBitmapNamed(int id) const { + DCHECK(CalledOnValidThread()); - return profile->GetExtensionService()->GetExtensionById(id, false); + SkBitmap* bitmap = NULL; + + if (theme_pack_.get()) + bitmap = theme_pack_->GetBitmapNamed(id); + + if (!bitmap) + bitmap = rb_.GetBitmapNamed(id); + + return bitmap; +} + +SkColor ThemeService::GetColor(int id) const { + DCHECK(CalledOnValidThread()); + + SkColor color; + if (theme_pack_.get() && theme_pack_->GetColor(id, &color)) + return color; + + // For backward compat with older themes, some newer colors are generated from + // older ones if they are missing. + switch (id) { + case COLOR_NTP_SECTION_HEADER_TEXT: + return IncreaseLightness(GetColor(COLOR_NTP_TEXT), 0.30); + case COLOR_NTP_SECTION_HEADER_TEXT_HOVER: + return GetColor(COLOR_NTP_TEXT); + case COLOR_NTP_SECTION_HEADER_RULE: + return IncreaseLightness(GetColor(COLOR_NTP_TEXT), 0.70); + case COLOR_NTP_SECTION_HEADER_RULE_LIGHT: + return IncreaseLightness(GetColor(COLOR_NTP_TEXT), 0.86); + case COLOR_NTP_TEXT_LIGHT: + return IncreaseLightness(GetColor(COLOR_NTP_TEXT), 0.40); + } + + return GetDefaultColor(id); } -void ThemeServiceFactory::ForceAssociationBetween(Profile* top_profile, - BrowserThemeProvider* provider) { - ThemeServiceFactory* service = GetInstance(); - Profile* profile = top_profile->GetOriginalProfile(); +bool ThemeService::GetDisplayProperty(int id, int* result) const { + if (theme_pack_.get()) + return theme_pack_->GetDisplayProperty(id, result); - service->Associate(profile, provider); + return GetDefaultDisplayProperty(id, result); } -ThemeServiceFactory* ThemeServiceFactory::GetInstance() { - return Singleton<ThemeServiceFactory>::get(); +bool ThemeService::ShouldUseNativeFrame() const { + if (HasCustomImage(IDR_THEME_FRAME)) + return false; +#if defined(OS_WIN) + return views::WidgetWin::IsAeroGlassEnabled(); +#else + return false; +#endif } -ThemeServiceFactory::ThemeServiceFactory() {} +bool ThemeService::HasCustomImage(int id) const { + if (!HasThemeableImage(id)) + return false; + + if (theme_pack_) + return theme_pack_->HasCustomImage(id); -ThemeServiceFactory::~ThemeServiceFactory() { - DCHECK(mapping_.empty()); + return false; } -void ThemeServiceFactory::Associate(Profile* profile, - BrowserThemeProvider* provider) { - DCHECK(mapping_.find(profile) == mapping_.end()); - mapping_.insert(std::make_pair(profile, provider)); +RefCountedMemory* ThemeService::GetRawData(int id) const { + // Check to see whether we should substitute some images. + int ntp_alternate; + GetDisplayProperty(NTP_LOGO_ALTERNATE, &ntp_alternate); + if (id == IDR_PRODUCT_LOGO && ntp_alternate != 0) + id = IDR_PRODUCT_LOGO_WHITE; - registrar_.Add(this, - NotificationType::PROFILE_DESTROYED, - Source<Profile>(profile)); - registrar_.Add(this, - NotificationType::THEME_INSTALLED, - Source<Profile>(profile)); + RefCountedMemory* data = NULL; + if (theme_pack_.get()) + data = theme_pack_->GetRawData(id); + if (!data) + data = rb_.LoadDataResourceBytes(id); + + return data; } -void ThemeServiceFactory::Observe(NotificationType type, - const NotificationSource& source, - const NotificationDetails& details) { - std::map<Profile*, BrowserThemeProvider*>::iterator it = - mapping_.find(Source<Profile>(source).ptr()); - DCHECK(it != mapping_.end()); +void ThemeService::SetTheme(const Extension* extension) { + // Clear our image cache. + FreePlatformCaches(); + + DCHECK(extension); + DCHECK(extension->is_theme()); - if (NotificationType::PROFILE_DESTROYED == type) { - delete it->second; - mapping_.erase(it); + BuildFromExtension(extension); + SaveThemeID(extension->id()); + + NotifyThemeChanged(extension); + UserMetrics::RecordAction(UserMetricsAction("Themes_Installed"), profile_); +} - // Remove ourselves from listening to all notifications because the source - // profile has been deleted. We have to do this because several unit tests - // are set up so a Profile is on the same place on the stack multiple - // times, so while they are different instances, they have the same - // addresses. - registrar_.Remove(this, - NotificationType::PROFILE_DESTROYED, - source); - registrar_.Remove(this, - NotificationType::THEME_INSTALLED, - source); - } else if (NotificationType::THEME_INSTALLED == type) { - const Extension* extension = Details<const Extension>(details).ptr(); - it->second->SetTheme(extension); - } else { - NOTREACHED(); +void ThemeService::RemoveUnusedThemes() { + if (!profile_) + return; + ExtensionService* service = profile_->GetExtensionService(); + if (!service) + return; + std::string current_theme = GetThemeID(); + std::vector<std::string> remove_list; + const ExtensionList* extensions = service->extensions(); + for (ExtensionList::const_iterator it = extensions->begin(); + it != extensions->end(); ++it) { + if ((*it)->is_theme() && (*it)->id() != current_theme) { + remove_list.push_back((*it)->id()); + } } + for (size_t i = 0; i < remove_list.size(); ++i) + service->UninstallExtension(remove_list[i], false); +} + +void ThemeService::UseDefaultTheme() { + ClearAllThemeData(); + NotifyThemeChanged(NULL); + UserMetrics::RecordAction(UserMetricsAction("Themes_Reset"), profile_); +} + +void ThemeService::SetNativeTheme() { + UseDefaultTheme(); +} + +bool ThemeService::UsingDefaultTheme() { + std::string id = GetThemeID(); + return id == ThemeService::kDefaultThemeID || + id == kDefaultThemeGalleryID; +} + +std::string ThemeService::GetThemeID() const { + return profile_->GetPrefs()->GetString(prefs::kCurrentThemeID); +} + +// static +std::string ThemeService::AlignmentToString(int alignment) { + // Convert from an AlignmentProperty back into a string. + std::string vertical_string; + std::string horizontal_string; + + if (alignment & ThemeService::ALIGN_TOP) + vertical_string = kAlignmentTop; + else if (alignment & ThemeService::ALIGN_BOTTOM) + vertical_string = kAlignmentBottom; + + if (alignment & ThemeService::ALIGN_LEFT) + horizontal_string = kAlignmentLeft; + else if (alignment & ThemeService::ALIGN_RIGHT) + horizontal_string = kAlignmentRight; + + if (vertical_string.empty()) + return horizontal_string; + if (horizontal_string.empty()) + return vertical_string; + return vertical_string + " " + horizontal_string; +} + +// static +int ThemeService::StringToAlignment(const std::string& alignment) { + std::vector<std::wstring> split; + base::SplitStringAlongWhitespace(UTF8ToWide(alignment), &split); + + int alignment_mask = 0; + for (std::vector<std::wstring>::iterator alignments(split.begin()); + alignments != split.end(); ++alignments) { + std::string comp = WideToUTF8(*alignments); + const char* component = comp.c_str(); + + if (base::strcasecmp(component, kAlignmentTop) == 0) + alignment_mask |= ThemeService::ALIGN_TOP; + else if (base::strcasecmp(component, kAlignmentBottom) == 0) + alignment_mask |= ThemeService::ALIGN_BOTTOM; + + if (base::strcasecmp(component, kAlignmentLeft) == 0) + alignment_mask |= ThemeService::ALIGN_LEFT; + else if (base::strcasecmp(component, kAlignmentRight) == 0) + alignment_mask |= ThemeService::ALIGN_RIGHT; + } + return alignment_mask; +} + +// static +std::string ThemeService::TilingToString(int tiling) { + // Convert from a TilingProperty back into a string. + if (tiling == ThemeService::REPEAT_X) + return kTilingRepeatX; + if (tiling == ThemeService::REPEAT_Y) + return kTilingRepeatY; + if (tiling == ThemeService::REPEAT) + return kTilingRepeat; + return kTilingNoRepeat; +} + +// static +int ThemeService::StringToTiling(const std::string& tiling) { + const char* component = tiling.c_str(); + + if (base::strcasecmp(component, kTilingRepeatX) == 0) + return ThemeService::REPEAT_X; + if (base::strcasecmp(component, kTilingRepeatY) == 0) + return ThemeService::REPEAT_Y; + if (base::strcasecmp(component, kTilingRepeat) == 0) + return ThemeService::REPEAT; + // NO_REPEAT is the default choice. + return ThemeService::NO_REPEAT; +} + +// static +color_utils::HSL ThemeService::GetDefaultTint(int id) { + switch (id) { + case TINT_FRAME: + return kDefaultTintFrame; + case TINT_FRAME_INACTIVE: + return kDefaultTintFrameInactive; + case TINT_FRAME_INCOGNITO: + return kDefaultTintFrameIncognito; + case TINT_FRAME_INCOGNITO_INACTIVE: + return kDefaultTintFrameIncognitoInactive; + case TINT_BUTTONS: + return kDefaultTintButtons; + case TINT_BACKGROUND_TAB: + return kDefaultTintBackgroundTab; + default: + color_utils::HSL result = {-1, -1, -1}; + return result; + } +} + +// static +SkColor ThemeService::GetDefaultColor(int id) { + switch (id) { + case COLOR_FRAME: + return kDefaultColorFrame; + case COLOR_FRAME_INACTIVE: + return kDefaultColorFrameInactive; + case COLOR_FRAME_INCOGNITO: + return kDefaultColorFrameIncognito; + case COLOR_FRAME_INCOGNITO_INACTIVE: + return kDefaultColorFrameIncognitoInactive; + case COLOR_TOOLBAR: + return kDefaultColorToolbar; + case COLOR_TAB_TEXT: + return kDefaultColorTabText; + case COLOR_BACKGROUND_TAB_TEXT: + return kDefaultColorBackgroundTabText; + case COLOR_BOOKMARK_TEXT: + return kDefaultColorBookmarkText; + case COLOR_NTP_BACKGROUND: + return kDefaultColorNTPBackground; + case COLOR_NTP_TEXT: + return kDefaultColorNTPText; + case COLOR_NTP_LINK: + return kDefaultColorNTPLink; + case COLOR_NTP_LINK_UNDERLINE: + return TintForUnderline(kDefaultColorNTPLink); + case COLOR_NTP_HEADER: + return kDefaultColorNTPHeader; + case COLOR_NTP_SECTION: + return kDefaultColorNTPSection; + case COLOR_NTP_SECTION_TEXT: + return kDefaultColorNTPSectionText; + case COLOR_NTP_SECTION_LINK: + return kDefaultColorNTPSectionLink; + case COLOR_NTP_SECTION_LINK_UNDERLINE: + return TintForUnderline(kDefaultColorNTPSectionLink); + case COLOR_CONTROL_BACKGROUND: + return kDefaultColorControlBackground; + case COLOR_BUTTON_BACKGROUND: + return kDefaultColorButtonBackground; +#if defined(OS_MACOSX) + case COLOR_TOOLBAR_BUTTON_STROKE: + return kDefaultColorToolbarButtonStroke; + case COLOR_TOOLBAR_BUTTON_STROKE_INACTIVE: + return kDefaultColorToolbarButtonStrokeInactive; + case COLOR_TOOLBAR_BEZEL: + return kDefaultColorToolbarBezel; + case COLOR_TOOLBAR_STROKE: + return kDefaultColorToolbarStroke; + case COLOR_TOOLBAR_STROKE_INACTIVE: + return kDefaultColorToolbarStrokeInactive; +#endif + default: + // Return a debugging red color. + return 0xffff0000; + } +} + +// static +bool ThemeService::GetDefaultDisplayProperty(int id, int* result) { + switch (id) { + case NTP_BACKGROUND_ALIGNMENT: + *result = kDefaultDisplayPropertyNTPAlignment; + return true; + case NTP_BACKGROUND_TILING: + *result = kDefaultDisplayPropertyNTPTiling; + return true; + case NTP_LOGO_ALTERNATE: + *result = kDefaultDisplayPropertyNTPInverseLogo; + return true; + } + + return false; +} + +// static +const std::set<int>& ThemeService::GetTintableToolbarButtons() { + static std::set<int> button_set; + if (button_set.empty()) { + button_set = std::set<int>( + kToolbarButtonIDs, + kToolbarButtonIDs + arraysize(kToolbarButtonIDs)); + } + + return button_set; +} + +color_utils::HSL ThemeService::GetTint(int id) const { + DCHECK(CalledOnValidThread()); + + color_utils::HSL hsl; + if (theme_pack_.get() && theme_pack_->GetTint(id, &hsl)) + return hsl; + + return GetDefaultTint(id); +} + +void ThemeService::ClearAllThemeData() { + // Clear our image cache. + FreePlatformCaches(); + theme_pack_ = NULL; + + profile_->GetPrefs()->ClearPref(prefs::kCurrentThemePackFilename); + SaveThemeID(kDefaultThemeID); +} + +void ThemeService::LoadThemePrefs() { + PrefService* prefs = profile_->GetPrefs(); + + std::string current_id = GetThemeID(); + if (current_id != kDefaultThemeID) { + bool loaded_pack = false; + + // If we don't have a file pack, we're updating from an old version. + FilePath path = prefs->GetFilePath(prefs::kCurrentThemePackFilename); + if (path != FilePath()) { + theme_pack_ = BrowserThemePack::BuildFromDataPack(path, current_id); + loaded_pack = theme_pack_.get() != NULL; + } + + if (loaded_pack) { + UserMetrics::RecordAction(UserMetricsAction("Themes.Loaded"), profile_); + } else { + // TODO(erg): We need to pop up a dialog informing the user that their + // theme is being migrated. + ExtensionService* service = profile_->GetExtensionService(); + if (service) { + const Extension* extension = + service->GetExtensionById(current_id, false); + if (extension) { + DLOG(ERROR) << "Migrating theme"; + BuildFromExtension(extension); + UserMetrics::RecordAction(UserMetricsAction("Themes.Migrated"), + profile_); + } else { + DLOG(ERROR) << "Theme is mysteriously gone."; + ClearAllThemeData(); + UserMetrics::RecordAction(UserMetricsAction("Themes.Gone"), profile_); + } + } + } + } +} + +void ThemeService::NotifyThemeChanged(const Extension* extension) { + VLOG(1) << "Sending BROWSER_THEME_CHANGED"; + // Redraw! + NotificationService* service = NotificationService::current(); + service->Notify(NotificationType::BROWSER_THEME_CHANGED, + Source<ThemeService>(this), + Details<const Extension>(extension)); +#if defined(OS_MACOSX) + NotifyPlatformThemeChanged(); +#endif // OS_MACOSX +} + +#if defined(OS_WIN) +void ThemeService::FreePlatformCaches() { + // Views (Skia) has no platform image cache to clear. +} +#endif + +void ThemeService::SavePackName(const FilePath& pack_path) { + profile_->GetPrefs()->SetFilePath( + prefs::kCurrentThemePackFilename, pack_path); +} + +void ThemeService::SaveThemeID(const std::string& id) { + profile_->GetPrefs()->SetString(prefs::kCurrentThemeID, id); +} + +void ThemeService::BuildFromExtension(const Extension* extension) { + scoped_refptr<BrowserThemePack> pack( + BrowserThemePack::BuildFromExtension(extension)); + if (!pack.get()) { + // TODO(erg): We've failed to install the theme; perhaps we should tell the + // user? http://crbug.com/34780 + LOG(ERROR) << "Could not load theme."; + return; + } + + // Write the packed file to disk. + FilePath pack_path = extension->path().Append(chrome::kThemePackFilename); + BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, + new WritePackToDiskTask(pack, pack_path)); + + SavePackName(pack_path); + theme_pack_ = pack; +} + +void ThemeService::OnInfobarDisplayed() { + number_of_infobars_++; +} + +void ThemeService::OnInfobarDestroyed() { + number_of_infobars_--; + + if (number_of_infobars_ == 0) + RemoveUnusedThemes(); } diff --git a/chrome/browser/themes/theme_service.h b/chrome/browser/themes/theme_service.h index 44abcc2..672bbf0 100644 --- a/chrome/browser/themes/theme_service.h +++ b/chrome/browser/themes/theme_service.h @@ -4,56 +4,285 @@ #ifndef CHROME_BROWSER_THEMES_THEME_SERVICE_H_ #define CHROME_BROWSER_THEMES_THEME_SERVICE_H_ +#pragma once #include <map> +#include <set> +#include <string> -#include "base/singleton.h" -#include "content/common/notification_observer.h" -#include "content/common/notification_registrar.h" +#include "base/ref_counted.h" +#include "base/threading/non_thread_safe.h" +#include "ui/base/theme_provider.h" -class BrowserThemeProvider; +class BrowserThemePack; +class ThemeServiceTest; class Extension; +class FilePath; class Profile; -// Singleton that owns all BrowserThemeProviders and associates them with -// Profiles. Listens for the Profile's destruction notification and cleans up -// the associated BrowserThemeProvider. -class ThemeServiceFactory : public NotificationObserver { +namespace color_utils { +struct HSL; +} + +namespace ui { +class ResourceBundle; +} +using ui::ResourceBundle; + +#ifdef __OBJC__ +@class NSString; +// Sent whenever the browser theme changes. Object => NSValue wrapping the +// ThemeService that changed. +extern "C" NSString* const kBrowserThemeDidChangeNotification; +#endif // __OBJC__ + +class ThemeService : public base::NonThreadSafe, + public ui::ThemeProvider { public: - // Returns the BrowserThemeProvider that provides theming resources for - // |profile|. Note that even if a Profile doesn't have a theme installed, it - // still needs a BrowserThemeProvider to hand back the default theme images. - static BrowserThemeProvider* GetForProfile(Profile* profile); + // Public constants used in ThemeService and its subclasses: + + // Strings used in alignment properties. + static const char* kAlignmentTop; + static const char* kAlignmentBottom; + static const char* kAlignmentLeft; + static const char* kAlignmentRight; + + // Strings used in tiling properties. + static const char* kTilingNoRepeat; + static const char* kTilingRepeatX; + static const char* kTilingRepeatY; + static const char* kTilingRepeat; + + static const char* kDefaultThemeID; + + // Returns true if the image is themeable. Safe to call on any thread. + static bool IsThemeableImage(int resource_id); + + ThemeService(); + virtual ~ThemeService(); + + enum { + COLOR_FRAME, + COLOR_FRAME_INACTIVE, + COLOR_FRAME_INCOGNITO, + COLOR_FRAME_INCOGNITO_INACTIVE, + COLOR_TOOLBAR, + COLOR_TAB_TEXT, + COLOR_BACKGROUND_TAB_TEXT, + COLOR_BOOKMARK_TEXT, + COLOR_NTP_BACKGROUND, + COLOR_NTP_TEXT, + COLOR_NTP_LINK, + COLOR_NTP_LINK_UNDERLINE, + COLOR_NTP_HEADER, + COLOR_NTP_SECTION, + COLOR_NTP_SECTION_TEXT, + COLOR_NTP_SECTION_LINK, + COLOR_NTP_SECTION_LINK_UNDERLINE, + COLOR_CONTROL_BACKGROUND, + COLOR_BUTTON_BACKGROUND, + + // These colors don't have constant default values. They are derived from + // the runtime value of other colors. + COLOR_NTP_SECTION_HEADER_TEXT, + COLOR_NTP_SECTION_HEADER_TEXT_HOVER, + COLOR_NTP_SECTION_HEADER_RULE, + COLOR_NTP_SECTION_HEADER_RULE_LIGHT, + COLOR_NTP_TEXT_LIGHT, + + TINT_BUTTONS, + TINT_FRAME, + TINT_FRAME_INACTIVE, + TINT_FRAME_INCOGNITO, + TINT_FRAME_INCOGNITO_INACTIVE, + TINT_BACKGROUND_TAB, + NTP_BACKGROUND_ALIGNMENT, + NTP_BACKGROUND_TILING, + NTP_LOGO_ALTERNATE +#if defined(OS_MACOSX) + , + COLOR_TOOLBAR_BEZEL = 1000, + COLOR_TOOLBAR_STROKE, + COLOR_TOOLBAR_STROKE_INACTIVE, + COLOR_TOOLBAR_BUTTON_STROKE, + COLOR_TOOLBAR_BUTTON_STROKE_INACTIVE, + GRADIENT_FRAME_INCOGNITO, + GRADIENT_FRAME_INCOGNITO_INACTIVE, + GRADIENT_TOOLBAR, + GRADIENT_TOOLBAR_INACTIVE, + GRADIENT_TOOLBAR_BUTTON, + GRADIENT_TOOLBAR_BUTTON_INACTIVE, + GRADIENT_TOOLBAR_BUTTON_PRESSED, + GRADIENT_TOOLBAR_BUTTON_PRESSED_INACTIVE +#endif // OS_MACOSX + }; + + // A bitfield mask for alignments. + typedef enum { + ALIGN_CENTER = 0x0, + ALIGN_LEFT = 0x1, + ALIGN_TOP = 0x2, + ALIGN_RIGHT = 0x4, + ALIGN_BOTTOM = 0x8, + } AlignmentMasks; + + // Background tiling choices. + typedef enum { + NO_REPEAT = 0, + REPEAT_X = 1, + REPEAT_Y = 2, + REPEAT = 3 + } Tiling; + + // ui::ThemeProvider implementation. + virtual void Init(Profile* profile); + virtual SkBitmap* GetBitmapNamed(int id) const; + virtual SkColor GetColor(int id) const; + virtual bool GetDisplayProperty(int id, int* result) const; + virtual bool ShouldUseNativeFrame() const; + virtual bool HasCustomImage(int id) const; + virtual RefCountedMemory* GetRawData(int id) const; +#if defined(TOOLKIT_USES_GTK) + // GdkPixbufs returned by GetPixbufNamed and GetRTLEnabledPixbufNamed are + // shared instances owned by the theme provider and should not be freed. + virtual GdkPixbuf* GetPixbufNamed(int id) const; + virtual GdkPixbuf* GetRTLEnabledPixbufNamed(int id) const; +#elif defined(OS_MACOSX) + virtual NSImage* GetNSImageNamed(int id, bool allow_default) const; + virtual NSColor* GetNSImageColorNamed(int id, bool allow_default) const; + virtual NSColor* GetNSColor(int id, bool allow_default) const; + virtual NSColor* GetNSColorTint(int id, bool allow_default) const; + virtual NSGradient* GetNSGradient(int id) const; +#endif + + // Set the current theme to the theme defined in |extension|. + virtual void SetTheme(const Extension* extension); + + // Reset the theme to default. + virtual void UseDefaultTheme(); + + // Set the current theme to the native theme. On some platforms, the native + // theme is the default theme. + virtual void SetNativeTheme(); + + // Whether we're using the chrome default theme. Virtual so linux can check + // if we're using the GTK theme. + virtual bool UsingDefaultTheme(); + + // Gets the id of the last installed theme. (The theme may have been further + // locally customized.) + virtual std::string GetThemeID() const; + + // This class needs to keep track of the number of theme infobars so that we + // clean up unused themes. + void OnInfobarDisplayed(); + + // Decrements the number of theme infobars. If the last infobar has been + // destroyed, uninstalls all themes that aren't the currently selected. + void OnInfobarDestroyed(); - // Returns the Extension that implements the theme associated with - // |profile|. Returns NULL if the theme is no longer installed, if there is - // no installed theme, or the theme was cleared. - static const Extension* GetThemeForProfile(Profile* profile); + // Convert a bitfield alignment into a string like "top left". Public so that + // it can be used to generate CSS values. Takes a bitfield of AlignmentMasks. + static std::string AlignmentToString(int alignment); - // Forces an association between |profile| and |provider|. Used in unit tests - // where we need to mock BrowserThemeProvider. - static void ForceAssociationBetween(Profile* profile, - BrowserThemeProvider* provider); + // Parse alignments from something like "top left" into a bitfield of + // AlignmentMasks + static int StringToAlignment(const std::string& alignment); - static ThemeServiceFactory* GetInstance(); + // Convert a tiling value into a string like "no-repeat". Public + // so that it can be used to generate CSS values. Takes a Tiling. + static std::string TilingToString(int tiling); + + // Parse tiling values from something like "no-repeat" into a Tiling value. + static int StringToTiling(const std::string& tiling); + + // Returns the default tint for the given tint |id| TINT_* enum value. + static color_utils::HSL GetDefaultTint(int id); + + // Returns the default color for the given color |id| COLOR_* enum value. + static SkColor GetDefaultColor(int id); + + // Returns true and sets |result| to the requested default property, if |id| + // is valid. + static bool GetDefaultDisplayProperty(int id, int* result); + + // Returns the set of IDR_* resources that should be tinted. + static const std::set<int>& GetTintableToolbarButtons(); + + // Remove preference values for themes that are no longer in use. + void RemoveUnusedThemes(); + + // Save the images to be written to disk, mapping file path to id. + typedef std::map<FilePath, int> ImagesDiskCache; + + protected: + // Get the specified tint - |id| is one of the TINT_* enum values. + color_utils::HSL GetTint(int id) const; + + // Clears all the override fields and saves the dictionary. + virtual void ClearAllThemeData(); + + // Load theme data from preferences. + virtual void LoadThemePrefs(); + + // Let all the browser views know that themes have changed. + // extension is NULL iff the theme is being set to the + // default/system theme. + virtual void NotifyThemeChanged(const Extension* extension); + +#if defined(OS_MACOSX) + // Let all the browser views know that themes have changed in a platform way. + virtual void NotifyPlatformThemeChanged(); +#endif // OS_MACOSX + + // Clears the platform-specific caches. Do not call directly; it's called + // from ClearCaches(). + virtual void FreePlatformCaches(); + + Profile* profile() { return profile_; } private: - friend struct DefaultSingletonTraits<ThemeServiceFactory>; + friend class ThemeServiceTest; + + // Saves the filename of the cached theme pack. + void SavePackName(const FilePath& pack_path); + + // Save the id of the last theme installed. + void SaveThemeID(const std::string& id); + + // Implementation of SetTheme() (and the fallback from LoadThemePrefs() in + // case we don't have a theme pack). + void BuildFromExtension(const Extension* extension); + +#if defined(TOOLKIT_USES_GTK) + // Loads an image and flips it horizontally if |rtl_enabled| is true. + GdkPixbuf* GetPixbufImpl(int id, bool rtl_enabled) const; +#endif + +#if defined(TOOLKIT_USES_GTK) + typedef std::map<int, GdkPixbuf*> GdkPixbufMap; + mutable GdkPixbufMap gdk_pixbufs_; +#elif defined(OS_MACOSX) + typedef std::map<int, NSImage*> NSImageMap; + mutable NSImageMap nsimage_cache_; + + // The bool member of the pair is whether the color is a default color. + typedef std::map<int, std::pair<NSColor*, bool> > NSColorMap; + mutable NSColorMap nscolor_cache_; + + typedef std::map<int, NSGradient*> NSGradientMap; + mutable NSGradientMap nsgradient_cache_; +#endif - ThemeServiceFactory(); - ~ThemeServiceFactory(); + ResourceBundle& rb_; + Profile* profile_; - // Maps |profile| to |provider| and listens for notifications relating to - // either. - void Associate(Profile* profile, BrowserThemeProvider* provider); + scoped_refptr<BrowserThemePack> theme_pack_; - // NotificationObserver: - virtual void Observe(NotificationType type, - const NotificationSource& source, - const NotificationDetails& details); + // The number of infobars currently displayed. + int number_of_infobars_; - NotificationRegistrar registrar_; - std::map<Profile*, BrowserThemeProvider*> mapping_; + DISALLOW_COPY_AND_ASSIGN(ThemeService); }; #endif // CHROME_BROWSER_THEMES_THEME_SERVICE_H_ diff --git a/chrome/browser/themes/theme_service_factory.cc b/chrome/browser/themes/theme_service_factory.cc new file mode 100644 index 0000000..f93b838 --- /dev/null +++ b/chrome/browser/themes/theme_service_factory.cc @@ -0,0 +1,109 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/themes/theme_service_factory.h" + +#include "base/logging.h" +#include "chrome/browser/extensions/extension_service.h" +#include "chrome/browser/profiles/profile.h" +#include "chrome/browser/themes/theme_service.h" +#include "content/common/notification_service.h" + +#if defined(TOOLKIT_USES_GTK) +#include "chrome/browser/ui/gtk/gtk_theme_service.h" +#endif + +// static +ThemeService* ThemeServiceFactory::GetForProfile(Profile* top_profile) { + // We may be asked for the Theme of an incognito profile. Make sure we're + // operating on the real profile. + Profile* profile = top_profile->GetOriginalProfile(); + + ThemeServiceFactory* service = GetInstance(); + + std::map<Profile*, ThemeService*>::const_iterator it = + service->mapping_.find(profile); + if (it != service->mapping_.end()) + return it->second; + + ThemeService* provider = NULL; +#if defined(TOOLKIT_USES_GTK) + provider = new GtkThemeService; +#else + provider = new ThemeService; +#endif + provider->Init(profile); + + service->Associate(profile, provider); + return provider; +} + +const Extension* ThemeServiceFactory::GetThemeForProfile(Profile* profile) { + std::string id = GetForProfile(profile)->GetThemeID(); + if (id == ThemeService::kDefaultThemeID) + return NULL; + + return profile->GetExtensionService()->GetExtensionById(id, false); +} + +void ThemeServiceFactory::ForceAssociationBetween(Profile* top_profile, + ThemeService* provider) { + ThemeServiceFactory* service = GetInstance(); + Profile* profile = top_profile->GetOriginalProfile(); + + service->Associate(profile, provider); +} + +ThemeServiceFactory* ThemeServiceFactory::GetInstance() { + return Singleton<ThemeServiceFactory>::get(); +} + +ThemeServiceFactory::ThemeServiceFactory() {} + +ThemeServiceFactory::~ThemeServiceFactory() { + DCHECK(mapping_.empty()); +} + +void ThemeServiceFactory::Associate(Profile* profile, + ThemeService* provider) { + DCHECK(mapping_.find(profile) == mapping_.end()); + mapping_.insert(std::make_pair(profile, provider)); + + registrar_.Add(this, + NotificationType::PROFILE_DESTROYED, + Source<Profile>(profile)); + registrar_.Add(this, + NotificationType::THEME_INSTALLED, + Source<Profile>(profile)); +} + +void ThemeServiceFactory::Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details) { + std::map<Profile*, ThemeService*>::iterator it = + mapping_.find(Source<Profile>(source).ptr()); + DCHECK(it != mapping_.end()); + + if (NotificationType::PROFILE_DESTROYED == type) { + delete it->second; + mapping_.erase(it); + + // Remove ourselves from listening to all notifications because the source + // profile has been deleted. We have to do this because several unit tests + // are set up so a Profile is on the same place on the stack multiple + // times, so while they are different instances, they have the same + // addresses. + registrar_.Remove(this, + NotificationType::PROFILE_DESTROYED, + source); + registrar_.Remove(this, + NotificationType::THEME_INSTALLED, + source); + } else if (NotificationType::THEME_INSTALLED == type) { + const Extension* extension = Details<const Extension>(details).ptr(); + it->second->SetTheme(extension); + } else { + NOTREACHED(); + } +} diff --git a/chrome/browser/themes/theme_service_factory.h b/chrome/browser/themes/theme_service_factory.h new file mode 100644 index 0000000..8211130 --- /dev/null +++ b/chrome/browser/themes/theme_service_factory.h @@ -0,0 +1,59 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_THEMES_THEME_SERVICE_FACTORY_H_ +#define CHROME_BROWSER_THEMES_THEME_SERVICE_FACTORY_H_ + +#include <map> + +#include "base/singleton.h" +#include "content/common/notification_observer.h" +#include "content/common/notification_registrar.h" + +class ThemeService; +class Extension; +class Profile; + +// Singleton that owns all ThemeServices and associates them with +// Profiles. Listens for the Profile's destruction notification and cleans up +// the associated ThemeService. +class ThemeServiceFactory : public NotificationObserver { + public: + // Returns the ThemeService that provides theming resources for + // |profile|. Note that even if a Profile doesn't have a theme installed, it + // still needs a ThemeService to hand back the default theme images. + static ThemeService* GetForProfile(Profile* profile); + + // Returns the Extension that implements the theme associated with + // |profile|. Returns NULL if the theme is no longer installed, if there is + // no installed theme, or the theme was cleared. + static const Extension* GetThemeForProfile(Profile* profile); + + // Forces an association between |profile| and |provider|. Used in unit tests + // where we need to mock ThemeService. + static void ForceAssociationBetween(Profile* profile, + ThemeService* provider); + + static ThemeServiceFactory* GetInstance(); + + private: + friend struct DefaultSingletonTraits<ThemeServiceFactory>; + + ThemeServiceFactory(); + ~ThemeServiceFactory(); + + // Maps |profile| to |provider| and listens for notifications relating to + // either. + void Associate(Profile* profile, ThemeService* provider); + + // NotificationObserver: + virtual void Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details); + + NotificationRegistrar registrar_; + std::map<Profile*, ThemeService*> mapping_; +}; + +#endif // CHROME_BROWSER_THEMES_THEME_SERVICE_FACTORY_H_ diff --git a/chrome/browser/themes/browser_theme_provider_gtk.cc b/chrome/browser/themes/theme_service_gtk.cc index 52be010..e9d33bc 100644 --- a/chrome/browser/themes/browser_theme_provider_gtk.cc +++ b/chrome/browser/themes/theme_service_gtk.cc @@ -1,8 +1,8 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/themes/browser_theme_provider.h" +#include "chrome/browser/themes/theme_service.h" #include <gdk-pixbuf/gdk-pixbuf.h> @@ -11,15 +11,15 @@ #include "third_party/skia/include/core/SkBitmap.h" #include "ui/gfx/gtk_util.h" -GdkPixbuf* BrowserThemeProvider::GetPixbufNamed(int id) const { +GdkPixbuf* ThemeService::GetPixbufNamed(int id) const { return GetPixbufImpl(id, false); } -GdkPixbuf* BrowserThemeProvider::GetRTLEnabledPixbufNamed(int id) const { +GdkPixbuf* ThemeService::GetRTLEnabledPixbufNamed(int id) const { return GetPixbufImpl(id, true); } -GdkPixbuf* BrowserThemeProvider::GetPixbufImpl(int id, bool rtl_enabled) const { +GdkPixbuf* ThemeService::GetPixbufImpl(int id, bool rtl_enabled) const { DCHECK(CalledOnValidThread()); // Use the negative |resource_id| for the key for BIDI-aware images. int key = rtl_enabled ? -id : id; @@ -61,7 +61,7 @@ GdkPixbuf* BrowserThemeProvider::GetPixbufImpl(int id, bool rtl_enabled) const { return empty_bitmap; } -void BrowserThemeProvider::FreePlatformCaches() { +void ThemeService::FreePlatformCaches() { DCHECK(CalledOnValidThread()); // Free GdkPixbufs. diff --git a/chrome/browser/themes/browser_theme_provider_mac.mm b/chrome/browser/themes/theme_service_mac.mm index 887f625..30d359e 100644 --- a/chrome/browser/themes/browser_theme_provider_mac.mm +++ b/chrome/browser/themes/theme_service_mac.mm @@ -1,8 +1,8 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/themes/browser_theme_provider.h" +#include "chrome/browser/themes/theme_service.h" #import <Cocoa/Cocoa.h> @@ -27,10 +27,9 @@ void HSLToHSB(const color_utils::HSL& hsl, CGFloat* h, CGFloat* s, CGFloat* b) { *b = SkScalarToDouble(hsv[2]); } -} +} // namespace -NSImage* BrowserThemeProvider::GetNSImageNamed(int id, - bool allow_default) const { +NSImage* ThemeService::GetNSImageNamed(int id, bool allow_default) const { DCHECK(CalledOnValidThread()); if (!allow_default && !HasCustomImage(id)) @@ -73,8 +72,7 @@ NSImage* BrowserThemeProvider::GetNSImageNamed(int id, return empty_image; } -NSColor* BrowserThemeProvider::GetNSImageColorNamed(int id, - bool allow_default) const { +NSColor* ThemeService::GetNSImageColorNamed(int id, bool allow_default) const { DCHECK(CalledOnValidThread()); // Check to see if we already have the color in the cache. @@ -99,8 +97,7 @@ NSColor* BrowserThemeProvider::GetNSImageColorNamed(int id, return image_color; } -NSColor* BrowserThemeProvider::GetNSColor(int id, - bool allow_default) const { +NSColor* ThemeService::GetNSColor(int id, bool allow_default) const { DCHECK(CalledOnValidThread()); // Check to see if we already have the color in the cache. @@ -136,8 +133,7 @@ NSColor* BrowserThemeProvider::GetNSColor(int id, return color; } -NSColor* BrowserThemeProvider::GetNSColorTint(int id, - bool allow_default) const { +NSColor* ThemeService::GetNSColorTint(int id, bool allow_default) const { DCHECK(CalledOnValidThread()); // Check to see if we already have the color in the cache. @@ -180,7 +176,7 @@ NSColor* BrowserThemeProvider::GetNSColorTint(int id, return tint_color; } -NSGradient* BrowserThemeProvider::GetNSGradient(int id) const { +NSGradient* ThemeService::GetNSGradient(int id) const { DCHECK(CalledOnValidThread()); // Check to see if we already have the gradient in the cache. @@ -285,13 +281,13 @@ NSGradient* BrowserThemeProvider::GetNSGradient(int id) const { } // Let all the browser views know that themes have changed in a platform way. -void BrowserThemeProvider::NotifyPlatformThemeChanged() { +void ThemeService::NotifyPlatformThemeChanged() { NSNotificationCenter* defaultCenter = [NSNotificationCenter defaultCenter]; [defaultCenter postNotificationName:kBrowserThemeDidChangeNotification object:[NSValue valueWithPointer:this]]; } -void BrowserThemeProvider::FreePlatformCaches() { +void ThemeService::FreePlatformCaches() { DCHECK(CalledOnValidThread()); // Free images. diff --git a/chrome/browser/themes/theme_service_unittest.cc b/chrome/browser/themes/theme_service_unittest.cc new file mode 100644 index 0000000..7b39c2e --- /dev/null +++ b/chrome/browser/themes/theme_service_unittest.cc @@ -0,0 +1,51 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/themes/theme_service.h" + +#include "base/json/json_reader.h" +#include "testing/gtest/include/gtest/gtest.h" + +TEST(ThemeServiceTest, AlignmentConversion) { + // Verify that we get out what we put in. + std::string top_left = "top left"; + int alignment = ThemeService::StringToAlignment(top_left); + EXPECT_EQ(ThemeService::ALIGN_TOP | ThemeService::ALIGN_LEFT, + alignment); + EXPECT_EQ(top_left, ThemeService::AlignmentToString(alignment)); + + alignment = ThemeService::StringToAlignment("top"); + EXPECT_EQ(ThemeService::ALIGN_TOP, alignment); + EXPECT_EQ("top", ThemeService::AlignmentToString(alignment)); + + alignment = ThemeService::StringToAlignment("left"); + EXPECT_EQ(ThemeService::ALIGN_LEFT, alignment); + EXPECT_EQ("left", ThemeService::AlignmentToString(alignment)); + + alignment = ThemeService::StringToAlignment("right"); + EXPECT_EQ(ThemeService::ALIGN_RIGHT, alignment); + EXPECT_EQ("right", ThemeService::AlignmentToString(alignment)); + + alignment = ThemeService::StringToAlignment("righttopbottom"); + EXPECT_EQ(ThemeService::ALIGN_CENTER, alignment); + EXPECT_EQ("", ThemeService::AlignmentToString(alignment)); +} + +TEST(ThemeServiceTest, AlignmentConversionInput) { + // Verify that we output in an expected format. + int alignment = ThemeService::StringToAlignment("right bottom"); + EXPECT_EQ("bottom right", ThemeService::AlignmentToString(alignment)); + + // Verify that bad strings don't cause explosions. + alignment = ThemeService::StringToAlignment("new zealand"); + EXPECT_EQ("", ThemeService::AlignmentToString(alignment)); + + // Verify that bad strings don't cause explosions. + alignment = ThemeService::StringToAlignment("new zealand top"); + EXPECT_EQ("top", ThemeService::AlignmentToString(alignment)); + + // Verify that bad strings don't cause explosions. + alignment = ThemeService::StringToAlignment("new zealandtop"); + EXPECT_EQ("", ThemeService::AlignmentToString(alignment)); +} diff --git a/chrome/browser/ui/browser_window.h b/chrome/browser/ui/browser_window.h index 86ddc67..ea54e3c 100644 --- a/chrome/browser/ui/browser_window.h +++ b/chrome/browser/ui/browser_window.h @@ -250,7 +250,7 @@ class BrowserWindow { virtual void ShowHTMLDialog(HtmlDialogUIDelegate* delegate, gfx::NativeWindow parent_window) = 0; - // BrowserThemeProvider calls this when a user has changed his or her theme, + // ThemeService calls this when a user has changed his or her theme, // indicating that it's time to redraw everything. virtual void UserChangedTheme() = 0; diff --git a/chrome/browser/ui/cocoa/background_gradient_view.mm b/chrome/browser/ui/cocoa/background_gradient_view.mm index 7b031a2..8ebf7ae 100644 --- a/chrome/browser/ui/cocoa/background_gradient_view.mm +++ b/chrome/browser/ui/cocoa/background_gradient_view.mm @@ -1,10 +1,10 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/ui/cocoa/background_gradient_view.h" -#import "chrome/browser/themes/browser_theme_provider.h" +#import "chrome/browser/themes/theme_service.h" #import "chrome/browser/ui/cocoa/themed_window.h" #include "grit/theme_resources.h" @@ -43,8 +43,8 @@ } else { CGFloat winHeight = NSHeight([[self window] frame]); NSGradient* gradient = themeProvider->GetNSGradient( - isKey ? BrowserThemeProvider::GRADIENT_TOOLBAR : - BrowserThemeProvider::GRADIENT_TOOLBAR_INACTIVE); + isKey ? ThemeService::GRADIENT_TOOLBAR : + ThemeService::GRADIENT_TOOLBAR_INACTIVE); NSPoint startPoint = [self convertPoint:NSMakePoint(0, winHeight - kToolbarTopOffset) fromView:nil]; @@ -74,8 +74,8 @@ if (!themeProvider) return [NSColor blackColor]; return themeProvider->GetNSColor( - isKey ? BrowserThemeProvider::COLOR_TOOLBAR_STROKE : - BrowserThemeProvider::COLOR_TOOLBAR_STROKE_INACTIVE, true); + isKey ? ThemeService::COLOR_TOOLBAR_STROKE : + ThemeService::COLOR_TOOLBAR_STROKE_INACTIVE, true); } @end diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.mm b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.mm index 594a8bf..ea1f77a 100644 --- a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.mm +++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.mm @@ -14,8 +14,8 @@ #include "chrome/browser/metrics/user_metrics.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" -#import "chrome/browser/themes/browser_theme_provider.h" #import "chrome/browser/themes/theme_service.h" +#import "chrome/browser/themes/theme_service_factory.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_list.h" #import "chrome/browser/ui/cocoa/background_gradient_view.h" @@ -1131,7 +1131,7 @@ void RecordAppLaunch(Profile* profile, GURL url) { ui::ThemeProvider* themeProvider = [[[self view] window] themeProvider]; if (themeProvider) { NSColor* color = - themeProvider->GetNSColor(BrowserThemeProvider::COLOR_BOOKMARK_TEXT, + themeProvider->GetNSColor(ThemeService::COLOR_BOOKMARK_TEXT, true); [cell setTextColor:color]; } @@ -1615,7 +1615,7 @@ void RecordAppLaunch(Profile* profile, GURL url) { if (!themeProvider) return; NSColor* color = - themeProvider->GetNSColor(BrowserThemeProvider::COLOR_BOOKMARK_TEXT, + themeProvider->GetNSColor(ThemeService::COLOR_BOOKMARK_TEXT, true); for (BookmarkButton* button in buttons_.get()) { BookmarkButtonCell* cell = [button cell]; diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_button_cell.h b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_button_cell.h index f599e0a..f768e27 100644 --- a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_button_cell.h +++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_button_cell.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -20,7 +20,7 @@ class BookmarkNode; } // Create a button cell which draws without a theme and with a frame -// color provided by the BrowserThemeProvider defaults. +// color provided by the ThemeService defaults. + (id)buttonCellForNode:(const BookmarkNode*)node contextMenu:(NSMenu*)contextMenu cellText:(NSString*)cellText diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.mm b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.mm index 96dd3ff2..d637271 100644 --- a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.mm +++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.mm @@ -8,7 +8,6 @@ #include "base/sys_string_conversions.h" #include "chrome/browser/bookmarks/bookmark_model.h" #include "chrome/browser/bookmarks/bookmark_utils.h" -#import "chrome/browser/themes/browser_theme_provider.h" #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_constants.h" #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_button_cell.h" @@ -18,6 +17,7 @@ #import "chrome/browser/ui/cocoa/bookmarks/bookmark_folder_target.h" #import "chrome/browser/ui/cocoa/browser_window_controller.h" #import "chrome/browser/ui/cocoa/event_utils.h" +#include "ui/base/theme_provider.h" using bookmarks::kBookmarkBarMenuCornerRadius; diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_view_unittest.mm b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_view_unittest.mm index 07aca2b..1eda2f5 100644 --- a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_view_unittest.mm +++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_view_unittest.mm @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_toolbar_view.mm b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_toolbar_view.mm index c277370..1060e59 100644 --- a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_toolbar_view.mm +++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_toolbar_view.mm @@ -1,11 +1,11 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_toolbar_view.h" #include "chrome/browser/ntp_background_util.h" -#include "chrome/browser/themes/browser_theme_provider.h" +#include "chrome/browser/themes/theme_service.h" #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_constants.h" #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" #import "chrome/browser/ui/cocoa/browser_window_controller.h" @@ -95,7 +95,7 @@ const CGFloat kBorderRadius = 3.0; // Draw the rounded rectangle. NSColor* toolbarColor = - themeProvider->GetNSColor(BrowserThemeProvider::COLOR_TOOLBAR, true); + themeProvider->GetNSColor(ThemeService::COLOR_TOOLBAR, true); CGFloat alpha = morph * [toolbarColor alphaComponent]; [[toolbarColor colorWithAlphaComponent:alpha] set]; // Set with opacity. [border fill]; @@ -113,7 +113,7 @@ const CGFloat kBorderRadius = 3.0; // Draw the border of the rounded rectangle. NSColor* borderColor = themeProvider->GetNSColor( - BrowserThemeProvider::COLOR_TOOLBAR_BUTTON_STROKE, true); + ThemeService::COLOR_TOOLBAR_BUTTON_STROKE, true); alpha = morph * [borderColor alphaComponent]; [[borderColor colorWithAlphaComponent:alpha] set]; // Set with opacity. [border stroke]; diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_toolbar_view_unittest.mm b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_toolbar_view_unittest.mm index ef8bfc8..17cdcec 100644 --- a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_toolbar_view_unittest.mm +++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_toolbar_view_unittest.mm @@ -1,11 +1,11 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #import <Cocoa/Cocoa.h> #include "base/scoped_nsobject.h" -#include "chrome/browser/themes/browser_theme_provider.h" +#include "chrome/browser/themes/theme_service.h" #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_toolbar_view.h" #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" @@ -133,7 +133,7 @@ TEST_F(BookmarkBarToolbarViewTest, DisplayAsDetachedBarWithNoImage) { // Tests where we don't have a background image, only a color. MockThemeProvider provider; - EXPECT_CALL(provider, GetColor(BrowserThemeProvider::COLOR_NTP_BACKGROUND)) + EXPECT_CALL(provider, GetColor(ThemeService::COLOR_NTP_BACKGROUND)) .WillRepeatedly(Return(SK_ColorWHITE)); EXPECT_CALL(provider, HasCustomImage(IDR_THEME_NTP_BACKGROUND)) .WillRepeatedly(Return(false)); @@ -144,12 +144,12 @@ TEST_F(BookmarkBarToolbarViewTest, DisplayAsDetachedBarWithNoImage) { // Actions used in DisplayAsDetachedBarWithBgImage. ACTION(SetBackgroundTiling) { - *arg1 = BrowserThemeProvider::NO_REPEAT; + *arg1 = ThemeService::NO_REPEAT; return true; } ACTION(SetAlignLeft) { - *arg1 = BrowserThemeProvider::ALIGN_LEFT; + *arg1 = ThemeService::ALIGN_LEFT; return true; } @@ -161,17 +161,17 @@ TEST_F(BookmarkBarToolbarViewTest, DisplayAsDetachedBarWithBgImage) { MockThemeProvider provider; // Advertise having an image. - EXPECT_CALL(provider, GetColor(BrowserThemeProvider::COLOR_NTP_BACKGROUND)) + EXPECT_CALL(provider, GetColor(ThemeService::COLOR_NTP_BACKGROUND)) .WillRepeatedly(Return(SK_ColorRED)); EXPECT_CALL(provider, HasCustomImage(IDR_THEME_NTP_BACKGROUND)) .WillRepeatedly(Return(true)); // Return the correct tiling/alignment information. EXPECT_CALL(provider, - GetDisplayProperty(BrowserThemeProvider::NTP_BACKGROUND_TILING, _)) + GetDisplayProperty(ThemeService::NTP_BACKGROUND_TILING, _)) .WillRepeatedly(SetBackgroundTiling()); EXPECT_CALL(provider, - GetDisplayProperty(BrowserThemeProvider::NTP_BACKGROUND_ALIGNMENT, _)) + GetDisplayProperty(ThemeService::NTP_BACKGROUND_ALIGNMENT, _)) .WillRepeatedly(SetAlignLeft()); // Create a dummy bitmap full of not-red to blit with. diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_view.mm b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_view.mm index d66a3a7..ca78cac 100644 --- a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_view.mm +++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_view.mm @@ -11,7 +11,7 @@ #import "chrome/browser/ui/cocoa/bookmarks/bookmark_folder_target.h" #import "chrome/browser/ui/cocoa/themed_window.h" #import "chrome/browser/ui/cocoa/view_id_util.h" -#import "chrome/browser/themes/browser_theme_provider.h" +#import "chrome/browser/themes/theme_service.h" #import "third_party/mozilla/NSPasteboard+Utils.h" @interface BookmarkBarView (Private) @@ -83,7 +83,7 @@ return; NSColor* color = - themeProvider->GetNSColor(BrowserThemeProvider::COLOR_BOOKMARK_TEXT, + themeProvider->GetNSColor(ThemeService::COLOR_BOOKMARK_TEXT, true); [noItemTextfield_ setTextColor:color]; } diff --git a/chrome/browser/ui/cocoa/browser_frame_view.mm b/chrome/browser/ui/cocoa/browser_frame_view.mm index 4b6980b..e487cc4 100644 --- a/chrome/browser/ui/cocoa/browser_frame_view.mm +++ b/chrome/browser/ui/cocoa/browser_frame_view.mm @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -9,7 +9,7 @@ #include "base/logging.h" #include "base/mac/scoped_nsautorelease_pool.h" -#import "chrome/browser/themes/browser_theme_provider.h" +#import "chrome/browser/themes/theme_service.h" #import "chrome/browser/ui/cocoa/framed_browser_window.h" #import "chrome/browser/ui/cocoa/themed_window.h" #include "grit/theme_resources.h" @@ -248,8 +248,8 @@ static BOOL gCanGetCornerRadius = NO; NSGradient* gradient = nil; if (!themeImageColor && incognito) gradient = themeProvider->GetNSGradient( - active ? BrowserThemeProvider::GRADIENT_FRAME_INCOGNITO : - BrowserThemeProvider::GRADIENT_FRAME_INCOGNITO_INACTIVE); + active ? ThemeService::GRADIENT_FRAME_INCOGNITO : + ThemeService::GRADIENT_FRAME_INCOGNITO_INACTIVE); BOOL themed = NO; if (themeImageColor) { @@ -336,10 +336,10 @@ static BOOL gCanGetCornerRadius = NO; NSColor* titleColor = nil; if (popup && active) { titleColor = themeProvider->GetNSColor( - BrowserThemeProvider::COLOR_TAB_TEXT, false); + ThemeService::COLOR_TAB_TEXT, false); } else if (popup && !active) { titleColor = themeProvider->GetNSColor( - BrowserThemeProvider::COLOR_BACKGROUND_TAB_TEXT, false); + ThemeService::COLOR_BACKGROUND_TAB_TEXT, false); } if (titleColor) diff --git a/chrome/browser/ui/cocoa/browser_window_controller.mm b/chrome/browser/ui/cocoa/browser_window_controller.mm index f01a883..e9ffedb 100644 --- a/chrome/browser/ui/cocoa/browser_window_controller.mm +++ b/chrome/browser/ui/cocoa/browser_window_controller.mm @@ -19,8 +19,8 @@ #include "chrome/browser/sync/sync_ui_util_mac.h" #include "chrome/browser/tab_contents/tab_contents_view_mac.h" #include "chrome/browser/tabs/tab_strip_model.h" -#include "chrome/browser/themes/browser_theme_provider.h" #include "chrome/browser/themes/theme_service.h" +#include "chrome/browser/themes/theme_service_factory.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_list.h" #import "chrome/browser/ui/cocoa/background_gradient_view.h" diff --git a/chrome/browser/ui/cocoa/browser_window_controller_private.mm b/chrome/browser/ui/cocoa/browser_window_controller_private.mm index 5f49c6e6..f1cf08b 100644 --- a/chrome/browser/ui/cocoa/browser_window_controller_private.mm +++ b/chrome/browser/ui/cocoa/browser_window_controller_private.mm @@ -8,7 +8,6 @@ #include "chrome/browser/browser_process.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/themes/browser_theme_provider.h" #include "chrome/browser/ui/browser_list.h" #import "chrome/browser/ui/cocoa/fast_resize_view.h" #import "chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.h" diff --git a/chrome/browser/ui/cocoa/bubble_view.mm b/chrome/browser/ui/cocoa/bubble_view.mm index 0b92f39..9892ecd 100644 --- a/chrome/browser/ui/cocoa/bubble_view.mm +++ b/chrome/browser/ui/cocoa/bubble_view.mm @@ -1,10 +1,10 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #import "chrome/browser/ui/cocoa/bubble_view.h" -#include "chrome/browser/themes/browser_theme_provider.h" +#include "chrome/browser/themes/theme_service.h" #import "chrome/browser/ui/cocoa/themed_window.h" #import "third_party/GTM/AppKit/GTMNSBezierPath+RoundRect.h" #import "third_party/GTM/AppKit/GTMNSColor+Luminance.h" @@ -90,7 +90,7 @@ const float kWindowEdge = 0.7f; bottomRightCornerRadius:bottomRightRadius]; if (themeProvider) - [themeProvider->GetNSColor(BrowserThemeProvider::COLOR_TOOLBAR, true) set]; + [themeProvider->GetNSColor(ThemeService::COLOR_TOOLBAR, true) set]; [border fill]; [[NSColor colorWithDeviceWhite:kWindowEdge alpha:1.0f] set]; @@ -99,7 +99,7 @@ const float kWindowEdge = 0.7f; // Text NSColor* textColor = [NSColor blackColor]; if (themeProvider) - textColor = themeProvider->GetNSColor(BrowserThemeProvider::COLOR_TAB_TEXT, + textColor = themeProvider->GetNSColor(ThemeService::COLOR_TAB_TEXT, true); NSFont* textFont = [self font]; scoped_nsobject<NSShadow> textShadow([[NSShadow alloc] init]); diff --git a/chrome/browser/ui/cocoa/chrome_browser_window.mm b/chrome/browser/ui/cocoa/chrome_browser_window.mm index cceeb14..e21507b 100644 --- a/chrome/browser/ui/cocoa/chrome_browser_window.mm +++ b/chrome/browser/ui/cocoa/chrome_browser_window.mm @@ -1,12 +1,12 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #import "chrome/browser/ui/cocoa/chrome_browser_window.h" #include "base/logging.h" -#include "chrome/browser/themes/browser_theme_provider.h" #import "chrome/browser/ui/cocoa/themed_window.h" +#include "ui/base/theme_provider.h" @implementation ChromeBrowserWindow diff --git a/chrome/browser/ui/cocoa/download/download_item_cell.mm b/chrome/browser/ui/cocoa/download/download_item_cell.mm index 37e300a..93d1461 100644 --- a/chrome/browser/ui/cocoa/download/download_item_cell.mm +++ b/chrome/browser/ui/cocoa/download/download_item_cell.mm @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -9,7 +9,7 @@ #include "chrome/browser/download/download_item_model.h" #include "chrome/browser/download/download_manager.h" #include "chrome/browser/download/download_util.h" -#import "chrome/browser/themes/browser_theme_provider.h" +#import "chrome/browser/themes/theme_service.h" #import "chrome/browser/ui/cocoa/download/download_item_cell.h" #import "chrome/browser/ui/cocoa/image_utils.h" #import "chrome/browser/ui/cocoa/themed_window.h" @@ -142,7 +142,7 @@ NSColor* BackgroundTheme::GetNSColor(int id, bool allow_default) const { } NSColor* BackgroundTheme::GetNSColorTint(int id, bool allow_default) const { - if (id == BrowserThemeProvider::TINT_BUTTONS) + if (id == ThemeService::TINT_BUTTONS) return borderColor_.get(); return provider_->GetNSColorTint(id, allow_default); @@ -150,11 +150,11 @@ NSColor* BackgroundTheme::GetNSColorTint(int id, bool allow_default) const { NSGradient* BackgroundTheme::GetNSGradient(int id) const { switch (id) { - case BrowserThemeProvider::GRADIENT_TOOLBAR_BUTTON: - case BrowserThemeProvider::GRADIENT_TOOLBAR_BUTTON_INACTIVE: + case ThemeService::GRADIENT_TOOLBAR_BUTTON: + case ThemeService::GRADIENT_TOOLBAR_BUTTON_INACTIVE: return buttonGradient_.get(); - case BrowserThemeProvider::GRADIENT_TOOLBAR_BUTTON_PRESSED: - case BrowserThemeProvider::GRADIENT_TOOLBAR_BUTTON_PRESSED_INACTIVE: + case ThemeService::GRADIENT_TOOLBAR_BUTTON_PRESSED: + case ThemeService::GRADIENT_TOOLBAR_BUTTON_PRESSED_INACTIVE: return buttonPressedGradient_.get(); default: return provider_->GetNSGradient(id); @@ -435,7 +435,7 @@ NSGradient* BackgroundTheme::GetNSGradient(int id) const { ui::ThemeProvider* themeProvider = [[[self controlView] window] themeProvider]; NSColor* themeTextColor = - themeProvider->GetNSColor(BrowserThemeProvider::COLOR_BOOKMARK_TEXT, + themeProvider->GetNSColor(ThemeService::COLOR_BOOKMARK_TEXT, true); return [self pressedWithDefaultThemeOnPart:part] ? [NSColor alternateSelectedControlTextColor] : themeTextColor; @@ -491,8 +491,8 @@ NSGradient* BackgroundTheme::GetNSGradient(int id) const { if (!isDefaultTheme) { themeProvider = [self backgroundThemeWrappingProvider:themeProvider]; bgGradient = themeProvider->GetNSGradient( - active ? BrowserThemeProvider::GRADIENT_TOOLBAR_BUTTON : - BrowserThemeProvider::GRADIENT_TOOLBAR_BUTTON_INACTIVE); + active ? ThemeService::GRADIENT_TOOLBAR_BUTTON : + ThemeService::GRADIENT_TOOLBAR_BUTTON_INACTIVE); } NSRect buttonDrawRect, dropdownDrawRect; diff --git a/chrome/browser/ui/cocoa/download/download_item_controller.mm b/chrome/browser/ui/cocoa/download/download_item_controller.mm index 60eb845..c2ca719 100644 --- a/chrome/browser/ui/cocoa/download/download_item_controller.mm +++ b/chrome/browser/ui/cocoa/download/download_item_controller.mm @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -14,7 +14,7 @@ #include "chrome/browser/download/download_item_model.h" #include "chrome/browser/download/download_shelf.h" #include "chrome/browser/download/download_util.h" -#import "chrome/browser/themes/browser_theme_provider.h" +#import "chrome/browser/themes/theme_service.h" #import "chrome/browser/ui/cocoa/download/download_item_button.h" #import "chrome/browser/ui/cocoa/download/download_item_cell.h" #include "chrome/browser/ui/cocoa/download/download_item_mac.h" @@ -332,7 +332,7 @@ class DownloadShelfContextMenuMac : public DownloadShelfContextMenu { // this is shown for the first time. - (void)updateTheme:(ui::ThemeProvider*)themeProvider { NSColor* color = - themeProvider->GetNSColor(BrowserThemeProvider::COLOR_TAB_TEXT, true); + themeProvider->GetNSColor(ThemeService::COLOR_TAB_TEXT, true); [dangerousDownloadLabel_ setTextColor:color]; } diff --git a/chrome/browser/ui/cocoa/download/download_shelf_controller.mm b/chrome/browser/ui/cocoa/download/download_shelf_controller.mm index 2c82d67..8324d9d 100644 --- a/chrome/browser/ui/cocoa/download/download_shelf_controller.mm +++ b/chrome/browser/ui/cocoa/download/download_shelf_controller.mm @@ -9,8 +9,8 @@ #include "chrome/browser/download/download_item.h" #include "chrome/browser/download/download_manager.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/themes/browser_theme_provider.h" #include "chrome/browser/themes/theme_service.h" +#include "chrome/browser/themes/theme_service_factory.h" #include "chrome/browser/ui/browser.h" #import "chrome/browser/ui/cocoa/animatable_view.h" #include "chrome/browser/ui/cocoa/browser_window_cocoa.h" @@ -167,7 +167,7 @@ const NSTimeInterval kAutoCloseDelaySeconds = 5; ThemeServiceFactory::GetForProfile(bridge_->browser()->profile()); color = - provider->GetNSColor(BrowserThemeProvider::COLOR_BOOKMARK_TEXT, false); + provider->GetNSColor(ThemeService::COLOR_BOOKMARK_TEXT, false); } if (!color) diff --git a/chrome/browser/ui/cocoa/download/download_shelf_view.mm b/chrome/browser/ui/cocoa/download/download_shelf_view.mm index 55b88d5..417b4c3 100644 --- a/chrome/browser/ui/cocoa/download/download_shelf_view.mm +++ b/chrome/browser/ui/cocoa/download/download_shelf_view.mm @@ -1,11 +1,11 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #import "chrome/browser/ui/cocoa/download/download_shelf_view.h" #include "base/scoped_nsobject.h" -#include "chrome/browser/themes/browser_theme_provider.h" +#include "chrome/browser/themes/theme_service.h" #import "chrome/browser/ui/cocoa/themed_window.h" #import "chrome/browser/ui/cocoa/view_id_util.h" #include "grit/theme_resources.h" @@ -16,8 +16,8 @@ BOOL isKey = [[self window] isKeyWindow]; ui::ThemeProvider* themeProvider = [[self window] themeProvider]; return themeProvider ? themeProvider->GetNSColor( - isKey ? BrowserThemeProvider::COLOR_TOOLBAR_STROKE : - BrowserThemeProvider::COLOR_TOOLBAR_STROKE_INACTIVE, true) : + isKey ? ThemeService::COLOR_TOOLBAR_STROKE : + ThemeService::COLOR_TOOLBAR_STROKE_INACTIVE, true) : [NSColor blackColor]; } @@ -38,8 +38,8 @@ NSRectFill([self bounds]); } else { NSGradient* gradient = themeProvider->GetNSGradient( - isKey ? BrowserThemeProvider::GRADIENT_TOOLBAR : - BrowserThemeProvider::GRADIENT_TOOLBAR_INACTIVE); + isKey ? ThemeService::GRADIENT_TOOLBAR : + ThemeService::GRADIENT_TOOLBAR_INACTIVE); NSPoint startPoint = [self convertPoint:NSMakePoint(0, 0) fromView:nil]; NSPoint endPoint = [self convertPoint:NSMakePoint(0, [self frame].size.height) diff --git a/chrome/browser/ui/cocoa/framed_browser_window.mm b/chrome/browser/ui/cocoa/framed_browser_window.mm index 30064cb..fff26f2 100644 --- a/chrome/browser/ui/cocoa/framed_browser_window.mm +++ b/chrome/browser/ui/cocoa/framed_browser_window.mm @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -11,7 +11,7 @@ #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" #import "chrome/browser/ui/cocoa/themed_window.h" #import "chrome/browser/renderer_host/render_widget_host_view_mac.h" -#include "chrome/browser/themes/browser_theme_provider.h" +#include "chrome/browser/themes/theme_service.h" namespace { // Size of the gradient. Empirically determined so that the gradient looks diff --git a/chrome/browser/ui/cocoa/fullscreen_window.mm b/chrome/browser/ui/cocoa/fullscreen_window.mm index ee4b881..586dbfa 100644 --- a/chrome/browser/ui/cocoa/fullscreen_window.mm +++ b/chrome/browser/ui/cocoa/fullscreen_window.mm @@ -1,10 +1,9 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #import "chrome/browser/ui/cocoa/fullscreen_window.h" -#include "chrome/browser/themes/browser_theme_provider.h" #import "chrome/browser/ui/cocoa/themed_window.h" @implementation FullscreenWindow diff --git a/chrome/browser/ui/cocoa/gradient_button_cell.mm b/chrome/browser/ui/cocoa/gradient_button_cell.mm index 86f4bfe..5d376ce 100644 --- a/chrome/browser/ui/cocoa/gradient_button_cell.mm +++ b/chrome/browser/ui/cocoa/gradient_button_cell.mm @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -6,7 +6,7 @@ #include "base/logging.h" #import "base/scoped_nsobject.h" -#import "chrome/browser/themes/browser_theme_provider.h" +#import "chrome/browser/themes/theme_service.h" #import "chrome/browser/ui/cocoa/image_utils.h" #import "chrome/browser/ui/cocoa/themed_window.h" #include "grit/theme_resources.h" @@ -392,8 +392,8 @@ static const NSTimeInterval kAnimationContinuousCycleDuration = 0.4; } else { clickedGradient = themeProvider ? themeProvider->GetNSGradient( active ? - BrowserThemeProvider::GRADIENT_TOOLBAR_BUTTON_PRESSED : - BrowserThemeProvider::GRADIENT_TOOLBAR_BUTTON_PRESSED_INACTIVE) : + ThemeService::GRADIENT_TOOLBAR_BUTTON_PRESSED : + ThemeService::GRADIENT_TOOLBAR_BUTTON_PRESSED_INACTIVE) : nil; } [clickedGradient drawInBezierPath:innerPath angle:90.0]; @@ -438,8 +438,8 @@ static const NSTimeInterval kAnimationContinuousCycleDuration = 0.4; alpha:0.3 * outerStrokeAlphaMult_]; } else { strokeColor = themeProvider ? themeProvider->GetNSColor( - active ? BrowserThemeProvider::COLOR_TOOLBAR_BUTTON_STROKE : - BrowserThemeProvider::COLOR_TOOLBAR_BUTTON_STROKE_INACTIVE, + active ? ThemeService::COLOR_TOOLBAR_BUTTON_STROKE : + ThemeService::COLOR_TOOLBAR_BUTTON_STROKE_INACTIVE, true) : [NSColor colorWithCalibratedWhite:0.0 alpha:0.3 * outerStrokeAlphaMult_]; } @@ -551,8 +551,8 @@ static const NSTimeInterval kAnimationContinuousCycleDuration = 0.4; NSRect borderRect, contentRect; NSDivideRect(cellFrame, &borderRect, &contentRect, 1.0, NSMaxXEdge); NSColor* stroke = themeProvider ? themeProvider->GetNSColor( - active ? BrowserThemeProvider::COLOR_TOOLBAR_BUTTON_STROKE : - BrowserThemeProvider::COLOR_TOOLBAR_BUTTON_STROKE_INACTIVE, + active ? ThemeService::COLOR_TOOLBAR_BUTTON_STROKE : + ThemeService::COLOR_TOOLBAR_BUTTON_STROKE_INACTIVE, true) : [NSColor blackColor]; [[stroke colorWithAlphaComponent:0.2] set]; @@ -571,17 +571,17 @@ static const NSTimeInterval kAnimationContinuousCycleDuration = 0.4; CGContextRef context = (CGContextRef)([[NSGraphicsContext currentContext] graphicsPort]); - BrowserThemeProvider* themeProvider = static_cast<BrowserThemeProvider*>( + ThemeService* themeProvider = static_cast<ThemeService*>( [[controlView window] themeProvider]); NSColor* color = themeProvider ? - themeProvider->GetNSColorTint(BrowserThemeProvider::TINT_BUTTONS, + themeProvider->GetNSColorTint(ThemeService::TINT_BUTTONS, true) : [NSColor blackColor]; if (isTemplate && themeProvider && themeProvider->UsingDefaultTheme()) { scoped_nsobject<NSShadow> shadow([[NSShadow alloc] init]); [shadow.get() setShadowColor:themeProvider->GetNSColor( - BrowserThemeProvider::COLOR_TOOLBAR_BEZEL, true)]; + ThemeService::COLOR_TOOLBAR_BEZEL, true)]; [shadow.get() setShadowOffset:NSMakeSize(0.0, -1.0)]; [shadow setShadowBlurRadius:1.0]; [shadow set]; diff --git a/chrome/browser/ui/cocoa/infobars/infobar_gradient_view.mm b/chrome/browser/ui/cocoa/infobars/infobar_gradient_view.mm index 70e1bb3..f8662a8 100644 --- a/chrome/browser/ui/cocoa/infobars/infobar_gradient_view.mm +++ b/chrome/browser/ui/cocoa/infobars/infobar_gradient_view.mm @@ -5,7 +5,7 @@ #include "chrome/browser/ui/cocoa/infobars/infobar_gradient_view.h" #include "base/scoped_nsobject.h" -#import "chrome/browser/themes/browser_theme_provider.h" +#import "chrome/browser/themes/theme_service.h" #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" #import "chrome/browser/ui/cocoa/themed_window.h" @@ -50,8 +50,8 @@ const double kBackgroundColorBottom[3] = BOOL active = [[self window] isMainWindow]; return themeProvider->GetNSColor( - active ? BrowserThemeProvider::COLOR_TOOLBAR_STROKE : - BrowserThemeProvider::COLOR_TOOLBAR_STROKE_INACTIVE, + active ? ThemeService::COLOR_TOOLBAR_STROKE : + ThemeService::COLOR_TOOLBAR_STROKE_INACTIVE, true); } diff --git a/chrome/browser/ui/cocoa/styled_text_field_cell.mm b/chrome/browser/ui/cocoa/styled_text_field_cell.mm index 46fcd8b..b4dcdcd 100644 --- a/chrome/browser/ui/cocoa/styled_text_field_cell.mm +++ b/chrome/browser/ui/cocoa/styled_text_field_cell.mm @@ -1,11 +1,11 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #import "chrome/browser/ui/cocoa/styled_text_field_cell.h" #include "base/logging.h" -#include "chrome/browser/themes/browser_theme_provider.h" +#include "chrome/browser/themes/theme_service.h" #import "chrome/browser/ui/cocoa/themed_window.h" #include "grit/theme_resources.h" #import "third_party/GTM/AppKit/GTMNSBezierPath+RoundRect.h" @@ -147,8 +147,8 @@ private: // Paint button background image if there is one (otherwise the border won't // look right). - BrowserThemeProvider* themeProvider = - static_cast<BrowserThemeProvider*>([[controlView window] themeProvider]); + ThemeService* themeProvider = + static_cast<ThemeService*>([[controlView window] themeProvider]); if (themeProvider) { NSColor* backgroundImageColor = themeProvider->GetNSImageColorNamed(IDR_THEME_BUTTON_BACKGROUND, false); @@ -167,8 +167,8 @@ private: // Draw the outer stroke (over the background). BOOL active = [[controlView window] isMainWindow]; NSColor* strokeColor = themeProvider->GetNSColor( - active ? BrowserThemeProvider::COLOR_TOOLBAR_BUTTON_STROKE : - BrowserThemeProvider::COLOR_TOOLBAR_BUTTON_STROKE_INACTIVE, + active ? ThemeService::COLOR_TOOLBAR_BUTTON_STROKE : + ThemeService::COLOR_TOOLBAR_BUTTON_STROKE_INACTIVE, true); FrameRectWithInset(roundedFlags, frame, 0.0, radius, 1.0, strokeColor); } @@ -195,7 +195,7 @@ private: themeProvider->UsingDefaultTheme()) { [themeProvider->GetNSColor( - BrowserThemeProvider::COLOR_TOOLBAR_BEZEL, true) set]; + ThemeService::COLOR_TOOLBAR_BEZEL, true) set]; NSRect bezelRect = NSMakeRect(cellFrame.origin.x, NSMaxY(cellFrame) - 0.5, NSWidth(cellFrame), diff --git a/chrome/browser/ui/cocoa/tabs/tab_controller.mm b/chrome/browser/ui/cocoa/tabs/tab_controller.mm index 7a12dc9..41daafa 100644 --- a/chrome/browser/ui/cocoa/tabs/tab_controller.mm +++ b/chrome/browser/ui/cocoa/tabs/tab_controller.mm @@ -3,7 +3,7 @@ // found in the LICENSE file. #include "base/mac/mac_util.h" -#import "chrome/browser/themes/browser_theme_provider.h" +#import "chrome/browser/themes/theme_service.h" #import "chrome/browser/ui/cocoa/menu_controller.h" #import "chrome/browser/ui/cocoa/tabs/tab_controller.h" #import "chrome/browser/ui/cocoa/tabs/tab_controller_target.h" @@ -271,12 +271,12 @@ class MenuDelegate : public ui::SimpleMenuModel::Delegate { ui::ThemeProvider* theme = [[[self view] window] themeProvider]; if (theme && ![self selected]) { titleColor = - theme->GetNSColor(BrowserThemeProvider::COLOR_BACKGROUND_TAB_TEXT, + theme->GetNSColor(ThemeService::COLOR_BACKGROUND_TAB_TEXT, true); } // Default to the selected text color unless told otherwise. if (theme && !titleColor) { - titleColor = theme->GetNSColor(BrowserThemeProvider::COLOR_TAB_TEXT, + titleColor = theme->GetNSColor(ThemeService::COLOR_TAB_TEXT, true); } [titleView_ setTextColor:titleColor ? titleColor : [NSColor textColor]]; diff --git a/chrome/browser/ui/cocoa/tabs/tab_strip_view.mm b/chrome/browser/ui/cocoa/tabs/tab_strip_view.mm index a8a15a4..2418d9b 100644 --- a/chrome/browser/ui/cocoa/tabs/tab_strip_view.mm +++ b/chrome/browser/ui/cocoa/tabs/tab_strip_view.mm @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -6,7 +6,7 @@ #include "base/logging.h" #include "base/mac/mac_util.h" -#include "chrome/browser/themes/browser_theme_provider.h" +#include "chrome/browser/themes/theme_service.h" #import "chrome/browser/ui/cocoa/browser_window_controller.h" #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" #import "chrome/browser/ui/cocoa/view_id_util.h" @@ -43,15 +43,15 @@ NSRectFillUsingOperation(borderRect, NSCompositeSourceOver); NSDivideRect(bounds, &borderRect, &contentRect, 1, NSMinYEdge); - BrowserThemeProvider* themeProvider = - static_cast<BrowserThemeProvider*>([[self window] themeProvider]); + ThemeService* themeProvider = + static_cast<ThemeService*>([[self window] themeProvider]); if (!themeProvider) return; NSColor* bezelColor = themeProvider->GetNSColor( themeProvider->UsingDefaultTheme() ? - BrowserThemeProvider::COLOR_TOOLBAR_BEZEL : - BrowserThemeProvider::COLOR_TOOLBAR, true); + ThemeService::COLOR_TOOLBAR_BEZEL : + ThemeService::COLOR_TOOLBAR, true); [bezelColor set]; NSRectFill(borderRect); NSRectFillUsingOperation(borderRect, NSCompositeSourceOver); diff --git a/chrome/browser/ui/cocoa/tabs/tab_view.mm b/chrome/browser/ui/cocoa/tabs/tab_view.mm index 1659d42..85799f4 100644 --- a/chrome/browser/ui/cocoa/tabs/tab_view.mm +++ b/chrome/browser/ui/cocoa/tabs/tab_view.mm @@ -7,7 +7,7 @@ #include "base/logging.h" #import "base/mac/mac_util.h" #include "base/mac/scoped_cftyperef.h" -#include "chrome/browser/themes/browser_theme_provider.h" +#include "chrome/browser/themes/theme_service.h" #import "chrome/browser/ui/cocoa/tabs/tab_controller.h" #import "chrome/browser/ui/cocoa/tabs/tab_window_controller.h" #import "chrome/browser/ui/cocoa/themed_window.h" @@ -625,8 +625,8 @@ const CGFloat kRapidCloseDist = 2.5; NSGraphicsContext* context = [NSGraphicsContext currentContext]; [context saveGraphicsState]; - BrowserThemeProvider* themeProvider = - static_cast<BrowserThemeProvider*>([[self window] themeProvider]); + ThemeService* themeProvider = + static_cast<ThemeService*>([[self window] themeProvider]); [context setPatternPhase:[[self window] themePatternPhase]]; NSRect rect = [self bounds]; @@ -717,8 +717,8 @@ const CGFloat kRapidCloseDist = 2.5; NSColor* borderColor = [NSColor colorWithDeviceWhite:0.0 alpha:borderAlpha]; NSColor* highlightColor = themeProvider ? themeProvider->GetNSColor( themeProvider->UsingDefaultTheme() ? - BrowserThemeProvider::COLOR_TOOLBAR_BEZEL : - BrowserThemeProvider::COLOR_TOOLBAR, true) : nil; + ThemeService::COLOR_TOOLBAR_BEZEL : + ThemeService::COLOR_TOOLBAR, true) : nil; // Draw the top inner highlight within the currently selected tab if using // the default theme. diff --git a/chrome/browser/ui/cocoa/toolbar/toolbar_controller.mm b/chrome/browser/ui/cocoa/toolbar/toolbar_controller.mm index c14c5d9..a7141a9 100644 --- a/chrome/browser/ui/cocoa/toolbar/toolbar_controller.mm +++ b/chrome/browser/ui/cocoa/toolbar/toolbar_controller.mm @@ -19,7 +19,7 @@ #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/search_engines/template_url_model.h" -#include "chrome/browser/themes/browser_theme_provider.h" +#include "chrome/browser/themes/theme_service.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_window.h" #import "chrome/browser/ui/cocoa/accelerators_cocoa.h" diff --git a/chrome/browser/ui/gtk/about_chrome_dialog.cc b/chrome/browser/ui/gtk/about_chrome_dialog.cc index 49909c6..f46f0e1 100644 --- a/chrome/browser/ui/gtk/about_chrome_dialog.cc +++ b/chrome/browser/ui/gtk/about_chrome_dialog.cc @@ -16,7 +16,7 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/gtk/cairo_cached_surface.h" #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h" -#include "chrome/browser/ui/gtk/gtk_theme_provider.h" +#include "chrome/browser/ui/gtk/gtk_theme_service.h" #include "chrome/browser/ui/gtk/gtk_util.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_version_info.h" @@ -84,8 +84,8 @@ gboolean OnEventBoxExpose(GtkWidget* event_box, cairo_t* cr = gdk_cairo_create(GDK_DRAWABLE(event_box->window)); gdk_cairo_rectangle(cr, &expose->area); cairo_clip(cr); - GtkThemeProvider* theme_provider = - GtkThemeProvider::GetFrom(BrowserList::GetLastActive()->profile()); + GtkThemeService* theme_provider = + GtkThemeService::GetFrom(BrowserList::GetLastActive()->profile()); CairoCachedSurface* background = theme_provider->GetSurfaceNamed( IDR_ABOUT_BACKGROUND_COLOR, event_box); diff --git a/chrome/browser/ui/gtk/back_forward_button_gtk.cc b/chrome/browser/ui/gtk/back_forward_button_gtk.cc index 2810126..c6c1a98 100644 --- a/chrome/browser/ui/gtk/back_forward_button_gtk.cc +++ b/chrome/browser/ui/gtk/back_forward_button_gtk.cc @@ -10,7 +10,7 @@ #include "chrome/app/chrome_command_ids.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/gtk/gtk_theme_provider.h" +#include "chrome/browser/ui/gtk/gtk_theme_service.h" #include "chrome/browser/ui/gtk/gtk_util.h" #include "chrome/browser/ui/gtk/menu_gtk.h" #include "chrome/browser/ui/toolbar/back_forward_menu_model.h" @@ -43,7 +43,7 @@ BackForwardButtonGtk::BackForwardButtonGtk(Browser* browser, bool is_forward) stock = GTK_STOCK_GO_BACK; } button_.reset(new CustomDrawButton( - GtkThemeProvider::GetFrom(browser_->profile()), + GtkThemeService::GetFrom(browser_->profile()), normal, pushed, hover, disabled, stock, GTK_ICON_SIZE_SMALL_TOOLBAR)); gtk_widget_set_tooltip_text(widget(), l10n_util::GetStringUTF8(tooltip).c_str()); diff --git a/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.cc b/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.cc index 3fd2105..7fc1286 100644 --- a/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.cc +++ b/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.cc @@ -26,7 +26,7 @@ #include "chrome/browser/ui/gtk/cairo_cached_surface.h" #include "chrome/browser/ui/gtk/custom_button.h" #include "chrome/browser/ui/gtk/gtk_chrome_button.h" -#include "chrome/browser/ui/gtk/gtk_theme_provider.h" +#include "chrome/browser/ui/gtk/gtk_theme_service.h" #include "chrome/browser/ui/gtk/gtk_util.h" #include "chrome/browser/ui/gtk/hover_controller_gtk.h" #include "chrome/browser/ui/gtk/menu_gtk.h" @@ -133,7 +133,7 @@ BookmarkBarGtk::BookmarkBarGtk(BrowserWindowGtk* window, dragged_node_(NULL), drag_icon_(NULL), toolbar_drop_item_(NULL), - theme_provider_(GtkThemeProvider::GetFrom(profile)), + theme_service_(GtkThemeService::GetFrom(profile)), show_instructions_(true), menu_bar_helper_(this), slide_animation_(this), @@ -204,7 +204,7 @@ void BookmarkBarGtk::Init(Profile* profile) { paint_box_ = gtk_event_box_new(); gtk_container_add(GTK_CONTAINER(ntp_padding_box_), paint_box_); GdkColor paint_box_color = - theme_provider_->GetGdkColor(BrowserThemeProvider::COLOR_TOOLBAR); + theme_service_->GetGdkColor(ThemeService::COLOR_TOOLBAR); gtk_widget_modify_bg(paint_box_, GTK_STATE_NORMAL, &paint_box_color); gtk_widget_add_events(paint_box_, GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK); @@ -240,7 +240,7 @@ void BookmarkBarGtk::Init(Profile* profile) { gtk_box_pack_start(GTK_BOX(bookmark_hbox_), bookmark_toolbar_.get(), TRUE, TRUE, 0); - overflow_button_ = theme_provider_->BuildChromeButton(); + overflow_button_ = theme_service_->BuildChromeButton(); g_object_set_data(G_OBJECT(overflow_button_), "left-align-popup", reinterpret_cast<void*>(true)); SetOverflowButtonAppearance(); @@ -258,13 +258,13 @@ void BookmarkBarGtk::Init(Profile* profile) { g_signal_connect(bookmark_toolbar_.get(), "drag-data-received", G_CALLBACK(&OnDragReceivedThunk), this); - GtkWidget* vseparator = theme_provider_->CreateToolbarSeparator(); + GtkWidget* vseparator = theme_service_->CreateToolbarSeparator(); gtk_box_pack_start(GTK_BOX(bookmark_hbox_), vseparator, FALSE, FALSE, 0); // We pack the button manually (rather than using gtk_button_set_*) so that // we can have finer control over its label. - other_bookmarks_button_ = theme_provider_->BuildChromeButton(); + other_bookmarks_button_ = theme_service_->BuildChromeButton(); ConnectFolderButtonEvents(other_bookmarks_button_, false); GtkWidget* other_padding = gtk_alignment_new(0, 0, 1, 1); gtk_alignment_set_padding(GTK_ALIGNMENT(other_padding), @@ -276,7 +276,7 @@ void BookmarkBarGtk::Init(Profile* profile) { gtk_box_pack_start(GTK_BOX(bookmark_hbox_), other_padding, FALSE, FALSE, 0); - sync_error_button_ = theme_provider_->BuildChromeButton(); + sync_error_button_ = theme_service_->BuildChromeButton(); gtk_button_set_image( GTK_BUTTON(sync_error_button_), gtk_image_new_from_pixbuf( @@ -311,7 +311,7 @@ void BookmarkBarGtk::Show(bool animate) { // Hide out behind the findbar. This is rather fragile code, it could // probably be improved. if (floating_) { - if (theme_provider_->UseGtkTheme()) { + if (theme_service_->UseGtkTheme()) { if (GTK_WIDGET_REALIZED(event_box_->parent)) gdk_window_lower(event_box_->parent->window); if (GTK_WIDGET_REALIZED(event_box_.get())) @@ -482,7 +482,7 @@ void BookmarkBarGtk::BookmarkNodeChanged(BookmarkModel* model, GtkToolItem* item = gtk_toolbar_get_nth_item( GTK_TOOLBAR(bookmark_toolbar_.get()), index); GtkWidget* button = gtk_bin_get_child(GTK_BIN(item)); - bookmark_utils::ConfigureButtonForNode(node, model, button, theme_provider_); + bookmark_utils::ConfigureButtonForNode(node, model, button, theme_service_); SetChevronState(); } @@ -515,7 +515,7 @@ void BookmarkBarGtk::CreateAllBookmarkButtons() { } bookmark_utils::ConfigureButtonForNode(model_->other_node(), - model_, other_bookmarks_button_, theme_provider_); + model_, other_bookmarks_button_, theme_service_); SetInstructionState(); SetChevronState(); @@ -572,7 +572,7 @@ void BookmarkBarGtk::SetOverflowButtonAppearance() { if (former_child) gtk_widget_destroy(former_child); - GtkWidget* new_child = theme_provider_->UseGtkTheme() ? + GtkWidget* new_child = theme_service_->UseGtkTheme() ? gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_NONE) : gtk_image_new_from_pixbuf(ResourceBundle::GetSharedInstance(). GetRTLEnabledPixbufNamed(IDR_BOOKMARK_BAR_CHEVRONS)); @@ -635,9 +635,9 @@ void BookmarkBarGtk::UpdateFloatingState() { #if !defined(OS_CHROMEOS) gtk_event_box_set_visible_window(GTK_EVENT_BOX(paint_box_), TRUE); #endif - GdkColor stroke_color = theme_provider_->UseGtkTheme() ? - theme_provider_->GetBorderColor() : - theme_provider_->GetGdkColor(BrowserThemeProvider::COLOR_NTP_HEADER); + GdkColor stroke_color = theme_service_->UseGtkTheme() ? + theme_service_->GetBorderColor() : + theme_service_->GetGdkColor(ThemeService::COLOR_NTP_HEADER); gtk_util::ActAsRoundedWindow(paint_box_, stroke_color, kNTPRoundedness, gtk_util::ROUNDED_ALL, gtk_util::BORDER_ALL); @@ -674,14 +674,14 @@ void BookmarkBarGtk::UpdateFloatingState() { void BookmarkBarGtk::UpdateEventBoxPaintability() { gtk_widget_set_app_paintable(event_box_.get(), - !theme_provider_->UseGtkTheme() || floating_); + !theme_service_->UseGtkTheme() || floating_); // When using the GTK+ theme, we need to have the event box be visible so // buttons don't get a halo color from the background. When using Chromium // themes, we want to let the background show through the toolbar. #if !defined(OS_CHROMEOS) gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box_.get()), - theme_provider_->UseGtkTheme()); + theme_service_->UseGtkTheme()); #endif } @@ -836,13 +836,13 @@ void BookmarkBarGtk::Observe(NotificationType type, UpdateEventBoxPaintability(); GdkColor paint_box_color = - theme_provider_->GetGdkColor(BrowserThemeProvider::COLOR_TOOLBAR); + theme_service_->GetGdkColor(ThemeService::COLOR_TOOLBAR); gtk_widget_modify_bg(paint_box_, GTK_STATE_NORMAL, &paint_box_color); if (floating_) { - GdkColor stroke_color = theme_provider_->UseGtkTheme() ? - theme_provider_->GetBorderColor() : - theme_provider_->GetGdkColor(BrowserThemeProvider::COLOR_NTP_HEADER); + GdkColor stroke_color = theme_service_->UseGtkTheme() ? + theme_service_->GetBorderColor() : + theme_service_->GetGdkColor(ThemeService::COLOR_NTP_HEADER); gtk_util::SetRoundedWindowBorderColor(paint_box_, stroke_color); } @@ -851,8 +851,8 @@ void BookmarkBarGtk::Observe(NotificationType type, } GtkWidget* BookmarkBarGtk::CreateBookmarkButton(const BookmarkNode* node) { - GtkWidget* button = theme_provider_->BuildChromeButton(); - bookmark_utils::ConfigureButtonForNode(node, model_, button, theme_provider_); + GtkWidget* button = theme_service_->BuildChromeButton(); + bookmark_utils::ConfigureButtonForNode(node, model_, button, theme_service_); // The tool item is also a source for dragging gtk_drag_source_set(button, GDK_BUTTON1_MASK, NULL, 0, @@ -1040,7 +1040,7 @@ void BookmarkBarGtk::OnButtonDragBegin(GtkWidget* button, DCHECK(dragged_node_); drag_icon_ = bookmark_utils::GetDragRepresentationForNode( - node, model_, theme_provider_); + node, model_, theme_service_); // We have to jump through some hoops to get the drag icon to line up because // it is a different size than the button. @@ -1312,7 +1312,7 @@ void BookmarkBarGtk::OnDragReceived(GtkWidget* widget, gboolean BookmarkBarGtk::OnEventBoxExpose(GtkWidget* widget, GdkEventExpose* event) { - GtkThemeProvider* theme_provider = theme_provider_; + GtkThemeService* theme_provider = theme_service_; // We don't need to render the toolbar image in GTK mode, except when // detached. diff --git a/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.h b/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.h index 7a74c79..a4c2b36 100644 --- a/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.h +++ b/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.h @@ -32,7 +32,7 @@ class BookmarkMenuController; class Browser; class BrowserWindowGtk; class CustomContainerButton; -class GtkThemeProvider; +class GtkThemeService; class MenuGtk; class PageNavigator; class Profile; @@ -361,7 +361,7 @@ class BookmarkBarGtk : public ui::AnimationDelegate, GtkToolItem* toolbar_drop_item_; // Theme provider for building buttons. - GtkThemeProvider* theme_provider_; + GtkThemeService* theme_service_; // Whether we should show the instructional text in the bookmark bar. bool show_instructions_; diff --git a/chrome/browser/ui/gtk/bookmarks/bookmark_bar_instructions_gtk.cc b/chrome/browser/ui/gtk/bookmarks/bookmark_bar_instructions_gtk.cc index 9d231f1..b763d5f 100644 --- a/chrome/browser/ui/gtk/bookmarks/bookmark_bar_instructions_gtk.cc +++ b/chrome/browser/ui/gtk/bookmarks/bookmark_bar_instructions_gtk.cc @@ -7,7 +7,7 @@ #include "base/observer_list.h" #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h" #include "chrome/browser/ui/gtk/gtk_chrome_shrinkable_hbox.h" -#include "chrome/browser/ui/gtk/gtk_theme_provider.h" +#include "chrome/browser/ui/gtk/gtk_theme_service.h" #include "chrome/browser/ui/gtk/gtk_util.h" #include "content/common/notification_service.h" #include "grit/generated_resources.h" @@ -17,7 +17,7 @@ BookmarkBarInstructionsGtk::BookmarkBarInstructionsGtk(Delegate* delegate, Profile* profile) : delegate_(delegate), profile_(profile), - theme_provider_(GtkThemeProvider::GetFrom(profile_)) { + theme_service_(GtkThemeService::GetFrom(profile_)) { instructions_hbox_ = gtk_chrome_shrinkable_hbox_new(FALSE, FALSE, 0); gtk_widget_set_size_request(instructions_hbox_, 0, -1); @@ -49,7 +49,7 @@ BookmarkBarInstructionsGtk::BookmarkBarInstructionsGtk(Delegate* delegate, registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, NotificationService::AllSources()); - theme_provider_->InitThemesFor(this); + theme_service_->InitThemesFor(this); } void BookmarkBarInstructionsGtk::Observe(NotificationType type, @@ -66,11 +66,11 @@ void BookmarkBarInstructionsGtk::OnButtonClick(GtkWidget* button) { void BookmarkBarInstructionsGtk::UpdateColors() { gtk_chrome_link_button_set_use_gtk_theme( GTK_CHROME_LINK_BUTTON(instructions_link_), - theme_provider_->UseGtkTheme()); + theme_service_->UseGtkTheme()); - GdkColor bookmark_color = theme_provider_->GetGdkColor( - BrowserThemeProvider::COLOR_BOOKMARK_TEXT); - if (theme_provider_->UseGtkTheme()) { + GdkColor bookmark_color = theme_service_->GetGdkColor( + ThemeService::COLOR_BOOKMARK_TEXT); + if (theme_service_->UseGtkTheme()) { gtk_util::SetLabelColor(instructions_label_, NULL); gtk_chrome_link_button_set_normal_color( GTK_CHROME_LINK_BUTTON(instructions_link_), NULL); @@ -80,9 +80,9 @@ void BookmarkBarInstructionsGtk::UpdateColors() { // When using a non-standard, non-gtk theme, we make the link color match // the bookmark text color. Otherwise, standard link blue can look very // bad for some dark themes. - if (theme_provider_->GetColor(BrowserThemeProvider::COLOR_BOOKMARK_TEXT) == - BrowserThemeProvider::GetDefaultColor( - BrowserThemeProvider::COLOR_BOOKMARK_TEXT)) { + if (theme_service_->GetColor(ThemeService::COLOR_BOOKMARK_TEXT) == + ThemeService::GetDefaultColor( + ThemeService::COLOR_BOOKMARK_TEXT)) { gtk_chrome_link_button_set_normal_color( GTK_CHROME_LINK_BUTTON(instructions_link_), NULL); } else { diff --git a/chrome/browser/ui/gtk/bookmarks/bookmark_bar_instructions_gtk.h b/chrome/browser/ui/gtk/bookmarks/bookmark_bar_instructions_gtk.h index ffb484c..509e8fd 100644 --- a/chrome/browser/ui/gtk/bookmarks/bookmark_bar_instructions_gtk.h +++ b/chrome/browser/ui/gtk/bookmarks/bookmark_bar_instructions_gtk.h @@ -12,7 +12,7 @@ #include "ui/base/gtk/gtk_signal.h" typedef struct _GtkWidget GtkWidget; -class GtkThemeProvider; +class GtkThemeService; class Profile; class BookmarkBarInstructionsGtk : public NotificationObserver { @@ -47,7 +47,7 @@ class BookmarkBarInstructionsGtk : public NotificationObserver { Profile* profile_; - GtkThemeProvider* theme_provider_; + GtkThemeService* theme_service_; // HBox that holds the the label and link of bookmark bar import promotion. GtkWidget* instructions_hbox_; diff --git a/chrome/browser/ui/gtk/bookmarks/bookmark_bubble_gtk.cc b/chrome/browser/ui/gtk/bookmarks/bookmark_bubble_gtk.cc index d285c1d..4248f43 100644 --- a/chrome/browser/ui/gtk/bookmarks/bookmark_bubble_gtk.cc +++ b/chrome/browser/ui/gtk/bookmarks/bookmark_bubble_gtk.cc @@ -19,7 +19,7 @@ #include "chrome/browser/metrics/user_metrics.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h" -#include "chrome/browser/ui/gtk/gtk_theme_provider.h" +#include "chrome/browser/ui/gtk/gtk_theme_service.h" #include "chrome/browser/ui/gtk/gtk_util.h" #include "chrome/browser/ui/gtk/info_bubble_gtk.h" #include "content/common/notification_service.h" @@ -67,9 +67,9 @@ void BookmarkBubbleGtk::Observe(NotificationType type, gtk_chrome_link_button_set_use_gtk_theme( GTK_CHROME_LINK_BUTTON(remove_button_), - theme_provider_->UseGtkTheme()); + theme_service_->UseGtkTheme()); - if (theme_provider_->UseGtkTheme()) { + if (theme_service_->UseGtkTheme()) { for (std::vector<GtkWidget*>::iterator it = labels_.begin(); it != labels_.end(); ++it) { gtk_widget_modify_fg(*it, GTK_STATE_NORMAL, NULL); @@ -88,7 +88,7 @@ BookmarkBubbleGtk::BookmarkBubbleGtk(GtkWidget* anchor, bool newly_bookmarked) : url_(url), profile_(profile), - theme_provider_(GtkThemeProvider::GetFrom(profile_)), + theme_service_(GtkThemeService::GetFrom(profile_)), anchor_(anchor), content_(NULL), name_entry_(NULL), @@ -166,7 +166,7 @@ BookmarkBubbleGtk::BookmarkBubbleGtk(GtkWidget* anchor, arrow_location, true, // match_system_theme true, // grab_input - theme_provider_, + theme_service_, this); // delegate if (!bubble_) { NOTREACHED(); @@ -190,7 +190,7 @@ BookmarkBubbleGtk::BookmarkBubbleGtk(GtkWidget* anchor, registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, NotificationService::AllSources()); - theme_provider_->InitThemesFor(this); + theme_service_->InitThemesFor(this); } BookmarkBubbleGtk::~BookmarkBubbleGtk() { diff --git a/chrome/browser/ui/gtk/bookmarks/bookmark_bubble_gtk.h b/chrome/browser/ui/gtk/bookmarks/bookmark_bubble_gtk.h index 5f31d85..6b99ff2 100644 --- a/chrome/browser/ui/gtk/bookmarks/bookmark_bubble_gtk.h +++ b/chrome/browser/ui/gtk/bookmarks/bookmark_bubble_gtk.h @@ -86,7 +86,7 @@ class BookmarkBubbleGtk : public InfoBubbleGtkDelegate, Profile* profile_; // Provides colors and stuff. - GtkThemeProvider* theme_provider_; + GtkThemeService* theme_service_; // The widget relative to which we are positioned. GtkWidget* anchor_; diff --git a/chrome/browser/ui/gtk/bookmarks/bookmark_editor_gtk.cc b/chrome/browser/ui/gtk/bookmarks/bookmark_editor_gtk.cc index cab8b1d..2d39eac 100644 --- a/chrome/browser/ui/gtk/bookmarks/bookmark_editor_gtk.cc +++ b/chrome/browser/ui/gtk/bookmarks/bookmark_editor_gtk.cc @@ -17,7 +17,7 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/gtk/bookmarks/bookmark_tree_model.h" #include "chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.h" -#include "chrome/browser/ui/gtk/gtk_theme_provider.h" +#include "chrome/browser/ui/gtk/gtk_theme_service.h" #include "chrome/browser/ui/gtk/gtk_util.h" #include "googleurl/src/gurl.h" #include "grit/chromium_strings.h" @@ -482,7 +482,7 @@ void BookmarkEditorGtk::AddNewFolder(GtkTreeIter* parent, GtkTreeIter* child) { gtk_tree_store_append(tree_store_, child, parent); gtk_tree_store_set( tree_store_, child, - bookmark_utils::FOLDER_ICON, GtkThemeProvider::GetFolderIcon(true), + bookmark_utils::FOLDER_ICON, GtkThemeService::GetFolderIcon(true), bookmark_utils::FOLDER_NAME, l10n_util::GetStringUTF8(IDS_BOOMARK_EDITOR_NEW_FOLDER_NAME).c_str(), bookmark_utils::ITEM_ID, static_cast<int64>(0), diff --git a/chrome/browser/ui/gtk/bookmarks/bookmark_menu_controller_gtk.cc b/chrome/browser/ui/gtk/bookmarks/bookmark_menu_controller_gtk.cc index 5af40b2..63140f1 100644 --- a/chrome/browser/ui/gtk/bookmarks/bookmark_menu_controller_gtk.cc +++ b/chrome/browser/ui/gtk/bookmarks/bookmark_menu_controller_gtk.cc @@ -13,7 +13,7 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.h" #include "chrome/browser/ui/gtk/gtk_chrome_button.h" -#include "chrome/browser/ui/gtk/gtk_theme_provider.h" +#include "chrome/browser/ui/gtk/gtk_theme_service.h" #include "chrome/browser/ui/gtk/gtk_util.h" #include "chrome/browser/ui/gtk/menu_gtk.h" #include "content/browser/tab_contents/page_navigator.h" @@ -348,7 +348,7 @@ void BookmarkMenuController::OnMenuItemDragBegin(GtkWidget* menu_item, const BookmarkNode* node = bookmark_utils::BookmarkNodeForWidget(menu_item); drag_icon_ = bookmark_utils::GetDragRepresentationForNode( - node, model_, GtkThemeProvider::GetFrom(profile_)); + node, model_, GtkThemeService::GetFrom(profile_)); gint x, y; gtk_widget_get_pointer(menu_item, &x, &y); gtk_drag_set_icon_widget(drag_context, drag_icon_, x, y); diff --git a/chrome/browser/ui/gtk/bookmarks/bookmark_tree_model.cc b/chrome/browser/ui/gtk/bookmarks/bookmark_tree_model.cc index 0589f28..cc2284f 100644 --- a/chrome/browser/ui/gtk/bookmarks/bookmark_tree_model.cc +++ b/chrome/browser/ui/gtk/bookmarks/bookmark_tree_model.cc @@ -10,7 +10,7 @@ #include "base/utf_string_conversions.h" #include "chrome/browser/bookmarks/bookmark_model.h" #include "chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.h" -#include "chrome/browser/ui/gtk/gtk_theme_provider.h" +#include "chrome/browser/ui/gtk/gtk_theme_service.h" namespace { @@ -25,7 +25,7 @@ void AddSingleNodeToTreeStore(GtkTreeStore* store, const BookmarkNode* node, // (and indeed, Nautilus does not render an expanded directory any // differently). gtk_tree_store_set(store, iter, - bookmark_utils::FOLDER_ICON, GtkThemeProvider::GetFolderIcon(true), + bookmark_utils::FOLDER_ICON, GtkThemeService::GetFolderIcon(true), bookmark_utils::FOLDER_NAME, UTF16ToUTF8(node->GetTitle()).c_str(), bookmark_utils::ITEM_ID, node->id(), diff --git a/chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.cc b/chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.cc index ae6f3da..961e7f1 100644 --- a/chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.cc +++ b/chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.cc @@ -13,7 +13,7 @@ #include "chrome/browser/bookmarks/bookmark_utils.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/gtk/gtk_chrome_button.h" -#include "chrome/browser/ui/gtk/gtk_theme_provider.h" +#include "chrome/browser/ui/gtk/gtk_theme_service.h" #include "chrome/browser/ui/gtk/gtk_util.h" #include "ui/base/dragdrop/gtk_dnd_util.h" #include "ui/base/l10n/l10n_util.h" @@ -51,7 +51,7 @@ void* AsVoid(const BookmarkNode* node) { // Creates the widget hierarchy for a bookmark button. void PackButton(GdkPixbuf* pixbuf, const string16& title, bool ellipsize, - GtkThemeProvider* provider, GtkWidget* button) { + GtkThemeService* provider, GtkWidget* button) { GtkWidget* former_child = gtk_bin_get_child(GTK_BIN(button)); if (former_child) gtk_container_remove(GTK_CONTAINER(button), former_child); @@ -165,11 +165,11 @@ GdkPixbuf* GetPixbufForNode(const BookmarkNode* node, BookmarkModel* model, if (model->GetFavicon(node).width() != 0) { pixbuf = gfx::GdkPixbufFromSkBitmap(&model->GetFavicon(node)); } else { - pixbuf = GtkThemeProvider::GetDefaultFavicon(native); + pixbuf = GtkThemeService::GetDefaultFavicon(native); g_object_ref(pixbuf); } } else { - pixbuf = GtkThemeProvider::GetFolderIcon(native); + pixbuf = GtkThemeService::GetFolderIcon(native); g_object_ref(pixbuf); } @@ -178,14 +178,14 @@ GdkPixbuf* GetPixbufForNode(const BookmarkNode* node, BookmarkModel* model, GtkWidget* GetDragRepresentation(GdkPixbuf* pixbuf, const string16& title, - GtkThemeProvider* provider) { + GtkThemeService* provider) { GtkWidget* window = gtk_window_new(GTK_WINDOW_POPUP); if (gtk_util::IsScreenComposited() && gtk_util::AddWindowAlphaChannel(window)) { DragRepresentationData* data = new DragRepresentationData( pixbuf, title, - provider->GetColor(BrowserThemeProvider::COLOR_BOOKMARK_TEXT)); + provider->GetColor(ThemeService::COLOR_BOOKMARK_TEXT)); g_signal_connect(window, "expose-event", G_CALLBACK(OnDragIconExpose), data); g_object_ref(window); @@ -198,7 +198,7 @@ GtkWidget* GetDragRepresentation(GdkPixbuf* pixbuf, } else { if (!provider->UseGtkTheme()) { GdkColor color = provider->GetGdkColor( - BrowserThemeProvider::COLOR_TOOLBAR); + ThemeService::COLOR_TOOLBAR); gtk_widget_modify_bg(window, GTK_STATE_NORMAL, &color); } gtk_widget_realize(window); @@ -218,7 +218,7 @@ GtkWidget* GetDragRepresentation(GdkPixbuf* pixbuf, GtkWidget* GetDragRepresentationForNode(const BookmarkNode* node, BookmarkModel* model, - GtkThemeProvider* provider) { + GtkThemeService* provider) { GdkPixbuf* pixbuf = GetPixbufForNode(node, model, provider->UseGtkTheme()); GtkWidget* widget = GetDragRepresentation(pixbuf, node->GetTitle(), provider); g_object_unref(pixbuf); @@ -226,7 +226,7 @@ GtkWidget* GetDragRepresentationForNode(const BookmarkNode* node, } void ConfigureButtonForNode(const BookmarkNode* node, BookmarkModel* model, - GtkWidget* button, GtkThemeProvider* provider) { + GtkWidget* button, GtkThemeService* provider) { GdkPixbuf* pixbuf = bookmark_utils::GetPixbufForNode(node, model, provider->UseGtkTheme()); PackButton(pixbuf, node->GetTitle(), node != model->other_node(), provider, @@ -278,12 +278,12 @@ const BookmarkNode* BookmarkNodeForWidget(GtkWidget* widget) { g_object_get_data(G_OBJECT(widget), bookmark_utils::kBookmarkNode)); } -void SetButtonTextColors(GtkWidget* label, GtkThemeProvider* provider) { +void SetButtonTextColors(GtkWidget* label, GtkThemeService* provider) { if (provider->UseGtkTheme()) { gtk_util::SetLabelColor(label, NULL); } else { GdkColor color = provider->GetGdkColor( - BrowserThemeProvider::COLOR_BOOKMARK_TEXT); + ThemeService::COLOR_BOOKMARK_TEXT); gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &color); gtk_widget_modify_fg(label, GTK_STATE_INSENSITIVE, &color); diff --git a/chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.h b/chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.h index 49e10a0..14efe65 100644 --- a/chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.h +++ b/chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.h @@ -14,7 +14,7 @@ class BookmarkModel; class BookmarkNode; -class GtkThemeProvider; +class GtkThemeService; class Profile; typedef struct _GdkDragContext GdkDragContext; @@ -35,15 +35,15 @@ GdkPixbuf* GetPixbufForNode(const BookmarkNode* node, BookmarkModel* model, // gtk_drag_set_icon_widget(). GtkWidget* GetDragRepresentation(GdkPixbuf* pixbuf, const string16& title, - GtkThemeProvider* provider); + GtkThemeService* provider); GtkWidget* GetDragRepresentationForNode(const BookmarkNode* node, BookmarkModel* model, - GtkThemeProvider* provider); + GtkThemeService* provider); // Helper function that sets visual properties of GtkButton |button| to the // contents of |node|. void ConfigureButtonForNode(const BookmarkNode* node, BookmarkModel* model, - GtkWidget* button, GtkThemeProvider* provider); + GtkWidget* button, GtkThemeService* provider); // Returns the tooltip. std::string BuildTooltipFor(const BookmarkNode* node); @@ -52,7 +52,7 @@ std::string BuildTooltipFor(const BookmarkNode* node); const BookmarkNode* BookmarkNodeForWidget(GtkWidget* widget); // Set the colors on |label| as per the theme. -void SetButtonTextColors(GtkWidget* label, GtkThemeProvider* provider); +void SetButtonTextColors(GtkWidget* label, GtkThemeService* provider); // Drag and drop. -------------------------------------------------------------- diff --git a/chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc b/chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc index 0f36121..511dee1 100644 --- a/chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc +++ b/chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc @@ -19,7 +19,7 @@ #include "chrome/browser/ui/gtk/extensions/extension_popup_gtk.h" #include "chrome/browser/ui/gtk/gtk_chrome_button.h" #include "chrome/browser/ui/gtk/gtk_chrome_shrinkable_hbox.h" -#include "chrome/browser/ui/gtk/gtk_theme_provider.h" +#include "chrome/browser/ui/gtk/gtk_theme_service.h" #include "chrome/browser/ui/gtk/gtk_util.h" #include "chrome/browser/ui/gtk/hover_controller_gtk.h" #include "chrome/browser/ui/gtk/menu_gtk.h" @@ -85,7 +85,7 @@ class BrowserActionButton : public NotificationObserver, public: BrowserActionButton(BrowserActionsToolbarGtk* toolbar, const Extension* extension, - GtkThemeProvider* theme_provider) + GtkThemeService* theme_provider) : toolbar_(toolbar), extension_(extension), image_(NULL), @@ -364,7 +364,7 @@ class BrowserActionButton : public NotificationObserver, BrowserActionsToolbarGtk::BrowserActionsToolbarGtk(Browser* browser) : browser_(browser), profile_(browser->profile()), - theme_provider_(GtkThemeProvider::GetFrom(browser->profile())), + theme_service_(GtkThemeService::GetFrom(browser->profile())), model_(NULL), hbox_(gtk_hbox_new(FALSE, 0)), button_hbox_(gtk_chrome_shrinkable_hbox_new(TRUE, FALSE, kButtonPadding)), @@ -380,7 +380,7 @@ BrowserActionsToolbarGtk::BrowserActionsToolbarGtk(Browser* browser) return; overflow_button_.reset(new CustomDrawButton( - theme_provider_, + theme_service_, IDR_BROWSER_ACTIONS_OVERFLOW, IDR_BROWSER_ACTIONS_OVERFLOW_P, IDR_BROWSER_ACTIONS_OVERFLOW_H, @@ -448,7 +448,7 @@ BrowserActionsToolbarGtk::BrowserActionsToolbarGtk(Browser* browser) registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, NotificationService::AllSources()); - theme_provider_->InitThemesFor(this); + theme_service_->InitThemesFor(this); } BrowserActionsToolbarGtk::~BrowserActionsToolbarGtk() { @@ -477,7 +477,7 @@ void BrowserActionsToolbarGtk::Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { DCHECK(NotificationType::BROWSER_THEME_CHANGED == type); - if (theme_provider_->UseGtkTheme()) + if (theme_service_->UseGtkTheme()) gtk_widget_show(separator_); else gtk_widget_hide(separator_); @@ -518,7 +518,7 @@ void BrowserActionsToolbarGtk::CreateButtonForExtension( RemoveButtonForExtension(extension); linked_ptr<BrowserActionButton> button( - new BrowserActionButton(this, extension, theme_provider_)); + new BrowserActionButton(this, extension, theme_service_)); gtk_chrome_shrinkable_hbox_pack_start( GTK_CHROME_SHRINKABLE_HBOX(button_hbox_.get()), button->widget(), 0); gtk_box_reorder_child(GTK_BOX(button_hbox_.get()), button->widget(), index); diff --git a/chrome/browser/ui/gtk/browser_actions_toolbar_gtk.h b/chrome/browser/ui/gtk/browser_actions_toolbar_gtk.h index 3e1db05..dfdc191 100644 --- a/chrome/browser/ui/gtk/browser_actions_toolbar_gtk.h +++ b/chrome/browser/ui/gtk/browser_actions_toolbar_gtk.h @@ -27,7 +27,7 @@ class Browser; class BrowserActionButton; class Extension; -class GtkThemeProvider; +class GtkThemeService; class Profile; typedef struct _GdkDragContext GdkDragContext; @@ -170,7 +170,7 @@ class BrowserActionsToolbarGtk : public ExtensionToolbarModel::Observer, Browser* browser_; Profile* profile_; - GtkThemeProvider* theme_provider_; + GtkThemeService* theme_service_; ExtensionToolbarModel* model_; diff --git a/chrome/browser/ui/gtk/browser_titlebar.cc b/chrome/browser/ui/gtk/browser_titlebar.cc index 130961e..32c048a 100644 --- a/chrome/browser/ui/gtk/browser_titlebar.cc +++ b/chrome/browser/ui/gtk/browser_titlebar.cc @@ -25,7 +25,7 @@ #if defined(USE_GCONF) #include "chrome/browser/ui/gtk/gconf_titlebar_listener.h" #endif -#include "chrome/browser/ui/gtk/gtk_theme_provider.h" +#include "chrome/browser/ui/gtk/gtk_theme_service.h" #include "chrome/browser/ui/gtk/gtk_util.h" #include "chrome/browser/ui/gtk/menu_gtk.h" #include "chrome/browser/ui/gtk/nine_box.h" @@ -214,7 +214,7 @@ BrowserTitlebar::BrowserTitlebar(BrowserWindowGtk* browser_window, app_mode_title_(NULL), using_custom_frame_(false), window_has_focus_(false), - theme_provider_(NULL) { + theme_service_(NULL) { Init(); } @@ -357,11 +357,11 @@ void BrowserTitlebar::Init() { // Register with the theme provider to set the |app_mode_title_| label // color. - theme_provider_ = GtkThemeProvider::GetFrom( + theme_service_ = GtkThemeService::GetFrom( browser_window_->browser()->profile()); registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, NotificationService::AllSources()); - theme_provider_->InitThemesFor(this); + theme_service_->InitThemesFor(this); UpdateTitleAndIcon(); } @@ -671,7 +671,7 @@ void BrowserTitlebar::UpdateTextColor() { if (!app_mode_title_) return; - if (theme_provider_ && theme_provider_->UseGtkTheme()) { + if (theme_service_ && theme_service_->UseGtkTheme()) { // We don't really have any good options here. // // Colors from window manager themes aren't exposed in GTK; the window @@ -687,11 +687,11 @@ void BrowserTitlebar::UpdateTextColor() { // color. GdkColor frame_color; if (window_has_focus_) { - frame_color = theme_provider_->GetGdkColor( - BrowserThemeProvider::COLOR_FRAME); + frame_color = theme_service_->GetGdkColor( + ThemeService::COLOR_FRAME); } else { - frame_color = theme_provider_->GetGdkColor( - BrowserThemeProvider::COLOR_FRAME_INACTIVE); + frame_color = theme_service_->GetGdkColor( + ThemeService::COLOR_FRAME_INACTIVE); } GdkColor text_color = PickLuminosityContrastingColor( &frame_color, >k_util::kGdkWhite, >k_util::kGdkBlack); diff --git a/chrome/browser/ui/gtk/browser_titlebar.h b/chrome/browser/ui/gtk/browser_titlebar.h index c4f4603..72a01b7 100644 --- a/chrome/browser/ui/gtk/browser_titlebar.h +++ b/chrome/browser/ui/gtk/browser_titlebar.h @@ -22,7 +22,7 @@ class BrowserWindowGtk; class CustomDrawButton; -class GtkThemeProvider; +class GtkThemeService; class MenuGtk; class PopupPageMenuModel; class TabContents; @@ -231,7 +231,7 @@ class BrowserTitlebar : public NotificationObserver, Throbber throbber_; // Theme provider for building buttons. - GtkThemeProvider* theme_provider_; + GtkThemeService* theme_service_; NotificationRegistrar registrar_; }; diff --git a/chrome/browser/ui/gtk/browser_toolbar_gtk.cc b/chrome/browser/ui/gtk/browser_toolbar_gtk.cc index f5c1735..4c057b0 100644 --- a/chrome/browser/ui/gtk/browser_toolbar_gtk.cc +++ b/chrome/browser/ui/gtk/browser_toolbar_gtk.cc @@ -19,7 +19,7 @@ #include "chrome/browser/net/url_fixer_upper.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/themes/browser_theme_provider.h" +#include "chrome/browser/themes/theme_service.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/gtk/accelerators_gtk.h" #include "chrome/browser/ui/gtk/back_forward_button_gtk.h" @@ -28,7 +28,7 @@ #include "chrome/browser/ui/gtk/cairo_cached_surface.h" #include "chrome/browser/ui/gtk/custom_button.h" #include "chrome/browser/ui/gtk/gtk_chrome_button.h" -#include "chrome/browser/ui/gtk/gtk_theme_provider.h" +#include "chrome/browser/ui/gtk/gtk_theme_service.h" #include "chrome/browser/ui/gtk/gtk_util.h" #include "chrome/browser/ui/gtk/location_bar_view_gtk.h" #include "chrome/browser/ui/gtk/reload_button_gtk.h" @@ -119,7 +119,7 @@ void BrowserToolbarGtk::Init(Profile* profile, // Make sure to tell the location bar the profile before calling its Init. SetProfile(profile); - theme_provider_ = GtkThemeProvider::GetFrom(profile); + theme_service_ = GtkThemeService::GetFrom(profile); offscreen_entry_.Own(gtk_entry_new()); show_home_button_.Init(prefs::kShowHomeButton, profile->GetPrefs(), this); @@ -130,7 +130,7 @@ void BrowserToolbarGtk::Init(Profile* profile, event_box_ = gtk_event_box_new(); // Make the event box transparent so themes can use transparent toolbar // backgrounds. - if (!theme_provider_->UseGtkTheme()) + if (!theme_service_->UseGtkTheme()) gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box_), FALSE); toolbar_ = gtk_hbox_new(FALSE, 0); @@ -159,7 +159,7 @@ void BrowserToolbarGtk::Init(Profile* profile, gtk_box_pack_start(GTK_BOX(toolbar_left_), reload_->widget(), FALSE, FALSE, 0); - home_.reset(new CustomDrawButton(GtkThemeProvider::GetFrom(profile_), + home_.reset(new CustomDrawButton(GtkThemeService::GetFrom(profile_), IDR_HOME, IDR_HOME_P, IDR_HOME_H, 0, GTK_STOCK_HOME, GTK_ICON_SIZE_SMALL_TOOLBAR)); gtk_widget_set_tooltip_text(home_->widget(), @@ -190,9 +190,9 @@ void BrowserToolbarGtk::Init(Profile* profile, } wrench_menu_image_ = gtk_image_new_from_pixbuf( - theme_provider_->GetRTLEnabledPixbufNamed(IDR_TOOLS)); + theme_service_->GetRTLEnabledPixbufNamed(IDR_TOOLS)); wrench_menu_button_.reset(new CustomDrawButton( - GtkThemeProvider::GetFrom(profile_), + GtkThemeService::GetFrom(profile_), IDR_TOOLS, IDR_TOOLS_P, IDR_TOOLS_H, 0, wrench_menu_image_)); GtkWidget* wrench_button = wrench_menu_button_->widget(); @@ -236,7 +236,7 @@ void BrowserToolbarGtk::Init(Profile* profile, location_bar_->UpdateContentSettingsIcons(); SetViewIDs(); - theme_provider_->InitThemesFor(this); + theme_service_->InitThemesFor(this); } void BrowserToolbarGtk::SetViewIDs() { @@ -315,7 +315,7 @@ void BrowserToolbarGtk::StoppedShowing() { } GtkIconSet* BrowserToolbarGtk::GetIconSetForId(int idr) { - return theme_provider_->GetIconSetForId(idr); + return theme_service_->GetIconSetForId(idr); } // Always show images because we desire that some icons always show @@ -345,7 +345,7 @@ void BrowserToolbarGtk::Observe(NotificationType type, NotifyPrefChanged(Details<std::string>(details).ptr()); } else if (type == NotificationType::BROWSER_THEME_CHANGED) { // Update the spacing around the menu buttons - bool use_gtk = theme_provider_->UseGtkTheme(); + bool use_gtk = theme_service_->UseGtkTheme(); int border = use_gtk ? 0 : 2; gtk_container_set_border_width( GTK_CONTAINER(wrench_menu_button_->widget()), border); @@ -372,7 +372,7 @@ void BrowserToolbarGtk::Observe(NotificationType type, // we set the initial value in Init()). gtk_image_set_from_pixbuf( GTK_IMAGE(wrench_menu_image_), - theme_provider_->GetRTLEnabledPixbufNamed(IDR_TOOLS)); + theme_service_->GetRTLEnabledPixbufNamed(IDR_TOOLS)); } UpdateRoundedness(); @@ -428,7 +428,7 @@ bool BrowserToolbarGtk::UpdateRoundedness() { // We still round the corners if we are in chrome theme mode, but we do it by // drawing theme resources rather than changing the physical shape of the // widget. - bool should_be_rounded = theme_provider_->UseGtkTheme() && + bool should_be_rounded = theme_service_->UseGtkTheme() && window_->ShouldDrawContentDropShadow(); if (should_be_rounded == gtk_util::IsActingAsRoundedWindow(alignment_)) @@ -453,7 +453,7 @@ gboolean BrowserToolbarGtk::OnAlignmentExpose(GtkWidget* widget, return TRUE; // We don't need to render the toolbar image in GTK mode. - if (theme_provider_->UseGtkTheme()) + if (theme_service_->UseGtkTheme()) return FALSE; cairo_t* cr = gdk_cairo_create(GDK_DRAWABLE(widget->window)); @@ -463,8 +463,8 @@ gboolean BrowserToolbarGtk::OnAlignmentExpose(GtkWidget* widget, gfx::Point tabstrip_origin = window_->tabstrip()->GetTabStripOriginForWidget(widget); // Fill the entire region with the toolbar color. - GdkColor color = theme_provider_->GetGdkColor( - BrowserThemeProvider::COLOR_TOOLBAR); + GdkColor color = theme_service_->GetGdkColor( + ThemeService::COLOR_TOOLBAR); gdk_cairo_set_source_color(cr, &color); cairo_fill(cr); @@ -490,7 +490,7 @@ gboolean BrowserToolbarGtk::OnAlignmentExpose(GtkWidget* widget, area = area.Subtract(right).Subtract(left); } - CairoCachedSurface* background = theme_provider_->GetSurfaceNamed( + CairoCachedSurface* background = theme_service_->GetSurfaceNamed( IDR_THEME_TOOLBAR, widget); background->SetSource(cr, tabstrip_origin.x(), tabstrip_origin.y()); cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT); @@ -517,13 +517,13 @@ gboolean BrowserToolbarGtk::OnAlignmentExpose(GtkWidget* widget, cairo_set_operator(copy_cr, CAIRO_OPERATOR_SOURCE); if (draw_left_corner) { - CairoCachedSurface* left_corner = theme_provider_->GetSurfaceNamed( + CairoCachedSurface* left_corner = theme_service_->GetSurfaceNamed( IDR_CONTENT_TOP_LEFT_CORNER_MASK, widget); left_corner->SetSource(copy_cr, left.x(), left.y()); cairo_paint(copy_cr); } if (draw_right_corner) { - CairoCachedSurface* right_corner = theme_provider_->GetSurfaceNamed( + CairoCachedSurface* right_corner = theme_service_->GetSurfaceNamed( IDR_CONTENT_TOP_RIGHT_CORNER_MASK, widget); right_corner->SetSource(copy_cr, right.x(), right.y()); // We fill a path rather than just painting because we don't want to @@ -554,7 +554,7 @@ gboolean BrowserToolbarGtk::OnAlignmentExpose(GtkWidget* widget, gboolean BrowserToolbarGtk::OnLocationHboxExpose(GtkWidget* location_hbox, GdkEventExpose* e) { - if (theme_provider_->UseGtkTheme()) { + if (theme_service_->UseGtkTheme()) { gtk_util::DrawTextEntryBackground(offscreen_entry_.get(), location_hbox, &e->area, &location_hbox->allocation); @@ -629,7 +629,7 @@ gboolean BrowserToolbarGtk::OnWrenchMenuButtonExpose(GtkWidget* sender, GdkEventExpose* expose) { const SkBitmap* badge = NULL; if (UpgradeDetector::GetInstance()->notify_upgrade()) { - badge = theme_provider_->GetBitmapNamed(IDR_UPDATE_BADGE); + badge = theme_service_->GetBitmapNamed(IDR_UPDATE_BADGE); } else { return FALSE; } diff --git a/chrome/browser/ui/gtk/browser_toolbar_gtk.h b/chrome/browser/ui/gtk/browser_toolbar_gtk.h index ff7ec88..4cae34e 100644 --- a/chrome/browser/ui/gtk/browser_toolbar_gtk.h +++ b/chrome/browser/ui/gtk/browser_toolbar_gtk.h @@ -28,7 +28,7 @@ class Browser; class BrowserActionsToolbarGtk; class BrowserWindowGtk; class CustomDrawButton; -class GtkThemeProvider; +class GtkThemeService; class LocationBar; class LocationBarViewGtk; class Profile; @@ -186,7 +186,7 @@ class BrowserToolbarGtk : public CommandUpdater::CommandObserver, // The model that contains the security level, text, icon to display... ToolbarModel* model_; - GtkThemeProvider* theme_provider_; + GtkThemeService* theme_service_; scoped_ptr<MenuGtk> wrench_menu_; diff --git a/chrome/browser/ui/gtk/browser_window_gtk.cc b/chrome/browser/ui/gtk/browser_window_gtk.cc index e04a5ea..f546e5f 100644 --- a/chrome/browser/ui/gtk/browser_window_gtk.cc +++ b/chrome/browser/ui/gtk/browser_window_gtk.cc @@ -31,7 +31,7 @@ #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/tabs/tab_strip_model.h" -#include "chrome/browser/themes/browser_theme_provider.h" +#include "chrome/browser/themes/theme_service.h" #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_dialogs.h" @@ -51,7 +51,7 @@ #include "chrome/browser/ui/gtk/find_bar_gtk.h" #include "chrome/browser/ui/gtk/fullscreen_exit_bubble_gtk.h" #include "chrome/browser/ui/gtk/gtk_floating_container.h" -#include "chrome/browser/ui/gtk/gtk_theme_provider.h" +#include "chrome/browser/ui/gtk/gtk_theme_service.h" #include "chrome/browser/ui/gtk/gtk_util.h" #include "chrome/browser/ui/gtk/info_bubble_gtk.h" #include "chrome/browser/ui/gtk/infobars/infobar_container_gtk.h" @@ -360,7 +360,7 @@ gboolean BrowserWindowGtk::OnCustomFrameExpose(GtkWidget* widget, void BrowserWindowGtk::DrawContentShadow(cairo_t* cr) { // Draw the shadow above the toolbar. Tabs on the tabstrip will draw over us. - GtkThemeProvider* theme_provider = GtkThemeProvider::GetFrom( + GtkThemeService* theme_provider = GtkThemeService::GetFrom( browser()->profile()); int left_x, top_y; gtk_widget_translate_coordinates(toolbar_->widget(), @@ -487,7 +487,7 @@ void BrowserWindowGtk::DrawContentShadow(cairo_t* cr) { void BrowserWindowGtk::DrawPopupFrame(cairo_t* cr, GtkWidget* widget, GdkEventExpose* event) { - GtkThemeProvider* theme_provider = GtkThemeProvider::GetFrom( + GtkThemeService* theme_provider = GtkThemeService::GetFrom( browser()->profile()); // Like DrawCustomFrame(), except that we use the unthemed resources to draw @@ -507,7 +507,7 @@ void BrowserWindowGtk::DrawPopupFrame(cairo_t* cr, void BrowserWindowGtk::DrawCustomFrame(cairo_t* cr, GtkWidget* widget, GdkEventExpose* event) { - GtkThemeProvider* theme_provider = GtkThemeProvider::GetFrom( + GtkThemeService* theme_provider = GtkThemeService::GetFrom( browser()->profile()); int image_name = GetThemeFrameResource(); @@ -1647,18 +1647,18 @@ void BrowserWindowGtk::InitWidgets() { void BrowserWindowGtk::SetBackgroundColor() { Profile* profile = browser()->profile(); - GtkThemeProvider* theme_provider = GtkThemeProvider::GetFrom(profile); + GtkThemeService* theme_provider = GtkThemeService::GetFrom(profile); int frame_color_id; if (UsingCustomPopupFrame()) { - frame_color_id = BrowserThemeProvider::COLOR_TOOLBAR; + frame_color_id = ThemeService::COLOR_TOOLBAR; } else if (IsActive()) { frame_color_id = browser()->profile()->IsOffTheRecord() - ? BrowserThemeProvider::COLOR_FRAME_INCOGNITO - : BrowserThemeProvider::COLOR_FRAME; + ? ThemeService::COLOR_FRAME_INCOGNITO + : ThemeService::COLOR_FRAME; } else { frame_color_id = browser()->profile()->IsOffTheRecord() - ? BrowserThemeProvider::COLOR_FRAME_INCOGNITO_INACTIVE - : BrowserThemeProvider::COLOR_FRAME_INACTIVE; + ? ThemeService::COLOR_FRAME_INCOGNITO_INACTIVE + : ThemeService::COLOR_FRAME_INACTIVE; } SkColor frame_color = theme_provider->GetColor(frame_color_id); @@ -1844,7 +1844,7 @@ gboolean BrowserWindowGtk::OnExposeDrawInfobarBits(GtkWidget* sender, Profile* profile = browser()->profile(); infobar_arrow_model_.Paint( sender, expose, bounds, - GtkThemeProvider::GetFrom(profile)->GetBorderColor()); + GtkThemeService::GetFrom(profile)->GetBorderColor()); return FALSE; } @@ -2148,7 +2148,7 @@ bool BrowserWindowGtk::IsBookmarkBarSupported() const { } bool BrowserWindowGtk::UsingCustomPopupFrame() const { - GtkThemeProvider* theme_provider = GtkThemeProvider::GetFrom( + GtkThemeService* theme_provider = GtkThemeService::GetFrom( browser()->profile()); return !theme_provider->UseGtkTheme() && browser()->type() & Browser::TYPE_POPUP; diff --git a/chrome/browser/ui/gtk/cairo_cached_surface.h b/chrome/browser/ui/gtk/cairo_cached_surface.h index da7fe67..8894ee1 100644 --- a/chrome/browser/ui/gtk/cairo_cached_surface.h +++ b/chrome/browser/ui/gtk/cairo_cached_surface.h @@ -16,10 +16,10 @@ typedef struct _cairo_surface cairo_surface_t; // once. From then on, that cached version is used so we don't upload the same // image each and every time we expose. // -// Most cached surfaces are owned by the GtkThemeProvider, which associates +// Most cached surfaces are owned by the GtkThemeService, which associates // them with a certain XDisplay. Some users of surfaces (CustomDrawButtonBase, // for example) own their surfaces instead since they interact with the -// ResourceBundle instead of the GtkThemeProvider. +// ResourceBundle instead of the GtkThemeService. class CairoCachedSurface { public: CairoCachedSurface(); diff --git a/chrome/browser/ui/gtk/content_setting_bubble_gtk.cc b/chrome/browser/ui/gtk/content_setting_bubble_gtk.cc index 9fe4ef1..c26e345 100644 --- a/chrome/browser/ui/gtk/content_setting_bubble_gtk.cc +++ b/chrome/browser/ui/gtk/content_setting_bubble_gtk.cc @@ -15,7 +15,7 @@ #include "chrome/browser/content_settings/host_content_settings_map.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h" -#include "chrome/browser/ui/gtk/gtk_theme_provider.h" +#include "chrome/browser/ui/gtk/gtk_theme_service.h" #include "chrome/browser/ui/gtk/gtk_util.h" #include "chrome/common/content_settings.h" #include "content/browser/tab_contents/tab_contents.h" @@ -87,7 +87,7 @@ void ContentSettingBubbleGtk::Observe(NotificationType type, } void ContentSettingBubbleGtk::BuildBubble() { - GtkThemeProvider* theme_provider = GtkThemeProvider::GetFrom(profile_); + GtkThemeService* theme_provider = GtkThemeService::GetFrom(profile_); GtkWidget* bubble_content = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); gtk_container_set_border_width(GTK_CONTAINER(bubble_content), kContentBorder); diff --git a/chrome/browser/ui/gtk/custom_button.cc b/chrome/browser/ui/gtk/custom_button.cc index 28f3713..4bdd1e8 100644 --- a/chrome/browser/ui/gtk/custom_button.cc +++ b/chrome/browser/ui/gtk/custom_button.cc @@ -7,7 +7,7 @@ #include "base/basictypes.h" #include "chrome/browser/ui/gtk/cairo_cached_surface.h" #include "chrome/browser/ui/gtk/gtk_chrome_button.h" -#include "chrome/browser/ui/gtk/gtk_theme_provider.h" +#include "chrome/browser/ui/gtk/gtk_theme_service.h" #include "chrome/browser/ui/gtk/gtk_util.h" #include "content/common/notification_service.h" #include "grit/theme_resources.h" @@ -16,7 +16,7 @@ #include "ui/gfx/gtk_util.h" #include "ui/gfx/skbitmap_operations.h" -CustomDrawButtonBase::CustomDrawButtonBase(GtkThemeProvider* theme_provider, +CustomDrawButtonBase::CustomDrawButtonBase(GtkThemeService* theme_provider, int normal_id, int pressed_id, int hover_id, @@ -27,7 +27,7 @@ CustomDrawButtonBase::CustomDrawButtonBase(GtkThemeProvider* theme_provider, pressed_id_(pressed_id), hover_id_(hover_id), disabled_id_(disabled_id), - theme_provider_(theme_provider), + theme_service_(theme_provider), flipped_(false) { for (int i = 0; i < (GTK_STATE_INSENSITIVE + 1); ++i) surfaces_[i].reset(new CairoCachedSurface); @@ -142,18 +142,18 @@ void CustomDrawButtonBase::SetBackground(SkColor color, void CustomDrawButtonBase::Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { - DCHECK(theme_provider_); + DCHECK(theme_service_); DCHECK(NotificationType::BROWSER_THEME_CHANGED == type); surfaces_[GTK_STATE_NORMAL]->UsePixbuf(normal_id_ ? - theme_provider_->GetRTLEnabledPixbufNamed(normal_id_) : NULL); + theme_service_->GetRTLEnabledPixbufNamed(normal_id_) : NULL); surfaces_[GTK_STATE_ACTIVE]->UsePixbuf(pressed_id_ ? - theme_provider_->GetRTLEnabledPixbufNamed(pressed_id_) : NULL); + theme_service_->GetRTLEnabledPixbufNamed(pressed_id_) : NULL); surfaces_[GTK_STATE_PRELIGHT]->UsePixbuf(hover_id_ ? - theme_provider_->GetRTLEnabledPixbufNamed(hover_id_) : NULL); + theme_service_->GetRTLEnabledPixbufNamed(hover_id_) : NULL); surfaces_[GTK_STATE_SELECTED]->UsePixbuf(NULL); surfaces_[GTK_STATE_INSENSITIVE]->UsePixbuf(disabled_id_ ? - theme_provider_->GetRTLEnabledPixbufNamed(disabled_id_) : NULL); + theme_service_->GetRTLEnabledPixbufNamed(disabled_id_) : NULL); } CairoCachedSurface* CustomDrawButtonBase::PixbufForState(int state) { @@ -221,14 +221,14 @@ CustomDrawButton::CustomDrawButton(int normal_id, int hover_id, int disabled_id) : button_base_(NULL, normal_id, pressed_id, hover_id, disabled_id), - theme_provider_(NULL) { + theme_service_(NULL) { Init(); // Initialize the theme stuff with no theme_provider. SetBrowserTheme(); } -CustomDrawButton::CustomDrawButton(GtkThemeProvider* theme_provider, +CustomDrawButton::CustomDrawButton(GtkThemeService* theme_provider, int normal_id, int pressed_id, int hover_id, @@ -237,18 +237,18 @@ CustomDrawButton::CustomDrawButton(GtkThemeProvider* theme_provider, GtkIconSize stock_size) : button_base_(theme_provider, normal_id, pressed_id, hover_id, disabled_id), - theme_provider_(theme_provider) { + theme_service_(theme_provider) { native_widget_.Own(gtk_image_new_from_stock(stock_id, stock_size)); Init(); - theme_provider_->InitThemesFor(this); + theme_service_->InitThemesFor(this); registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, NotificationService::AllSources()); } -CustomDrawButton::CustomDrawButton(GtkThemeProvider* theme_provider, +CustomDrawButton::CustomDrawButton(GtkThemeService* theme_provider, int normal_id, int pressed_id, int hover_id, @@ -257,10 +257,10 @@ CustomDrawButton::CustomDrawButton(GtkThemeProvider* theme_provider, : button_base_(theme_provider, normal_id, pressed_id, hover_id, disabled_id), native_widget_(native_widget), - theme_provider_(theme_provider) { + theme_service_(theme_provider) { Init(); - theme_provider_->InitThemesFor(this); + theme_service_->InitThemesFor(this); registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, NotificationService::AllSources()); @@ -315,7 +315,7 @@ gboolean CustomDrawButton::OnCustomExpose(GtkWidget* sender, // static CustomDrawButton* CustomDrawButton::CloseButton( - GtkThemeProvider* theme_provider) { + GtkThemeService* theme_provider) { CustomDrawButton* button = new CustomDrawButton(theme_provider, IDR_CLOSE_BAR, IDR_CLOSE_BAR_P, IDR_CLOSE_BAR_H, 0, GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU); return button; @@ -341,5 +341,5 @@ void CustomDrawButton::SetBrowserTheme() { } bool CustomDrawButton::UseGtkTheme() { - return theme_provider_ && theme_provider_->UseGtkTheme(); + return theme_service_ && theme_service_->UseGtkTheme(); } diff --git a/chrome/browser/ui/gtk/custom_button.h b/chrome/browser/ui/gtk/custom_button.h index 64b3a65..c18c7ed 100644 --- a/chrome/browser/ui/gtk/custom_button.h +++ b/chrome/browser/ui/gtk/custom_button.h @@ -19,7 +19,7 @@ #include "ui/gfx/rect.h" class CairoCachedSurface; -class GtkThemeProvider; +class GtkThemeService; class SkBitmap; // These classes implement two kinds of custom-drawn buttons. They're @@ -32,7 +32,7 @@ class CustomDrawButtonBase : public NotificationObserver { public: // If the images come from ResourceBundle rather than the theme provider, // pass in NULL for |theme_provider|. - CustomDrawButtonBase(GtkThemeProvider* theme_provider, + CustomDrawButtonBase(GtkThemeService* theme_provider, int normal_id, int pressed_id, int hover_id, @@ -81,7 +81,7 @@ class CustomDrawButtonBase : public NotificationObserver { int pressed_id_; int hover_id_; int disabled_id_; - GtkThemeProvider* theme_provider_; + GtkThemeService* theme_service_; // Whether the button is flipped horizontally. Not used for RTL (we get // flipped versions from the theme provider). Used for the flipped window @@ -137,7 +137,7 @@ class CustomDrawButton : public NotificationObserver { // Same as above, but uses themed (and possibly tinted) images. |stock_id| and // |stock_size| are used for GTK+ theme mode. - CustomDrawButton(GtkThemeProvider* theme_provider, + CustomDrawButton(GtkThemeService* theme_provider, int normal_id, int pressed_id, int hover_id, @@ -147,7 +147,7 @@ class CustomDrawButton : public NotificationObserver { // As above, but uses an arbitrary GtkImage rather than a stock icon. This // constructor takes ownership of |native_widget|. - CustomDrawButton(GtkThemeProvider* theme_provider, + CustomDrawButton(GtkThemeService* theme_provider, int normal_id, int pressed_id, int hover_id, @@ -191,7 +191,7 @@ class CustomDrawButton : public NotificationObserver { // Returns a standard close button. Pass a |theme_provider| to use Gtk icons // in Gtk rendering mode. - static CustomDrawButton* CloseButton(GtkThemeProvider* theme_provider); + static CustomDrawButton* CloseButton(GtkThemeService* theme_provider); private: // Sets the button to themed or not. @@ -216,7 +216,7 @@ class CustomDrawButton : public NotificationObserver { OwnedWidgetGtk native_widget_; // Our theme provider. - GtkThemeProvider* theme_provider_; + GtkThemeService* theme_service_; // Used to listen for theme change notifications. NotificationRegistrar registrar_; diff --git a/chrome/browser/ui/gtk/download_item_gtk.cc b/chrome/browser/ui/gtk/download_item_gtk.cc index b4a5484..1c0449b 100644 --- a/chrome/browser/ui/gtk/download_item_gtk.cc +++ b/chrome/browser/ui/gtk/download_item_gtk.cc @@ -19,7 +19,7 @@ #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/gtk/custom_drag.h" #include "chrome/browser/ui/gtk/download_shelf_gtk.h" -#include "chrome/browser/ui/gtk/gtk_theme_provider.h" +#include "chrome/browser/ui/gtk/gtk_theme_service.h" #include "chrome/browser/ui/gtk/gtk_util.h" #include "chrome/browser/ui/gtk/menu_gtk.h" #include "chrome/browser/ui/gtk/nine_box.h" @@ -167,7 +167,7 @@ DownloadItemGtk::DownloadItemGtk(DownloadShelfGtk* parent_shelf, : parent_shelf_(parent_shelf), arrow_(NULL), menu_showing_(false), - theme_provider_(GtkThemeProvider::GetFrom( + theme_service_(GtkThemeService::GetFrom( parent_shelf->browser()->profile())), progress_angle_(download_util::kStartAngleDegrees), download_model_(download_model), @@ -320,7 +320,7 @@ DownloadItemGtk::DownloadItemGtk(DownloadShelfGtk* parent_shelf, registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, NotificationService::AllSources()); - theme_provider_->InitThemesFor(this); + theme_service_->InitThemesFor(this); // Set the initial width of the widget to be animated. if (IsDangerous()) { @@ -448,7 +448,7 @@ void DownloadItemGtk::Observe(NotificationType type, if (type == NotificationType::BROWSER_THEME_CHANGED) { // Our GtkArrow is only visible in gtk mode. Otherwise, we let the custom // rendering code do whatever it wants. - if (theme_provider_->UseGtkTheme()) { + if (theme_service_->UseGtkTheme()) { if (!arrow_) { arrow_ = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_NONE); gtk_widget_set_size_request(arrow_, @@ -546,9 +546,9 @@ void DownloadItemGtk::UpdateNameLabel() { get_download()->GetFileNameToReportUser(), gfx::Font(), kTextWidth); - GdkColor color = theme_provider_->GetGdkColor( - BrowserThemeProvider::COLOR_BOOKMARK_TEXT); - gtk_util::SetLabelColor(name_label_, theme_provider_->UseGtkTheme() ? + GdkColor color = theme_service_->GetGdkColor( + ThemeService::COLOR_BOOKMARK_TEXT); + gtk_util::SetLabelColor(name_label_, theme_service_->UseGtkTheme() ? NULL : &color); gtk_label_set_text(GTK_LABEL(name_label_), UTF16ToUTF8(elided_filename).c_str()); @@ -559,9 +559,9 @@ void DownloadItemGtk::UpdateStatusLabel(const std::string& status_text) { return; GdkColor text_color; - if (!theme_provider_->UseGtkTheme()) { - SkColor color = theme_provider_->GetColor( - BrowserThemeProvider::COLOR_BOOKMARK_TEXT); + if (!theme_service_->UseGtkTheme()) { + SkColor color = theme_service_->GetColor( + ThemeService::COLOR_BOOKMARK_TEXT); if (color_utils::RelativeLuminance(color) > 0.5) { color = SkColorSetRGB( static_cast<int>(kDownloadItemLuminanceMod * @@ -579,7 +579,7 @@ void DownloadItemGtk::UpdateStatusLabel(const std::string& status_text) { color_utils::AlphaBlend(blend_color, color, 77)); } - gtk_util::SetLabelColor(status_label_, theme_provider_->UseGtkTheme() ? + gtk_util::SetLabelColor(status_label_, theme_service_->UseGtkTheme() ? NULL : &text_color); gtk_label_set_text(GTK_LABEL(status_label_), status_text.c_str()); } @@ -612,11 +612,11 @@ void DownloadItemGtk::UpdateDangerWarning() { } } - if (theme_provider_->UseGtkTheme()) { + if (theme_service_->UseGtkTheme()) { gtk_util::SetLabelColor(dangerous_label_, NULL); } else { - GdkColor color = theme_provider_->GetGdkColor( - BrowserThemeProvider::COLOR_BOOKMARK_TEXT); + GdkColor color = theme_service_->GetGdkColor( + ThemeService::COLOR_BOOKMARK_TEXT); gtk_util::SetLabelColor(dangerous_label_, &color); } @@ -647,7 +647,7 @@ void DownloadItemGtk::UpdateDangerWarning() { } void DownloadItemGtk::UpdateDangerIcon() { - if (theme_provider_->UseGtkTheme()) { + if (theme_service_->UseGtkTheme()) { const char* stock = get_download()->danger_type() == DownloadItem::DANGEROUS_URL ? GTK_STOCK_DIALOG_ERROR : GTK_STOCK_DIALOG_WARNING; @@ -730,7 +730,7 @@ void DownloadItemGtk::InitNineBoxes() { } gboolean DownloadItemGtk::OnHboxExpose(GtkWidget* widget, GdkEventExpose* e) { - if (theme_provider_->UseGtkTheme()) { + if (theme_service_->UseGtkTheme()) { int border_width = GTK_CONTAINER(widget)->border_width; int x = widget->allocation.x + border_width; int y = widget->allocation.y + border_width; @@ -799,7 +799,7 @@ gboolean DownloadItemGtk::OnHboxExpose(GtkWidget* widget, GdkEventExpose* e) { } gboolean DownloadItemGtk::OnExpose(GtkWidget* widget, GdkEventExpose* e) { - if (!theme_provider_->UseGtkTheme()) { + if (!theme_service_->UseGtkTheme()) { bool is_body = widget == body_.get(); NineBox* nine_box = NULL; @@ -901,7 +901,7 @@ void DownloadItemGtk::ShowPopupMenu(GtkWidget* button, gboolean DownloadItemGtk::OnDangerousPromptExpose(GtkWidget* widget, GdkEventExpose* event) { - if (!theme_provider_->UseGtkTheme()) { + if (!theme_service_->UseGtkTheme()) { // The hbox renderer will take care of the border when in GTK mode. dangerous_nine_box_->RenderToWidget(widget); } diff --git a/chrome/browser/ui/gtk/download_item_gtk.h b/chrome/browser/ui/gtk/download_item_gtk.h index afe5fe7..190db53 100644 --- a/chrome/browser/ui/gtk/download_item_gtk.h +++ b/chrome/browser/ui/gtk/download_item_gtk.h @@ -23,7 +23,7 @@ class BaseDownloadItemModel; class DownloadShelfContextMenuGtk; class DownloadShelfGtk; -class GtkThemeProvider; +class GtkThemeService; class NineBox; class SkBitmap; @@ -181,7 +181,7 @@ class DownloadItemGtk : public DownloadItem::Observer, bool menu_showing_; // Whether we should use the GTK text color - GtkThemeProvider* theme_provider_; + GtkThemeService* theme_service_; // The widget that contains the animation progress and the file's icon // (as well as the complete animation). diff --git a/chrome/browser/ui/gtk/download_shelf_gtk.cc b/chrome/browser/ui/gtk/download_shelf_gtk.cc index a64006b..40c45a9 100644 --- a/chrome/browser/ui/gtk/download_shelf_gtk.cc +++ b/chrome/browser/ui/gtk/download_shelf_gtk.cc @@ -15,7 +15,7 @@ #include "chrome/browser/ui/gtk/download_item_gtk.h" #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h" #include "chrome/browser/ui/gtk/gtk_chrome_shrinkable_hbox.h" -#include "chrome/browser/ui/gtk/gtk_theme_provider.h" +#include "chrome/browser/ui/gtk/gtk_theme_service.h" #include "chrome/browser/ui/gtk/gtk_util.h" #include "content/common/notification_service.h" #include "grit/generated_resources.h" @@ -60,7 +60,7 @@ const int kShelfAuraSize = 40; DownloadShelfGtk::DownloadShelfGtk(Browser* browser, GtkWidget* parent) : browser_(browser), is_showing_(false), - theme_provider_(GtkThemeProvider::GetFrom(browser->profile())), + theme_service_(GtkThemeService::GetFrom(browser->profile())), close_on_mouse_out_(false), mouse_in_shelf_(false), auto_close_factory_(this) { @@ -109,7 +109,7 @@ DownloadShelfGtk::DownloadShelfGtk(Browser* browser, GtkWidget* parent) gtk_container_add(GTK_CONTAINER(shelf_.get()), vbox); // Create and pack the close button. - close_button_.reset(CustomDrawButton::CloseButton(theme_provider_)); + close_button_.reset(CustomDrawButton::CloseButton(theme_service_)); gtk_util::CenterWidgetInHBox(outer_hbox, close_button_->widget(), true, 0); g_signal_connect(close_button_->widget(), "clicked", G_CALLBACK(OnButtonClickThunk), this); @@ -140,7 +140,7 @@ DownloadShelfGtk::DownloadShelfGtk(Browser* browser, GtkWidget* parent) kShelfAnimationDurationMs, false, true, this)); - theme_provider_->InitThemesFor(this); + theme_service_->InitThemesFor(this); registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, NotificationService::AllSources()); @@ -222,32 +222,32 @@ void DownloadShelfGtk::Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { if (type == NotificationType::BROWSER_THEME_CHANGED) { - GdkColor color = theme_provider_->GetGdkColor( - BrowserThemeProvider::COLOR_TOOLBAR); + GdkColor color = theme_service_->GetGdkColor( + ThemeService::COLOR_TOOLBAR); gtk_widget_modify_bg(padding_bg_, GTK_STATE_NORMAL, &color); - color = theme_provider_->GetBorderColor(); + color = theme_service_->GetBorderColor(); gtk_widget_modify_bg(top_border_, GTK_STATE_NORMAL, &color); gtk_chrome_link_button_set_use_gtk_theme( - GTK_CHROME_LINK_BUTTON(link_button_), theme_provider_->UseGtkTheme()); + GTK_CHROME_LINK_BUTTON(link_button_), theme_service_->UseGtkTheme()); // When using a non-standard, non-gtk theme, we make the link color match // the bookmark text color. Otherwise, standard link blue can look very // bad for some dark themes. - bool use_default_color = theme_provider_->GetColor( - BrowserThemeProvider::COLOR_BOOKMARK_TEXT) == - BrowserThemeProvider::GetDefaultColor( - BrowserThemeProvider::COLOR_BOOKMARK_TEXT); - GdkColor bookmark_color = theme_provider_->GetGdkColor( - BrowserThemeProvider::COLOR_BOOKMARK_TEXT); + bool use_default_color = theme_service_->GetColor( + ThemeService::COLOR_BOOKMARK_TEXT) == + ThemeService::GetDefaultColor( + ThemeService::COLOR_BOOKMARK_TEXT); + GdkColor bookmark_color = theme_service_->GetGdkColor( + ThemeService::COLOR_BOOKMARK_TEXT); gtk_chrome_link_button_set_normal_color( GTK_CHROME_LINK_BUTTON(link_button_), use_default_color ? NULL : &bookmark_color); ResourceBundle& rb = ResourceBundle::GetSharedInstance(); close_button_->SetBackground( - theme_provider_->GetColor(BrowserThemeProvider::COLOR_TAB_TEXT), + theme_service_->GetColor(ThemeService::COLOR_TAB_TEXT), rb.GetBitmapNamed(IDR_CLOSE_BAR), rb.GetBitmapNamed(IDR_CLOSE_BAR_MASK)); } diff --git a/chrome/browser/ui/gtk/download_shelf_gtk.h b/chrome/browser/ui/gtk/download_shelf_gtk.h index d54cabe..abe735d1 100644 --- a/chrome/browser/ui/gtk/download_shelf_gtk.h +++ b/chrome/browser/ui/gtk/download_shelf_gtk.h @@ -24,7 +24,7 @@ class BaseDownloadItemModel; class Browser; class CustomDrawButton; class DownloadItemGtk; -class GtkThemeProvider; +class GtkThemeService; class SlideAnimatorGtk; namespace gfx { @@ -132,7 +132,7 @@ class DownloadShelfGtk : public DownloadShelf, std::vector<DownloadItemGtk*> download_items_; // Gives us our colors and theme information. - GtkThemeProvider* theme_provider_; + GtkThemeService* theme_service_; NotificationRegistrar registrar_; diff --git a/chrome/browser/ui/gtk/extensions/extension_installed_bubble_gtk.cc b/chrome/browser/ui/gtk/extensions/extension_installed_bubble_gtk.cc index 1fa0156..1892a0d 100644 --- a/chrome/browser/ui/gtk/extensions/extension_installed_bubble_gtk.cc +++ b/chrome/browser/ui/gtk/extensions/extension_installed_bubble_gtk.cc @@ -14,7 +14,7 @@ #include "chrome/browser/ui/gtk/browser_actions_toolbar_gtk.h" #include "chrome/browser/ui/gtk/browser_toolbar_gtk.h" #include "chrome/browser/ui/gtk/browser_window_gtk.h" -#include "chrome/browser/ui/gtk/gtk_theme_provider.h" +#include "chrome/browser/ui/gtk/gtk_theme_service.h" #include "chrome/browser/ui/gtk/gtk_util.h" #include "chrome/browser/ui/gtk/location_bar_view_gtk.h" #include "chrome/common/extensions/extension.h" @@ -171,7 +171,7 @@ void ExtensionInstalledBubbleGtk::ShowInternal() { if (reference_widget == NULL) reference_widget = browser_window->GetToolbar()->GetAppMenuButton(); - GtkThemeProvider* theme_provider = GtkThemeProvider::GetFrom( + GtkThemeService* theme_provider = GtkThemeService::GetFrom( browser_->profile()); // Setup the InfoBubble content. diff --git a/chrome/browser/ui/gtk/extensions/extension_popup_gtk.cc b/chrome/browser/ui/gtk/extensions/extension_popup_gtk.cc index 823f5a7..b395292 100644 --- a/chrome/browser/ui/gtk/extensions/extension_popup_gtk.cc +++ b/chrome/browser/ui/gtk/extensions/extension_popup_gtk.cc @@ -17,7 +17,7 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/renderer_host/render_widget_host_view_gtk.h" #include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/gtk/gtk_theme_provider.h" +#include "chrome/browser/ui/gtk/gtk_theme_service.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/common/notification_details.h" #include "content/common/notification_source.h" @@ -124,7 +124,7 @@ void ExtensionPopupGtk::ShowPopup() { arrow_location, false, // match_system_theme !being_inspected_, // grab_input - GtkThemeProvider::GetFrom(browser_->profile()), + GtkThemeService::GetFrom(browser_->profile()), this); } diff --git a/chrome/browser/ui/gtk/find_bar_gtk.cc b/chrome/browser/ui/gtk/find_bar_gtk.cc index 81fe41f..5487d9f 100644 --- a/chrome/browser/ui/gtk/find_bar_gtk.cc +++ b/chrome/browser/ui/gtk/find_bar_gtk.cc @@ -24,7 +24,7 @@ #include "chrome/browser/ui/gtk/cairo_cached_surface.h" #include "chrome/browser/ui/gtk/custom_button.h" #include "chrome/browser/ui/gtk/gtk_floating_container.h" -#include "chrome/browser/ui/gtk/gtk_theme_provider.h" +#include "chrome/browser/ui/gtk/gtk_theme_service.h" #include "chrome/browser/ui/gtk/gtk_util.h" #include "chrome/browser/ui/gtk/nine_box.h" #include "chrome/browser/ui/gtk/slide_animator_gtk.h" @@ -176,7 +176,7 @@ void BuildBorder(GtkWidget* child, FindBarGtk::FindBarGtk(Browser* browser) : browser_(browser), window_(static_cast<BrowserWindowGtk*>(browser->window())), - theme_provider_(GtkThemeProvider::GetFrom(browser->profile())), + theme_service_(GtkThemeService::GetFrom(browser->profile())), container_width_(-1), container_height_(-1), match_label_failure_(false), @@ -235,7 +235,7 @@ void FindBarGtk::InitWidgets() { SlideAnimatorGtk::DOWN, 0, false, false, NULL)); - close_button_.reset(CustomDrawButton::CloseButton(theme_provider_)); + close_button_.reset(CustomDrawButton::CloseButton(theme_service_)); gtk_util::CenterWidgetInHBox(hbox, close_button_->widget(), true, kCloseButtonPaddingLeft); g_signal_connect(close_button_->widget(), "clicked", @@ -243,7 +243,7 @@ void FindBarGtk::InitWidgets() { gtk_widget_set_tooltip_text(close_button_->widget(), l10n_util::GetStringUTF8(IDS_FIND_IN_PAGE_CLOSE_TOOLTIP).c_str()); - find_next_button_.reset(new CustomDrawButton(theme_provider_, + find_next_button_.reset(new CustomDrawButton(theme_service_, IDR_FINDINPAGE_NEXT, IDR_FINDINPAGE_NEXT_H, IDR_FINDINPAGE_NEXT_H, IDR_FINDINPAGE_NEXT_P, GTK_STOCK_GO_DOWN, GTK_ICON_SIZE_MENU)); g_signal_connect(find_next_button_->widget(), "clicked", @@ -253,7 +253,7 @@ void FindBarGtk::InitWidgets() { gtk_box_pack_end(GTK_BOX(hbox), find_next_button_->widget(), FALSE, FALSE, 0); - find_previous_button_.reset(new CustomDrawButton(theme_provider_, + find_previous_button_.reset(new CustomDrawButton(theme_service_, IDR_FINDINPAGE_PREV, IDR_FINDINPAGE_PREV_H, IDR_FINDINPAGE_PREV_H, IDR_FINDINPAGE_PREV_P, GTK_STOCK_GO_UP, GTK_ICON_SIZE_MENU)); g_signal_connect(find_previous_button_->widget(), "clicked", @@ -302,7 +302,7 @@ void FindBarGtk::InitWidgets() { &border_bin_, &border_bin_alignment_); gtk_util::CenterWidgetInHBox(hbox, border_bin_, true, 0); - theme_provider_->InitThemesFor(this); + theme_service_->InitThemesFor(this); registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, NotificationService::AllSources()); @@ -468,7 +468,7 @@ void FindBarGtk::Observe(NotificationType type, container_width_ = -1; container_height_ = -1; - if (theme_provider_->UseGtkTheme()) { + if (theme_service_->UseGtkTheme()) { gtk_widget_modify_cursor(text_entry_, NULL, NULL); gtk_widget_modify_base(text_entry_, GTK_STATE_NORMAL, NULL); gtk_widget_modify_text(text_entry_, GTK_STATE_NORMAL, NULL); @@ -535,7 +535,7 @@ void FindBarGtk::Observe(NotificationType type, ResourceBundle& rb = ResourceBundle::GetSharedInstance(); close_button_->SetBackground( - theme_provider_->GetColor(BrowserThemeProvider::COLOR_TAB_TEXT), + theme_service_->GetColor(ThemeService::COLOR_TAB_TEXT), rb.GetBitmapNamed(IDR_CLOSE_BAR), rb.GetBitmapNamed(IDR_CLOSE_BAR_MASK)); } @@ -602,7 +602,7 @@ void FindBarGtk::FindEntryTextInContents(bool forward_search) { void FindBarGtk::UpdateMatchLabelAppearance(bool failure) { match_label_failure_ = failure; - bool use_gtk = theme_provider_->UseGtkTheme(); + bool use_gtk = theme_service_->UseGtkTheme(); if (use_gtk) { GtkStyle* style = gtk_rc_get_style(text_entry_); @@ -812,7 +812,7 @@ void FindBarGtk::OnClicked(GtkWidget* button, FindBarGtk* find_bar) { gboolean FindBarGtk::OnContentEventBoxExpose(GtkWidget* widget, GdkEventExpose* event, FindBarGtk* bar) { - if (bar->theme_provider_->UseGtkTheme()) { + if (bar->theme_service_->UseGtkTheme()) { // Draw the text entry background around where we input stuff. Note the // decrement to |width|. We do this because some theme engines // (*cough*Clearlooks*cough*) don't do any blending and use thickness to @@ -839,7 +839,7 @@ gboolean FindBarGtk::OnExpose(GtkWidget* widget, GdkEventExpose* e, gtk_widget_size_request(widget, &req); gtk_widget_set_size_request(bar->widget(), req.width, -1); - if (bar->theme_provider_->UseGtkTheme()) { + if (bar->theme_service_->UseGtkTheme()) { if (bar->container_width_ != widget->allocation.width || bar->container_height_ != widget->allocation.height) { std::vector<GdkPoint> mask_points = MakeFramePolygonPoints( @@ -859,7 +859,7 @@ gboolean FindBarGtk::OnExpose(GtkWidget* widget, GdkEventExpose* e, GdkDrawable* drawable = GDK_DRAWABLE(e->window); GdkGC* gc = gdk_gc_new(drawable); gdk_gc_set_clip_rectangle(gc, &e->area); - GdkColor color = bar->theme_provider_->GetBorderColor(); + GdkColor color = bar->theme_service_->GetBorderColor(); gdk_gc_set_rgb_fg_color(gc, &color); // Stroke the frame border. @@ -887,7 +887,7 @@ gboolean FindBarGtk::OnExpose(GtkWidget* widget, GdkEventExpose* e, bar->window_->tabstrip()->GetTabStripOriginForWidget(widget); gtk_util::DrawThemedToolbarBackground(widget, cr, e, tabstrip_origin, - bar->theme_provider_); + bar->theme_service_); // During chrome theme mode, we need to draw the border around content_hbox // now instead of when we render |border_bin_|. We don't use stacked event @@ -897,7 +897,7 @@ gboolean FindBarGtk::OnExpose(GtkWidget* widget, GdkEventExpose* e, // Blit the left part of the background image once on the left. CairoCachedSurface* background_left = - bar->theme_provider_->GetRTLEnabledSurfaceNamed( + bar->theme_service_->GetRTLEnabledSurfaceNamed( IDR_FIND_BOX_BACKGROUND_LEFT, widget); background_left->SetSource(cr, border_allocation.x, border_allocation.y); cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT); @@ -906,7 +906,7 @@ gboolean FindBarGtk::OnExpose(GtkWidget* widget, GdkEventExpose* e, cairo_fill(cr); // Blit the center part of the background image in all the space between. - CairoCachedSurface* background = bar->theme_provider_->GetSurfaceNamed( + CairoCachedSurface* background = bar->theme_service_->GetSurfaceNamed( IDR_FIND_BOX_BACKGROUND, widget); background->SetSource(cr, border_allocation.x + background_left->Width(), diff --git a/chrome/browser/ui/gtk/find_bar_gtk.h b/chrome/browser/ui/gtk/find_bar_gtk.h index ae5a656..7059c94 100644 --- a/chrome/browser/ui/gtk/find_bar_gtk.h +++ b/chrome/browser/ui/gtk/find_bar_gtk.h @@ -22,7 +22,7 @@ class Browser; class BrowserWindowGtk; class CustomDrawButton; class FindBarController; -class GtkThemeProvider; +class GtkThemeService; class NineBox; class SlideAnimatorGtk; class TabContentsContainerGtk; @@ -172,7 +172,7 @@ class FindBarGtk : public FindBar, BrowserWindowGtk* window_; // Provides colors and information about GTK. - GtkThemeProvider* theme_provider_; + GtkThemeService* theme_service_; // The widget that animates the slide-in and -out of the findbar. scoped_ptr<SlideAnimatorGtk> slide_widget_; diff --git a/chrome/browser/ui/gtk/first_run_bubble.cc b/chrome/browser/ui/gtk/first_run_bubble.cc index 9a5f2c6..3c05c31 100644 --- a/chrome/browser/ui/gtk/first_run_bubble.cc +++ b/chrome/browser/ui/gtk/first_run_bubble.cc @@ -12,7 +12,7 @@ #include "chrome/browser/browser_list.h" #include "chrome/browser/search_engines/util.h" #include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/gtk/gtk_theme_provider.h" +#include "chrome/browser/ui/gtk/gtk_theme_service.h" #include "chrome/browser/ui/gtk/gtk_util.h" #include "content/common/notification_service.h" #include "grit/chromium_strings.h" @@ -57,7 +57,7 @@ void FirstRunBubble::Observe(NotificationType type, const NotificationDetails& details) { DCHECK(type == NotificationType::BROWSER_THEME_CHANGED); - if (theme_provider_->UseGtkTheme()) { + if (theme_service_->UseGtkTheme()) { for (std::vector<GtkWidget*>::iterator it = labels_.begin(); it != labels_.end(); ++it) { gtk_widget_modify_fg(*it, GTK_STATE_NORMAL, NULL); @@ -75,7 +75,7 @@ FirstRunBubble::FirstRunBubble(Profile* profile, const gfx::Rect& rect, FirstRun::BubbleType bubble_type) : profile_(profile), - theme_provider_(GtkThemeProvider::GetFrom(profile_)), + theme_service_(GtkThemeService::GetFrom(profile_)), anchor_(anchor), content_(NULL), bubble_(NULL) { @@ -110,7 +110,7 @@ FirstRunBubble::FirstRunBubble(Profile* profile, arrow_location, true, // match_system_theme true, // grab_input - theme_provider_, + theme_service_, this); // delegate if (!bubble_) { NOTREACHED(); @@ -119,7 +119,7 @@ FirstRunBubble::FirstRunBubble(Profile* profile, registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, NotificationService::AllSources()); - theme_provider_->InitThemesFor(this); + theme_service_->InitThemesFor(this); } FirstRunBubble::~FirstRunBubble() { diff --git a/chrome/browser/ui/gtk/first_run_bubble.h b/chrome/browser/ui/gtk/first_run_bubble.h index 1a26e1b..7e774de 100644 --- a/chrome/browser/ui/gtk/first_run_bubble.h +++ b/chrome/browser/ui/gtk/first_run_bubble.h @@ -66,7 +66,7 @@ class FirstRunBubble : public InfoBubbleGtkDelegate, Profile* profile_; // Provides colors and stuff. - GtkThemeProvider* theme_provider_; + GtkThemeService* theme_service_; // The widget we anchor to, and a descendant of the toplevel window we // are transient for. diff --git a/chrome/browser/ui/gtk/gtk_theme_provider.cc b/chrome/browser/ui/gtk/gtk_theme_service.cc index 7247515..81bf8a9 100644 --- a/chrome/browser/ui/gtk/gtk_theme_provider.cc +++ b/chrome/browser/ui/gtk/gtk_theme_service.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/ui/gtk/gtk_theme_provider.h" +#include "chrome/browser/ui/gtk/gtk_theme_service.h" #include <gtk/gtk.h> @@ -17,7 +17,7 @@ #include "chrome/browser/metrics/user_metrics.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/themes/theme_service.h" +#include "chrome/browser/themes/theme_service_factory.h" #include "chrome/browser/ui/gtk/cairo_cached_surface.h" #include "chrome/browser/ui/gtk/chrome_gtk_frame.h" #include "chrome/browser/ui/gtk/gtk_chrome_button.h" @@ -122,8 +122,7 @@ bool IsOverridableImage(int id) { images.insert(kAutocompleteImages, kAutocompleteImages + arraysize(kAutocompleteImages)); - const std::set<int>& buttons = - BrowserThemeProvider::GetTintableToolbarButtons(); + const std::set<int>& buttons = ThemeService::GetTintableToolbarButtons(); images.insert(buttons.begin(), buttons.end()); } @@ -242,18 +241,18 @@ void GdkColorHSLShift(const color_utils::HSL& shift, GdkColor* frame_color) { } // namespace -GtkWidget* GtkThemeProvider::icon_widget_ = NULL; -GdkPixbuf* GtkThemeProvider::default_folder_icon_ = NULL; -GdkPixbuf* GtkThemeProvider::default_bookmark_icon_ = NULL; +GtkWidget* GtkThemeService::icon_widget_ = NULL; +GdkPixbuf* GtkThemeService::default_folder_icon_ = NULL; +GdkPixbuf* GtkThemeService::default_bookmark_icon_ = NULL; // static -GtkThemeProvider* GtkThemeProvider::GetFrom(Profile* profile) { - return static_cast<GtkThemeProvider*>( +GtkThemeService* GtkThemeService::GetFrom(Profile* profile) { + return static_cast<GtkThemeService*>( ThemeServiceFactory::GetForProfile(profile)); } -GtkThemeProvider::GtkThemeProvider() - : BrowserThemeProvider(), +GtkThemeService::GtkThemeService() + : ThemeService(), fake_window_(gtk_window_new(GTK_WINDOW_TOPLEVEL)), fake_frame_(chrome_gtk_frame_new()), signals_(new ui::GtkSignalRegistrar), @@ -271,7 +270,7 @@ GtkThemeProvider::GtkThemeProvider() G_CALLBACK(&OnStyleSetThunk), this); } -GtkThemeProvider::~GtkThemeProvider() { +GtkThemeService::~GtkThemeService() { gtk_widget_destroy(fake_window_); gtk_widget_destroy(fake_frame_); fake_label_.Destroy(); @@ -280,20 +279,20 @@ GtkThemeProvider::~GtkThemeProvider() { FreeIconSets(); - // We have to call this because FreePlatformCached() in ~BrowserThemeProvider + // We have to call this because FreePlatformCached() in ~ThemeService // doesn't call the right virutal FreePlatformCaches. FreePlatformCaches(); } -void GtkThemeProvider::Init(Profile* profile) { +void GtkThemeService::Init(Profile* profile) { registrar_.Init(profile->GetPrefs()); registrar_.Add(prefs::kUsesSystemTheme, this); use_gtk_ = profile->GetPrefs()->GetBoolean(prefs::kUsesSystemTheme); - BrowserThemeProvider::Init(profile); + ThemeService::Init(profile); } -SkBitmap* GtkThemeProvider::GetBitmapNamed(int id) const { +SkBitmap* GtkThemeService::GetBitmapNamed(int id) const { // Try to get our cached version: ImageCache::const_iterator it = gtk_images_.find(id); if (it != gtk_images_.end()) @@ -306,64 +305,64 @@ SkBitmap* GtkThemeProvider::GetBitmapNamed(int id) const { return bitmap; } - return BrowserThemeProvider::GetBitmapNamed(id); + return ThemeService::GetBitmapNamed(id); } -SkColor GtkThemeProvider::GetColor(int id) const { +SkColor GtkThemeService::GetColor(int id) const { if (use_gtk_) { ColorMap::const_iterator it = colors_.find(id); if (it != colors_.end()) return it->second; } - return BrowserThemeProvider::GetColor(id); + return ThemeService::GetColor(id); } -bool GtkThemeProvider::HasCustomImage(int id) const { +bool GtkThemeService::HasCustomImage(int id) const { if (use_gtk_) return IsOverridableImage(id); - return BrowserThemeProvider::HasCustomImage(id); + return ThemeService::HasCustomImage(id); } -void GtkThemeProvider::InitThemesFor(NotificationObserver* observer) { +void GtkThemeService::InitThemesFor(NotificationObserver* observer) { observer->Observe(NotificationType::BROWSER_THEME_CHANGED, Source<ui::ThemeProvider>(this), NotificationService::NoDetails()); } -void GtkThemeProvider::SetTheme(const Extension* extension) { +void GtkThemeService::SetTheme(const Extension* extension) { profile()->GetPrefs()->SetBoolean(prefs::kUsesSystemTheme, false); LoadDefaultValues(); - BrowserThemeProvider::SetTheme(extension); + ThemeService::SetTheme(extension); } -void GtkThemeProvider::UseDefaultTheme() { +void GtkThemeService::UseDefaultTheme() { profile()->GetPrefs()->SetBoolean(prefs::kUsesSystemTheme, false); LoadDefaultValues(); - BrowserThemeProvider::UseDefaultTheme(); + ThemeService::UseDefaultTheme(); } -void GtkThemeProvider::SetNativeTheme() { +void GtkThemeService::SetNativeTheme() { profile()->GetPrefs()->SetBoolean(prefs::kUsesSystemTheme, true); ClearAllThemeData(); LoadGtkValues(); NotifyThemeChanged(NULL); } -bool GtkThemeProvider::UsingDefaultTheme() { - return !use_gtk_ && BrowserThemeProvider::UsingDefaultTheme(); +bool GtkThemeService::UsingDefaultTheme() { + return !use_gtk_ && ThemeService::UsingDefaultTheme(); } -void GtkThemeProvider::Observe(NotificationType type, - const NotificationSource& source, - const NotificationDetails& details) { +void GtkThemeService::Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details) { if ((type == NotificationType::PREF_CHANGED) && (*Details<std::string>(details).ptr() == prefs::kUsesSystemTheme)) use_gtk_ = profile()->GetPrefs()->GetBoolean(prefs::kUsesSystemTheme); } -GtkWidget* GtkThemeProvider::BuildChromeButton() { +GtkWidget* GtkThemeService::BuildChromeButton() { GtkWidget* button = HoverControllerGtk::CreateChromeButton(); gtk_chrome_button_set_use_gtk_rendering(GTK_CHROME_BUTTON(button), use_gtk_); chrome_buttons_.push_back(button); @@ -373,7 +372,7 @@ GtkWidget* GtkThemeProvider::BuildChromeButton() { return button; } -GtkWidget* GtkThemeProvider::CreateToolbarSeparator() { +GtkWidget* GtkThemeService::CreateToolbarSeparator() { GtkWidget* separator = gtk_vseparator_new(); GtkWidget* alignment = gtk_alignment_new(0, 0, 1, 1); gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), @@ -385,15 +384,15 @@ GtkWidget* GtkThemeProvider::CreateToolbarSeparator() { return alignment; } -bool GtkThemeProvider::UseGtkTheme() const { +bool GtkThemeService::UseGtkTheme() const { return use_gtk_; } -GdkColor GtkThemeProvider::GetGdkColor(int id) const { +GdkColor GtkThemeService::GetGdkColor(int id) const { return gfx::SkColorToGdkColor(GetColor(id)); } -GdkColor GtkThemeProvider::GetBorderColor() const { +GdkColor GtkThemeService::GetBorderColor() const { GtkStyle* style = gtk_rc_get_style(fake_window_); GdkColor text; @@ -417,16 +416,16 @@ GdkColor GtkThemeProvider::GetBorderColor() const { return color; } -GtkIconSet* GtkThemeProvider::GetIconSetForId(int id) const { +GtkIconSet* GtkThemeService::GetIconSetForId(int id) const { if (id == IDR_FULLSCREEN_MENU_BUTTON) return fullscreen_icon_set_; return NULL; } -void GtkThemeProvider::GetScrollbarColors(GdkColor* thumb_active_color, - GdkColor* thumb_inactive_color, - GdkColor* track_color) { +void GtkThemeService::GetScrollbarColors(GdkColor* thumb_active_color, + GdkColor* thumb_inactive_color, + GdkColor* track_color) { const GdkColor* theme_thumb_active = NULL; const GdkColor* theme_thumb_inactive = NULL; const GdkColor* theme_trough_color = NULL; @@ -523,7 +522,7 @@ void GtkThemeProvider::GetScrollbarColors(GdkColor* thumb_active_color, *track_color = *theme_trough_color; } -CairoCachedSurface* GtkThemeProvider::GetSurfaceNamed( +CairoCachedSurface* GtkThemeService::GetSurfaceNamed( int id, GtkWidget* widget_on_display) { return GetSurfaceNamedImpl(id, @@ -532,11 +531,11 @@ CairoCachedSurface* GtkThemeProvider::GetSurfaceNamed( widget_on_display); } -CairoCachedSurface* GtkThemeProvider::GetRTLEnabledSurfaceNamed( +CairoCachedSurface* GtkThemeService::GetRTLEnabledSurfaceNamed( int id, GtkWidget* widget_on_display) { // We flip the sign of |id| when passing it to GetSurfaceNamedImpl() for the - // same reason that BrowserThemeProvider::GetPixbufImpl() does: so that if one + // same reason that ThemeService::GetPixbufImpl() does: so that if one // location calls this function with a resource ID, and another place calls // GetSurfaceNamed() with the same ID, they'll correctly get different // surfaces in RTL mode. @@ -546,7 +545,7 @@ CairoCachedSurface* GtkThemeProvider::GetRTLEnabledSurfaceNamed( widget_on_display); } -CairoCachedSurface* GtkThemeProvider::GetUnthemedSurfaceNamed( +CairoCachedSurface* GtkThemeService::GetUnthemedSurfaceNamed( int id, GtkWidget* widget_on_display) { return GetSurfaceNamedImpl(id, @@ -556,7 +555,7 @@ CairoCachedSurface* GtkThemeProvider::GetUnthemedSurfaceNamed( } // static -GdkPixbuf* GtkThemeProvider::GetFolderIcon(bool native) { +GdkPixbuf* GtkThemeService::GetFolderIcon(bool native) { if (native) { if (!icon_widget_) icon_widget_ = gtk_window_new(GTK_WINDOW_TOPLEVEL); @@ -577,7 +576,7 @@ GdkPixbuf* GtkThemeProvider::GetFolderIcon(bool native) { } // static -GdkPixbuf* GtkThemeProvider::GetDefaultFavicon(bool native) { +GdkPixbuf* GtkThemeService::GetDefaultFavicon(bool native) { if (native) { if (!icon_widget_) icon_widget_ = gtk_window_new(GTK_WINDOW_TOPLEVEL); @@ -598,7 +597,7 @@ GdkPixbuf* GtkThemeProvider::GetDefaultFavicon(bool native) { } // static -bool GtkThemeProvider::DefaultUsesSystemTheme() { +bool GtkThemeService::DefaultUsesSystemTheme() { scoped_ptr<base::Environment> env(base::Environment::Create()); switch (base::nix::GetDesktopEnvironment(env.get())) { @@ -610,26 +609,26 @@ bool GtkThemeProvider::DefaultUsesSystemTheme() { } } -void GtkThemeProvider::ClearAllThemeData() { +void GtkThemeService::ClearAllThemeData() { colors_.clear(); tints_.clear(); - BrowserThemeProvider::ClearAllThemeData(); + ThemeService::ClearAllThemeData(); } -void GtkThemeProvider::LoadThemePrefs() { +void GtkThemeService::LoadThemePrefs() { if (use_gtk_) { LoadGtkValues(); } else { LoadDefaultValues(); - BrowserThemeProvider::LoadThemePrefs(); + ThemeService::LoadThemePrefs(); } RebuildMenuIconSets(); } -void GtkThemeProvider::NotifyThemeChanged(const Extension* extension) { - BrowserThemeProvider::NotifyThemeChanged(extension); +void GtkThemeService::NotifyThemeChanged(const Extension* extension) { + ThemeService::NotifyThemeChanged(extension); // Notify all GtkChromeButtons of their new rendering mode: for (std::vector<GtkWidget*>::iterator it = chrome_buttons_.begin(); @@ -644,15 +643,15 @@ void GtkThemeProvider::NotifyThemeChanged(const Extension* extension) { } } -void GtkThemeProvider::FreePlatformCaches() { - BrowserThemeProvider::FreePlatformCaches(); +void GtkThemeService::FreePlatformCaches() { + ThemeService::FreePlatformCaches(); FreePerDisplaySurfaces(&per_display_surfaces_); FreePerDisplaySurfaces(&per_display_unthemed_surfaces_); STLDeleteValues(>k_images_); } -void GtkThemeProvider::OnStyleSet(GtkWidget* widget, - GtkStyle* previous_style) { +void GtkThemeService::OnStyleSet(GtkWidget* widget, + GtkStyle* previous_style) { GdkPixbuf* default_folder_icon = default_folder_icon_; GdkPixbuf* default_bookmark_icon = default_bookmark_icon_; default_folder_icon_ = NULL; @@ -674,7 +673,7 @@ void GtkThemeProvider::OnStyleSet(GtkWidget* widget, g_object_unref(default_bookmark_icon); } -void GtkThemeProvider::LoadGtkValues() { +void GtkThemeService::LoadGtkValues() { // Before we start setting images and values, we have to clear out old, stale // values. (If we don't do this, we'll regress startup time in the case where // someone installs a heavyweight theme, then goes back to GTK.) @@ -685,21 +684,21 @@ void GtkThemeProvider::LoadGtkValues() { GtkStyle* frame_style = gtk_rc_get_style(fake_frame_); GtkStyle* window_style = gtk_rc_get_style(fake_window_); - SetThemeColorFromGtk(BrowserThemeProvider::COLOR_CONTROL_BACKGROUND, + SetThemeColorFromGtk(ThemeService::COLOR_CONTROL_BACKGROUND, &window_style->bg[GTK_STATE_NORMAL]); - SetThemeColorFromGtk(BrowserThemeProvider::COLOR_BUTTON_BACKGROUND, + SetThemeColorFromGtk(ThemeService::COLOR_BUTTON_BACKGROUND, &window_style->bg[GTK_STATE_NORMAL]); GdkColor toolbar_color = window_style->bg[GTK_STATE_NORMAL]; - SetThemeColorFromGtk(BrowserThemeProvider::COLOR_TOOLBAR, &toolbar_color); + SetThemeColorFromGtk(ThemeService::COLOR_TOOLBAR, &toolbar_color); GdkColor button_color = window_style->bg[GTK_STATE_SELECTED]; - SetThemeTintFromGtk(BrowserThemeProvider::TINT_BUTTONS, &button_color); + SetThemeTintFromGtk(ThemeService::TINT_BUTTONS, &button_color); GtkStyle* label_style = gtk_rc_get_style(fake_label_.get()); GdkColor label_color = label_style->fg[GTK_STATE_NORMAL]; - SetThemeColorFromGtk(BrowserThemeProvider::COLOR_TAB_TEXT, &label_color); - SetThemeColorFromGtk(BrowserThemeProvider::COLOR_BOOKMARK_TEXT, &label_color); + SetThemeColorFromGtk(ThemeService::COLOR_TAB_TEXT, &label_color); + SetThemeColorFromGtk(ThemeService::COLOR_BOOKMARK_TEXT, &label_color); // Build the various icon tints. GetNormalButtonTintHSL(&button_tint_); @@ -723,7 +722,7 @@ void GtkThemeProvider::LoadGtkValues() { else inactive_tab_text_hsl.s = kLightInactiveSaturation; - colors_[BrowserThemeProvider::COLOR_BACKGROUND_TAB_TEXT] = + colors_[ThemeService::COLOR_BACKGROUND_TAB_TEXT] = color_utils::HSLToSkColor(inactive_tab_text_hsl, 255); // We pick the text and background colors for the NTP out of the colors for a @@ -734,9 +733,9 @@ void GtkThemeProvider::LoadGtkValues() { GtkStyle* entry_style = gtk_rc_get_style(fake_entry_.get()); GdkColor ntp_background = entry_style->base[GTK_STATE_NORMAL]; GdkColor ntp_foreground = entry_style->text[GTK_STATE_NORMAL]; - SetThemeColorFromGtk(BrowserThemeProvider::COLOR_NTP_BACKGROUND, + SetThemeColorFromGtk(ThemeService::COLOR_NTP_BACKGROUND, &ntp_background); - SetThemeColorFromGtk(BrowserThemeProvider::COLOR_NTP_TEXT, + SetThemeColorFromGtk(ThemeService::COLOR_NTP_TEXT, &ntp_foreground); // The NTP header is the color that surrounds the current active thumbnail on @@ -744,11 +743,11 @@ void GtkThemeProvider::LoadGtkValues() { // awesome if they were separated so we could use GetBorderColor() for the // border around the "Recent Links" section, but matching the frame color is // more important. - SetThemeColorFromGtk(BrowserThemeProvider::COLOR_NTP_HEADER, + SetThemeColorFromGtk(ThemeService::COLOR_NTP_HEADER, &frame_color); - SetThemeColorFromGtk(BrowserThemeProvider::COLOR_NTP_SECTION, + SetThemeColorFromGtk(ThemeService::COLOR_NTP_SECTION, &toolbar_color); - SetThemeColorFromGtk(BrowserThemeProvider::COLOR_NTP_SECTION_TEXT, + SetThemeColorFromGtk(ThemeService::COLOR_NTP_SECTION_TEXT, &label_color); // Override the link color if the theme provides it. @@ -758,21 +757,21 @@ void GtkThemeProvider::LoadGtkValues() { if (!link_color) link_color = &kDefaultLinkColor; - SetThemeColorFromGtk(BrowserThemeProvider::COLOR_NTP_LINK, + SetThemeColorFromGtk(ThemeService::COLOR_NTP_LINK, link_color); - SetThemeColorFromGtk(BrowserThemeProvider::COLOR_NTP_LINK_UNDERLINE, + SetThemeColorFromGtk(ThemeService::COLOR_NTP_LINK_UNDERLINE, link_color); - SetThemeColorFromGtk(BrowserThemeProvider::COLOR_NTP_SECTION_LINK, + SetThemeColorFromGtk(ThemeService::COLOR_NTP_SECTION_LINK, link_color); - SetThemeColorFromGtk(BrowserThemeProvider::COLOR_NTP_SECTION_LINK_UNDERLINE, + SetThemeColorFromGtk(ThemeService::COLOR_NTP_SECTION_LINK_UNDERLINE, link_color); // Generate the colors that we pass to WebKit. focus_ring_color_ = GdkToSkColor(&frame_color); GdkColor thumb_active_color, thumb_inactive_color, track_color; - GtkThemeProvider::GetScrollbarColors(&thumb_active_color, - &thumb_inactive_color, - &track_color); + GtkThemeService::GetScrollbarColors(&thumb_active_color, + &thumb_inactive_color, + &track_color); thumb_active_color_ = GdkToSkColor(&thumb_active_color); thumb_inactive_color_ = GdkToSkColor(&thumb_inactive_color); track_color_ = GdkToSkColor(&track_color); @@ -789,7 +788,7 @@ void GtkThemeProvider::LoadGtkValues() { GdkToSkColor(&entry_style->text[GTK_STATE_ACTIVE]); } -GdkColor GtkThemeProvider::BuildFrameColors(GtkStyle* frame_style) { +GdkColor GtkThemeService::BuildFrameColors(GtkStyle* frame_style) { const GdkColor* theme_frame = NULL; const GdkColor* theme_inactive_frame = NULL; const GdkColor* theme_incognito_frame = NULL; @@ -806,35 +805,35 @@ GdkColor GtkThemeProvider::BuildFrameColors(GtkStyle* frame_style) { &frame_style->bg[GTK_STATE_SELECTED], theme_frame, kDefaultFrameShift, - BrowserThemeProvider::COLOR_FRAME, - BrowserThemeProvider::TINT_FRAME); - SetThemeTintFromGtk(BrowserThemeProvider::TINT_BACKGROUND_TAB, &frame_color); + ThemeService::COLOR_FRAME, + ThemeService::TINT_FRAME); + SetThemeTintFromGtk(ThemeService::TINT_BACKGROUND_TAB, &frame_color); BuildAndSetFrameColor( &frame_style->bg[GTK_STATE_INSENSITIVE], theme_inactive_frame, kDefaultFrameShift, - BrowserThemeProvider::COLOR_FRAME_INACTIVE, - BrowserThemeProvider::TINT_FRAME_INACTIVE); + ThemeService::COLOR_FRAME_INACTIVE, + ThemeService::TINT_FRAME_INACTIVE); BuildAndSetFrameColor( &frame_color, theme_incognito_frame, - GetDefaultTint(BrowserThemeProvider::TINT_FRAME_INCOGNITO), - BrowserThemeProvider::COLOR_FRAME_INCOGNITO, - BrowserThemeProvider::TINT_FRAME_INCOGNITO); + GetDefaultTint(ThemeService::TINT_FRAME_INCOGNITO), + ThemeService::COLOR_FRAME_INCOGNITO, + ThemeService::TINT_FRAME_INCOGNITO); BuildAndSetFrameColor( &frame_color, theme_incognito_inactive_frame, - GetDefaultTint(BrowserThemeProvider::TINT_FRAME_INCOGNITO_INACTIVE), - BrowserThemeProvider::COLOR_FRAME_INCOGNITO_INACTIVE, - BrowserThemeProvider::TINT_FRAME_INCOGNITO_INACTIVE); + GetDefaultTint(ThemeService::TINT_FRAME_INCOGNITO_INACTIVE), + ThemeService::COLOR_FRAME_INCOGNITO_INACTIVE, + ThemeService::TINT_FRAME_INCOGNITO_INACTIVE); return frame_color; } -void GtkThemeProvider::LoadDefaultValues() { +void GtkThemeService::LoadDefaultValues() { focus_ring_color_ = SkColorSetARGB(255, 229, 151, 0); thumb_active_color_ = SkColorSetRGB(244, 244, 244); thumb_inactive_color_ = SkColorSetRGB(234, 234, 234); @@ -846,7 +845,7 @@ void GtkThemeProvider::LoadDefaultValues() { inactive_selection_fg_color_ = SkColorSetRGB(50, 50, 50); } -void GtkThemeProvider::RebuildMenuIconSets() { +void GtkThemeService::RebuildMenuIconSets() { FreeIconSets(); GtkStyle* style = gtk_rc_get_style(fake_menu_item_.get()); @@ -862,11 +861,11 @@ void GtkThemeProvider::RebuildMenuIconSets() { fullscreen_icon_set_); } -void GtkThemeProvider::SetThemeColorFromGtk(int id, const GdkColor* color) { +void GtkThemeService::SetThemeColorFromGtk(int id, const GdkColor* color) { colors_[id] = GdkToSkColor(color); } -void GtkThemeProvider::SetThemeTintFromGtk(int id, const GdkColor* color) { +void GtkThemeService::SetThemeTintFromGtk(int id, const GdkColor* color) { color_utils::HSL default_tint = GetDefaultTint(id); color_utils::HSL hsl; color_utils::SkColorToHSL(GdkToSkColor(color), &hsl); @@ -880,11 +879,11 @@ void GtkThemeProvider::SetThemeTintFromGtk(int id, const GdkColor* color) { tints_[id] = hsl; } -GdkColor GtkThemeProvider::BuildAndSetFrameColor(const GdkColor* base, - const GdkColor* gtk_base, - const color_utils::HSL& tint, - int color_id, - int tint_id) { +GdkColor GtkThemeService::BuildAndSetFrameColor(const GdkColor* base, + const GdkColor* gtk_base, + const color_utils::HSL& tint, + int color_id, + int tint_id) { GdkColor out_color = *base; if (gtk_base) { // The theme author specified a color to use, use it without modification. @@ -900,7 +899,7 @@ GdkColor GtkThemeProvider::BuildAndSetFrameColor(const GdkColor* base, return out_color; } -void GtkThemeProvider::FreePerDisplaySurfaces( +void GtkThemeService::FreePerDisplaySurfaces( PerDisplaySurfaceMap* per_display_map) { for (PerDisplaySurfaceMap::iterator it = per_display_map->begin(); it != per_display_map->end(); ++it) { @@ -912,14 +911,14 @@ void GtkThemeProvider::FreePerDisplaySurfaces( per_display_map->clear(); } -void GtkThemeProvider::FreeIconSets() { +void GtkThemeService::FreeIconSets() { if (fullscreen_icon_set_) { gtk_icon_set_unref(fullscreen_icon_set_); fullscreen_icon_set_ = NULL; } } -SkBitmap* GtkThemeProvider::GenerateGtkThemeBitmap(int id) const { +SkBitmap* GtkThemeService::GenerateGtkThemeBitmap(int id) const { switch (id) { case IDR_THEME_TOOLBAR: { GtkStyle* style = gtk_rc_get_style(fake_window_); @@ -936,17 +935,17 @@ SkBitmap* GtkThemeProvider::GenerateGtkThemeBitmap(int id) const { case IDR_THEME_TAB_BACKGROUND_INCOGNITO: return GenerateTabImage(IDR_THEME_FRAME_INCOGNITO); case IDR_THEME_FRAME: - return GenerateFrameImage(BrowserThemeProvider::COLOR_FRAME, + return GenerateFrameImage(ThemeService::COLOR_FRAME, "frame-gradient-color"); case IDR_THEME_FRAME_INACTIVE: - return GenerateFrameImage(BrowserThemeProvider::COLOR_FRAME_INACTIVE, + return GenerateFrameImage(ThemeService::COLOR_FRAME_INACTIVE, "inactive-frame-gradient-color"); case IDR_THEME_FRAME_INCOGNITO: - return GenerateFrameImage(BrowserThemeProvider::COLOR_FRAME_INCOGNITO, + return GenerateFrameImage(ThemeService::COLOR_FRAME_INCOGNITO, "incognito-frame-gradient-color"); case IDR_THEME_FRAME_INCOGNITO_INACTIVE: { return GenerateFrameImage( - BrowserThemeProvider::COLOR_FRAME_INCOGNITO_INACTIVE, + ThemeService::COLOR_FRAME_INCOGNITO_INACTIVE, "incognito-inactive-frame-gradient-color"); } // Icons that sit inside the omnibox shouldn't receive TINT_BUTTONS and @@ -977,7 +976,7 @@ SkBitmap* GtkThemeProvider::GenerateGtkThemeBitmap(int id) const { } } -SkBitmap* GtkThemeProvider::GenerateFrameImage( +SkBitmap* GtkThemeService::GenerateFrameImage( int color_id, const char* gradient_name) const { // We use two colors: the main color (passed in) and a lightened version of @@ -1015,15 +1014,15 @@ SkBitmap* GtkThemeProvider::GenerateFrameImage( return new SkBitmap(canvas.ExtractBitmap()); } -SkBitmap* GtkThemeProvider::GenerateTabImage(int base_id) const { +SkBitmap* GtkThemeService::GenerateTabImage(int base_id) const { SkBitmap* base_image = GetBitmapNamed(base_id); SkBitmap bg_tint = SkBitmapOperations::CreateHSLShiftedBitmap( - *base_image, GetTint(BrowserThemeProvider::TINT_BACKGROUND_TAB)); + *base_image, GetTint(ThemeService::TINT_BACKGROUND_TAB)); return new SkBitmap(SkBitmapOperations::CreateTiledBitmap( bg_tint, 0, 0, bg_tint.width(), bg_tint.height())); } -SkBitmap* GtkThemeProvider::GenerateTintedIcon( +SkBitmap* GtkThemeService::GenerateTintedIcon( int base_id, const color_utils::HSL& tint) const { ResourceBundle& rb = ResourceBundle::GetSharedInstance(); @@ -1032,7 +1031,7 @@ SkBitmap* GtkThemeProvider::GenerateTintedIcon( *button, tint)); } -void GtkThemeProvider::GetNormalButtonTintHSL( +void GtkThemeService::GetNormalButtonTintHSL( color_utils::HSL* tint) const { GtkStyle* window_style = gtk_rc_get_style(fake_window_); const GdkColor accent_gdk_color = window_style->bg[GTK_STATE_SELECTED]; @@ -1044,7 +1043,7 @@ void GtkThemeProvider::GetNormalButtonTintHSL( PickButtonTintFromColors(accent_gdk_color, text_color, base_color, tint); } -void GtkThemeProvider::GetNormalEntryForegroundHSL( +void GtkThemeService::GetNormalEntryForegroundHSL( color_utils::HSL* tint) const { GtkStyle* window_style = gtk_rc_get_style(fake_window_); const GdkColor accent_gdk_color = window_style->bg[GTK_STATE_SELECTED]; @@ -1056,7 +1055,7 @@ void GtkThemeProvider::GetNormalEntryForegroundHSL( PickButtonTintFromColors(accent_gdk_color, text_color, base_color, tint); } -void GtkThemeProvider::GetSelectedEntryForegroundHSL( +void GtkThemeService::GetSelectedEntryForegroundHSL( color_utils::HSL* tint) const { // The simplest of all the tints. We just use the selected text in the entry // since the icons tinted this way will only be displayed against @@ -1066,7 +1065,7 @@ void GtkThemeProvider::GetSelectedEntryForegroundHSL( color_utils::SkColorToHSL(GdkToSkColor(&color), tint); } -CairoCachedSurface* GtkThemeProvider::GetSurfaceNamedImpl( +CairoCachedSurface* GtkThemeService::GetSurfaceNamedImpl( int id, PerDisplaySurfaceMap* display_surface_map, GdkPixbuf* pixbuf, @@ -1087,15 +1086,15 @@ CairoCachedSurface* GtkThemeProvider::GetSurfaceNamedImpl( return surface; } -void GtkThemeProvider::OnDestroyChromeButton(GtkWidget* button) { +void GtkThemeService::OnDestroyChromeButton(GtkWidget* button) { std::vector<GtkWidget*>::iterator it = find(chrome_buttons_.begin(), chrome_buttons_.end(), button); if (it != chrome_buttons_.end()) chrome_buttons_.erase(it); } -gboolean GtkThemeProvider::OnSeparatorExpose(GtkWidget* widget, - GdkEventExpose* event) { +gboolean GtkThemeService::OnSeparatorExpose(GtkWidget* widget, + GdkEventExpose* event) { if (UseGtkTheme()) return FALSE; @@ -1103,7 +1102,7 @@ gboolean GtkThemeProvider::OnSeparatorExpose(GtkWidget* widget, gdk_cairo_rectangle(cr, &event->area); cairo_clip(cr); - GdkColor bottom_color = GetGdkColor(BrowserThemeProvider::COLOR_TOOLBAR); + GdkColor bottom_color = GetGdkColor(ThemeService::COLOR_TOOLBAR); double bottom_color_rgb[] = { static_cast<double>(bottom_color.red / 257) / 255.0, static_cast<double>(bottom_color.green / 257) / 255.0, @@ -1130,7 +1129,7 @@ gboolean GtkThemeProvider::OnSeparatorExpose(GtkWidget* widget, cairo_set_line_width(cr, 1.0); cairo_move_to(cr, start_x, widget->allocation.y); cairo_line_to(cr, start_x, - widget->allocation.y + widget->allocation.height); + widget->allocation.y + widget->allocation.height); cairo_stroke(cr); cairo_destroy(cr); cairo_pattern_destroy(pattern); diff --git a/chrome/browser/ui/gtk/gtk_theme_provider.h b/chrome/browser/ui/gtk/gtk_theme_service.h index cdaed61..0b3f3da 100644 --- a/chrome/browser/ui/gtk/gtk_theme_provider.h +++ b/chrome/browser/ui/gtk/gtk_theme_service.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_UI_GTK_GTK_THEME_PROVIDER_H_ -#define CHROME_BROWSER_UI_GTK_GTK_THEME_PROVIDER_H_ +#ifndef CHROME_BROWSER_UI_GTK_GTK_THEME_SERVICE_H_ +#define CHROME_BROWSER_UI_GTK_GTK_THEME_SERVICE_H_ #pragma once #include <map> @@ -11,7 +11,7 @@ #include "base/scoped_ptr.h" #include "chrome/browser/prefs/pref_change_registrar.h" -#include "chrome/browser/themes/browser_theme_provider.h" +#include "chrome/browser/themes/theme_service.h" #include "chrome/browser/ui/gtk/owned_widget_gtk.h" #include "content/common/notification_observer.h" #include "ui/base/gtk/gtk_integers.h" @@ -32,24 +32,24 @@ typedef struct _GtkIconSet GtkIconSet; typedef struct _GtkStyle GtkStyle; typedef struct _GtkWidget GtkWidget; -// Specialization of BrowserThemeProvider which supplies system colors. -class GtkThemeProvider : public BrowserThemeProvider, - public NotificationObserver { +// Specialization of ThemeService which supplies system colors. +class GtkThemeService : public ThemeService, + public NotificationObserver { public: - // Returns GtkThemeProvider, casted from our superclass. - static GtkThemeProvider* GetFrom(Profile* profile); + // Returns GtkThemeService, casted from our superclass. + static GtkThemeService* GetFrom(Profile* profile); - GtkThemeProvider(); - virtual ~GtkThemeProvider(); + GtkThemeService(); + virtual ~GtkThemeService(); // Calls |observer|.Observe() for the browser theme with this provider as the // source. void InitThemesFor(NotificationObserver* observer); - // Overridden from BrowserThemeProvider: + // Overridden from ThemeService: // // Sets that we aren't using the system theme, then calls - // BrowserThemeProvider's implementation. + // ThemeService's implementation. virtual void Init(Profile* profile); virtual SkBitmap* GetBitmapNamed(int id) const; virtual SkColor GetColor(int id) const; @@ -107,7 +107,7 @@ class GtkThemeProvider : public BrowserThemeProvider, GtkWidget* widget_on_display); // Same as above, but gets the resource from the ResourceBundle instead of the - // BrowserThemeProvider. + // ThemeService. // NOTE: Never call this with resource IDs that are ever passed to the above // two functions! Depending on which call comes first, all callers will // either get the themed or the unthemed version. @@ -163,7 +163,7 @@ class GtkThemeProvider : public BrowserThemeProvider, virtual void FreePlatformCaches(); // Extracts colors and tints from the GTK theme, both for the - // BrowserThemeProvider interface and the colors we send to webkit. + // ThemeService interface and the colors we send to webkit. void LoadGtkValues(); // Reads in explicit theme frame colors from the ChromeGtkFrame style class @@ -192,9 +192,9 @@ class GtkThemeProvider : public BrowserThemeProvider, int tint_id); // Split out from FreePlatformCaches so it can be called in our destructor; - // FreePlatformCaches() is called from the BrowserThemeProvider's destructor, - // but by the time ~BrowserThemeProvider() is run, the vtable no longer - // points to GtkThemeProvider's version. + // FreePlatformCaches() is called from the ThemeService's destructor, + // but by the time ~ThemeService() is run, the vtable no longer + // points to GtkThemeService's version. void FreePerDisplaySurfaces(PerDisplaySurfaceMap* per_display_map); // Frees all the created GtkIconSets we use for the chrome menu. @@ -214,7 +214,7 @@ class GtkThemeProvider : public BrowserThemeProvider, SkBitmap* GenerateTabImage(int base_id) const; // Tints an icon based on tint. - SkBitmap* GenerateTintedIcon(int base_id, + SkBitmap* GenerateTintedIcon(int base_id, const color_utils::HSL& tint) const; // Returns the tint for buttons that contrasts with the normal window @@ -235,13 +235,13 @@ class GtkThemeProvider : public BrowserThemeProvider, GtkWidget* widget_on_display); // Handles signal from GTK that our theme has been changed. - CHROMEGTK_CALLBACK_1(GtkThemeProvider, void, OnStyleSet, GtkStyle*); + CHROMEGTK_CALLBACK_1(GtkThemeService, void, OnStyleSet, GtkStyle*); // A notification from the GtkChromeButton GObject destructor that we should // remove it from our internal list. - CHROMEGTK_CALLBACK_0(GtkThemeProvider, void, OnDestroyChromeButton); + CHROMEGTK_CALLBACK_0(GtkThemeService, void, OnDestroyChromeButton); - CHROMEGTK_CALLBACK_1(GtkThemeProvider, gboolean, OnSeparatorExpose, + CHROMEGTK_CALLBACK_1(GtkThemeService, gboolean, OnSeparatorExpose, GdkEventExpose*); // Whether we should be using gtk rendering. @@ -310,4 +310,4 @@ class GtkThemeProvider : public BrowserThemeProvider, static GdkPixbuf* default_bookmark_icon_; }; -#endif // CHROME_BROWSER_UI_GTK_GTK_THEME_PROVIDER_H_ +#endif // CHROME_BROWSER_UI_GTK_GTK_THEME_SERVICE_H_ diff --git a/chrome/browser/ui/gtk/gtk_theme_provider_unittest.cc b/chrome/browser/ui/gtk/gtk_theme_service_unittest.cc index 28d2fab..7ba0313 100644 --- a/chrome/browser/ui/gtk/gtk_theme_provider_unittest.cc +++ b/chrome/browser/ui/gtk/gtk_theme_service_unittest.cc @@ -6,7 +6,7 @@ #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/ui/gtk/gtk_theme_provider.h" +#include "chrome/browser/ui/gtk/gtk_theme_service.h" #include "chrome/common/pref_names.h" #include "chrome/test/testing_profile.h" #include "grit/theme_resources.h" @@ -23,37 +23,37 @@ SkColor GdkToSkColor(GdkColor* color) { } // namespace -class GtkThemeProviderTest : public testing::Test { +class GtkThemeServiceTest : public testing::Test { public: - GtkThemeProviderTest() : provider_(NULL) {} + GtkThemeServiceTest() : provider_(NULL) {} void SetUseGtkTheme(bool use_gtk_theme) { profile_.GetPrefs()->SetBoolean(prefs::kUsesSystemTheme, use_gtk_theme); } void BuildProvider() { - provider_ = GtkThemeProvider::GetFrom(&profile_); + provider_ = GtkThemeService::GetFrom(&profile_); } protected: TestingProfile profile_; - GtkThemeProvider* provider_; + GtkThemeService* provider_; }; -TEST_F(GtkThemeProviderTest, DefaultValues) { +TEST_F(GtkThemeServiceTest, DefaultValues) { SetUseGtkTheme(false); BuildProvider(); // Test that we get the default theme colors back when in normal mode. - for (int i = BrowserThemeProvider::COLOR_FRAME; - i <= BrowserThemeProvider::COLOR_BUTTON_BACKGROUND; ++i) { - EXPECT_EQ(provider_->GetColor(i), BrowserThemeProvider::GetDefaultColor(i)) + for (int i = ThemeService::COLOR_FRAME; + i <= ThemeService::COLOR_BUTTON_BACKGROUND; ++i) { + EXPECT_EQ(provider_->GetColor(i), ThemeService::GetDefaultColor(i)) << "Wrong default color for " << i; } } -TEST_F(GtkThemeProviderTest, UsingGtkValues) { +TEST_F(GtkThemeServiceTest, UsingGtkValues) { SetUseGtkTheme(true); BuildProvider(); @@ -65,6 +65,6 @@ TEST_F(GtkThemeProviderTest, UsingGtkValues) { GtkWidget* fake_label = provider_->fake_label(); GtkStyle* label_style = gtk_rc_get_style(fake_label); GdkColor label_color = label_style->fg[GTK_STATE_NORMAL]; - EXPECT_EQ(provider_->GetColor(BrowserThemeProvider::COLOR_TAB_TEXT), + EXPECT_EQ(provider_->GetColor(ThemeService::COLOR_TAB_TEXT), GdkToSkColor(&label_color)); } diff --git a/chrome/browser/ui/gtk/gtk_tree.cc b/chrome/browser/ui/gtk/gtk_tree.cc index 9ff0416..8351c3f 100644 --- a/chrome/browser/ui/gtk/gtk_tree.cc +++ b/chrome/browser/ui/gtk/gtk_tree.cc @@ -6,7 +6,7 @@ #include "base/logging.h" #include "base/utf_string_conversions.h" -#include "chrome/browser/ui/gtk/gtk_theme_provider.h" +#include "chrome/browser/ui/gtk/gtk_theme_service.h" #include "third_party/skia/include/core/SkBitmap.h" #include "ui/base/models/table_model.h" #include "ui/gfx/gtk_util.h" @@ -383,7 +383,7 @@ void TreeAdapter::FillRow(GtkTreeIter* iter, ui::TreeModelNode* node) { if (icon_index >= 0 && icon_index < static_cast<int>(pixbufs_.size())) pixbuf = pixbufs_[icon_index]; else - pixbuf = GtkThemeProvider::GetFolderIcon(true); + pixbuf = GtkThemeService::GetFolderIcon(true); gtk_tree_store_set(tree_store_, iter, COL_ICON, pixbuf, COL_TITLE, UTF16ToUTF8(node->GetTitle()).c_str(), diff --git a/chrome/browser/ui/gtk/gtk_util.cc b/chrome/browser/ui/gtk/gtk_util.cc index a7b46eb..84e7e9b 100644 --- a/chrome/browser/ui/gtk/gtk_util.cc +++ b/chrome/browser/ui/gtk/gtk_util.cc @@ -25,7 +25,7 @@ #include "chrome/browser/browser_window.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/gtk/cairo_cached_surface.h" -#include "chrome/browser/ui/gtk/gtk_theme_provider.h" +#include "chrome/browser/ui/gtk/gtk_theme_service.h" #include "content/browser/disposition_utils.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/tab_contents/tab_contents.h" @@ -809,17 +809,17 @@ void DrawThemedToolbarBackground(GtkWidget* widget, cairo_t* cr, GdkEventExpose* event, const gfx::Point& tabstrip_origin, - GtkThemeProvider* theme_provider) { + GtkThemeService* theme_service) { // Fill the entire region with the toolbar color. - GdkColor color = theme_provider->GetGdkColor( - BrowserThemeProvider::COLOR_TOOLBAR); + GdkColor color = theme_service->GetGdkColor( + ThemeService::COLOR_TOOLBAR); gdk_cairo_set_source_color(cr, &color); cairo_fill(cr); // The toolbar is supposed to blend in with the active tab, so we have to pass // coordinates for the IDR_THEME_TOOLBAR bitmap relative to the top of the // tab strip. - CairoCachedSurface* background = theme_provider->GetSurfaceNamed( + CairoCachedSurface* background = theme_service->GetSurfaceNamed( IDR_THEME_TOOLBAR, widget); background->SetSource(cr, tabstrip_origin.x(), tabstrip_origin.y()); // We tile the toolbar background in both directions. diff --git a/chrome/browser/ui/gtk/gtk_util.h b/chrome/browser/ui/gtk/gtk_util.h index c0113c3..cd59366 100644 --- a/chrome/browser/ui/gtk/gtk_util.h +++ b/chrome/browser/ui/gtk/gtk_util.h @@ -22,7 +22,7 @@ typedef struct _GdkColor GdkColor; typedef struct _GtkWidget GtkWidget; class BrowserWindow; -class GtkThemeProvider; +class GtkThemeService; class GURL; class Profile; struct RendererPreferences; // from common/renderer_preferences.h @@ -252,7 +252,7 @@ void DrawThemedToolbarBackground(GtkWidget* widget, cairo_t* cr, GdkEventExpose* event, const gfx::Point& tabstrip_origin, - GtkThemeProvider* provider); + GtkThemeService* provider); // Returns the two colors averaged together. GdkColor AverageColors(GdkColor color_one, GdkColor color_two); diff --git a/chrome/browser/ui/gtk/info_bubble_gtk.cc b/chrome/browser/ui/gtk/info_bubble_gtk.cc index f942674..b6a037a 100644 --- a/chrome/browser/ui/gtk/info_bubble_gtk.cc +++ b/chrome/browser/ui/gtk/info_bubble_gtk.cc @@ -9,7 +9,7 @@ #include "base/basictypes.h" #include "base/logging.h" -#include "chrome/browser/ui/gtk/gtk_theme_provider.h" +#include "chrome/browser/ui/gtk/gtk_theme_service.h" #include "chrome/browser/ui/gtk/gtk_util.h" #include "chrome/browser/ui/gtk/info_bubble_accelerators_gtk.h" #include "content/common/notification_service.h" @@ -51,7 +51,7 @@ InfoBubbleGtk* InfoBubbleGtk::Show(GtkWidget* anchor_widget, ArrowLocationGtk arrow_location, bool match_system_theme, bool grab_input, - GtkThemeProvider* provider, + GtkThemeService* provider, InfoBubbleGtkDelegate* delegate) { InfoBubbleGtk* bubble = new InfoBubbleGtk(provider, match_system_theme); bubble->Init(anchor_widget, rect, content, arrow_location, grab_input); @@ -59,11 +59,11 @@ InfoBubbleGtk* InfoBubbleGtk::Show(GtkWidget* anchor_widget, return bubble; } -InfoBubbleGtk::InfoBubbleGtk(GtkThemeProvider* provider, +InfoBubbleGtk::InfoBubbleGtk(GtkThemeService* provider, bool match_system_theme) : delegate_(NULL), window_(NULL), - theme_provider_(provider), + theme_service_(provider), accel_group_(gtk_accel_group_new()), toplevel_window_(NULL), anchor_widget_(NULL), @@ -182,7 +182,7 @@ void InfoBubbleGtk::Init(GtkWidget* anchor_widget, registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, NotificationService::AllSources()); - theme_provider_->InitThemesFor(this); + theme_service_->InitThemesFor(this); } // NOTE: This seems a bit overcomplicated, but it requires a bunch of careful @@ -346,7 +346,7 @@ void InfoBubbleGtk::Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { DCHECK_EQ(type.value, NotificationType::BROWSER_THEME_CHANGED); - if (theme_provider_->UseGtkTheme() && match_system_theme_) { + if (theme_service_->UseGtkTheme() && match_system_theme_) { gtk_widget_modify_bg(window_, GTK_STATE_NORMAL, NULL); } else { // Set the background color, so we don't need to paint it manually. diff --git a/chrome/browser/ui/gtk/info_bubble_gtk.h b/chrome/browser/ui/gtk/info_bubble_gtk.h index f45f80c..891b27d 100644 --- a/chrome/browser/ui/gtk/info_bubble_gtk.h +++ b/chrome/browser/ui/gtk/info_bubble_gtk.h @@ -25,7 +25,7 @@ #include "ui/gfx/point.h" #include "ui/gfx/rect.h" -class GtkThemeProvider; +class GtkThemeService; class InfoBubbleGtk; namespace gfx { class Rect; @@ -68,7 +68,7 @@ class InfoBubbleGtk : public NotificationObserver { ArrowLocationGtk arrow_location, bool match_system_theme, bool grab_input, - GtkThemeProvider* provider, + GtkThemeService* provider, InfoBubbleGtkDelegate* delegate); // Close the bubble if it's open. This will delete the widgets and object, @@ -96,7 +96,7 @@ class InfoBubbleGtk : public NotificationObserver { FRAME_STROKE, }; - explicit InfoBubbleGtk(GtkThemeProvider* provider, bool match_system_theme); + explicit InfoBubbleGtk(GtkThemeService* provider, bool match_system_theme); virtual ~InfoBubbleGtk(); // Creates the InfoBubble. @@ -166,7 +166,7 @@ class InfoBubbleGtk : public NotificationObserver { GtkWidget* window_; // Provides colors and stuff. - GtkThemeProvider* theme_provider_; + GtkThemeService* theme_service_; // The accel group attached to |window_|, to handle closing with escape. GtkAccelGroup* accel_group_; diff --git a/chrome/browser/ui/gtk/infobars/infobar_container_gtk.cc b/chrome/browser/ui/gtk/infobars/infobar_container_gtk.cc index a125ee1..ef766a7 100644 --- a/chrome/browser/ui/gtk/infobars/infobar_container_gtk.cc +++ b/chrome/browser/ui/gtk/infobars/infobar_container_gtk.cc @@ -13,7 +13,7 @@ #include "chrome/browser/platform_util.h" #include "chrome/browser/tab_contents/infobar_delegate.h" #include "chrome/browser/ui/gtk/browser_window_gtk.h" -#include "chrome/browser/ui/gtk/gtk_theme_provider.h" +#include "chrome/browser/ui/gtk/gtk_theme_service.h" #include "chrome/browser/ui/gtk/gtk_util.h" #include "chrome/browser/ui/gtk/infobars/infobar_gtk.h" #include "content/browser/tab_contents/tab_contents.h" @@ -178,7 +178,7 @@ void InfoBarContainerGtk::ShowArrowForDelegate(InfoBarDelegate* delegate, void InfoBarContainerGtk::AddInfoBar(InfoBarDelegate* delegate, bool animate) { InfoBar* infobar = delegate->CreateInfoBar(); infobar->set_container(this); - infobar->SetThemeProvider(GtkThemeProvider::GetFrom(profile_)); + infobar->SetThemeProvider(GtkThemeService::GetFrom(profile_)); gtk_box_pack_start(GTK_BOX(widget()), infobar->widget(), FALSE, FALSE, 0); diff --git a/chrome/browser/ui/gtk/infobars/infobar_gtk.cc b/chrome/browser/ui/gtk/infobars/infobar_gtk.cc index 3df712a..453db8a 100644 --- a/chrome/browser/ui/gtk/infobars/infobar_gtk.cc +++ b/chrome/browser/ui/gtk/infobars/infobar_gtk.cc @@ -11,7 +11,7 @@ #include "chrome/browser/ui/gtk/browser_window_gtk.h" #include "chrome/browser/ui/gtk/custom_button.h" #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h" -#include "chrome/browser/ui/gtk/gtk_theme_provider.h" +#include "chrome/browser/ui/gtk/gtk_theme_service.h" #include "chrome/browser/ui/gtk/gtk_util.h" #include "chrome/browser/ui/gtk/infobars/infobar_container_gtk.h" #include "content/common/notification_service.h" @@ -40,7 +40,7 @@ const int InfoBar::kButtonButtonSpacing = 3; InfoBar::InfoBar(InfoBarDelegate* delegate) : container_(NULL), delegate_(delegate), - theme_provider_(NULL), + theme_service_(NULL), arrow_model_(this) { // Create |hbox_| and pad the sides. hbox_ = gtk_hbox_new(FALSE, kElementPadding); @@ -148,13 +148,13 @@ void InfoBar::Closed() { Close(); } -void InfoBar::SetThemeProvider(GtkThemeProvider* theme_provider) { - if (theme_provider_) { +void InfoBar::SetThemeProvider(GtkThemeService* theme_service) { + if (theme_service_) { NOTREACHED(); return; } - theme_provider_ = theme_provider; + theme_service_ = theme_service; registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, NotificationService::AllSources()); UpdateBorderColor(); @@ -276,7 +276,7 @@ gboolean InfoBar::OnBackgroundExpose(GtkWidget* sender, cairo_pattern_destroy(pattern); // Draw the bottom border. - GdkColor border_color = theme_provider_->GetBorderColor(); + GdkColor border_color = theme_service_->GetBorderColor(); cairo_set_source_rgb(cr, border_color.red / 65535.0, border_color.green / 65535.0, border_color.blue / 65535.0); diff --git a/chrome/browser/ui/gtk/infobars/infobar_gtk.h b/chrome/browser/ui/gtk/infobars/infobar_gtk.h index 3b5d23f..cda753d 100644 --- a/chrome/browser/ui/gtk/infobars/infobar_gtk.h +++ b/chrome/browser/ui/gtk/infobars/infobar_gtk.h @@ -18,7 +18,7 @@ #include "ui/base/gtk/gtk_signal.h" class CustomDrawButton; -class GtkThemeProvider; +class GtkThemeService; class InfoBarContainerGtk; class InfoBarDelegate; @@ -59,7 +59,7 @@ class InfoBar : public SlideAnimatorGtk::Delegate, // Returns true if the infobar is showing the close animation. bool IsClosing(); - void SetThemeProvider(GtkThemeProvider* theme_provider); + void SetThemeProvider(GtkThemeService* theme_provider); // Show an arrow that originates from another infobar (i.e. a bar was added // below this one). If |other| is NULL, stop showing the arrow. @@ -124,7 +124,7 @@ class InfoBar : public SlideAnimatorGtk::Delegate, InfoBarDelegate* delegate_; // The theme provider, used for getting border colors. - GtkThemeProvider* theme_provider_; + GtkThemeService* theme_service_; // The model that tracks the paint state of the arrow for the infobar // below this one (if it exists). diff --git a/chrome/browser/ui/gtk/location_bar_view_gtk.cc b/chrome/browser/ui/gtk/location_bar_view_gtk.cc index 77af1c3..29768db 100644 --- a/chrome/browser/ui/gtk/location_bar_view_gtk.cc +++ b/chrome/browser/ui/gtk/location_bar_view_gtk.cc @@ -38,7 +38,7 @@ #include "chrome/browser/ui/gtk/content_setting_bubble_gtk.h" #include "chrome/browser/ui/gtk/extensions/extension_popup_gtk.h" #include "chrome/browser/ui/gtk/first_run_bubble.h" -#include "chrome/browser/ui/gtk/gtk_theme_provider.h" +#include "chrome/browser/ui/gtk/gtk_theme_service.h" #include "chrome/browser/ui/gtk/gtk_util.h" #include "chrome/browser/ui/gtk/nine_box.h" #include "chrome/browser/ui/gtk/rounded_window.h" @@ -164,7 +164,7 @@ LocationBarViewGtk::LocationBarViewGtk(Browser* browser) transition_(PageTransition::TYPED), first_run_bubble_(this), popup_window_mode_(false), - theme_provider_(NULL), + theme_service_(NULL), hbox_width_(0), entry_box_width_(0), show_selected_keyword_(false), @@ -323,8 +323,8 @@ void LocationBarViewGtk::Init(bool popup_window_mode) { registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, NotificationService::AllSources()); - theme_provider_ = GtkThemeProvider::GetFrom(profile_); - theme_provider_->InitThemesFor(this); + theme_service_ = GtkThemeService::GetFrom(profile_); + theme_service_->InitThemesFor(this); } void LocationBarViewGtk::BuildSiteTypeArea() { @@ -452,7 +452,7 @@ void LocationBarViewGtk::Update(const TabContents* contents) { UpdatePageActions(); location_entry_->Update(contents); // The security level (background color) could have changed, etc. - if (theme_provider_->UseGtkTheme()) { + if (theme_service_->UseGtkTheme()) { // In GTK mode, we need our parent to redraw, as it draws the text entry // border. gtk_widget_queue_draw(widget()->parent); @@ -761,11 +761,11 @@ void LocationBarViewGtk::Observe(NotificationType type, const NotificationDetails& details) { DCHECK_EQ(type.value, NotificationType::BROWSER_THEME_CHANGED); - if (theme_provider_->UseGtkTheme()) { + if (theme_service_->UseGtkTheme()) { gtk_widget_modify_bg(tab_to_search_box_, GTK_STATE_NORMAL, NULL); - GdkColor border_color = theme_provider_->GetGdkColor( - BrowserThemeProvider::COLOR_FRAME); + GdkColor border_color = theme_service_->GetGdkColor( + ThemeService::COLOR_FRAME); gtk_util::SetRoundedWindowBorderColor(tab_to_search_box_, border_color); gtk_util::SetLabelColor(tab_to_search_full_label_, NULL); @@ -831,7 +831,7 @@ gboolean LocationBarViewGtk::HandleExpose(GtkWidget* widget, // If we're not using GTK theming, draw our own border over the edge pixels // of the background. if (!profile_ || - !GtkThemeProvider::GetFrom(profile_)->UseGtkTheme()) { + !GtkThemeService::GetFrom(profile_)->UseGtkTheme()) { int left, center, right; if (popup_window_mode_) { left = right = IDR_LOCATIONBG_POPUPMODE_EDGE; @@ -861,7 +861,7 @@ void LocationBarViewGtk::UpdateSiteTypeArea() { int resource_id = location_entry_->GetIcon(); gtk_image_set_from_pixbuf(GTK_IMAGE(location_icon_image_), - theme_provider_->GetPixbufNamed(resource_id)); + theme_service_->GetPixbufNamed(resource_id)); if (toolbar_model_->GetSecurityLevel() == ToolbarModel::EV_SECURE) { if (!gtk_util::IsActingAsRoundedWindow(site_type_event_box_)) { @@ -1085,7 +1085,7 @@ void LocationBarViewGtk::OnIconDragBegin(GtkWidget* sender, if (!pixbuf) return; drag_icon_ = bookmark_utils::GetDragRepresentation(pixbuf, - GetTitle(), theme_provider_); + GetTitle(), theme_service_); g_object_unref(pixbuf); gtk_drag_set_icon_widget(context, drag_icon_, 0, 0); } @@ -1140,7 +1140,7 @@ void LocationBarViewGtk::UpdateStarIcon() { return; gtk_image_set_from_pixbuf(GTK_IMAGE(star_image_), - theme_provider_->GetPixbufNamed( + theme_service_->GetPixbufNamed( starred_ ? IDR_STAR_LIT : IDR_STAR)); } @@ -1270,7 +1270,7 @@ void LocationBarViewGtk::ContentSettingImageViewGtk::UpdateFromTabContents( } gtk_image_set_from_pixbuf(GTK_IMAGE(image_.get()), - GtkThemeProvider::GetFrom(profile_)->GetPixbufNamed( + GtkThemeService::GetFrom(profile_)->GetPixbufNamed( content_setting_image_model_->get_icon())); gtk_widget_set_tooltip_text(widget(), diff --git a/chrome/browser/ui/gtk/location_bar_view_gtk.h b/chrome/browser/ui/gtk/location_bar_view_gtk.h index 5d489b2..c0fb744 100644 --- a/chrome/browser/ui/gtk/location_bar_view_gtk.h +++ b/chrome/browser/ui/gtk/location_bar_view_gtk.h @@ -38,7 +38,7 @@ class CommandUpdater; class ContentSettingImageModel; class ContentSettingBubbleGtk; class ExtensionAction; -class GtkThemeProvider; +class GtkThemeService; class Profile; class SkBitmap; class TabContents; @@ -430,7 +430,7 @@ class LocationBarViewGtk : public AutocompleteEditController, bool popup_window_mode_; // Provides colors and rendering mode. - GtkThemeProvider* theme_provider_; + GtkThemeService* theme_service_; NotificationRegistrar registrar_; diff --git a/chrome/browser/ui/gtk/notifications/balloon_view_gtk.cc b/chrome/browser/ui/gtk/notifications/balloon_view_gtk.cc index 064c5cc..102507c 100644 --- a/chrome/browser/ui/gtk/notifications/balloon_view_gtk.cc +++ b/chrome/browser/ui/gtk/notifications/balloon_view_gtk.cc @@ -20,9 +20,9 @@ #include "chrome/browser/notifications/notification.h" #include "chrome/browser/notifications/notification_options_menu_model.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/themes/browser_theme_provider.h" +#include "chrome/browser/themes/theme_service.h" #include "chrome/browser/ui/gtk/custom_button.h" -#include "chrome/browser/ui/gtk/gtk_theme_provider.h" +#include "chrome/browser/ui/gtk/gtk_theme_service.h" #include "chrome/browser/ui/gtk/gtk_util.h" #include "chrome/browser/ui/gtk/info_bubble_gtk.h" #include "chrome/browser/ui/gtk/menu_gtk.h" @@ -201,7 +201,7 @@ void BalloonViewImpl::AnimationProgressed(const ui::Animation* animation) { } void BalloonViewImpl::Show(Balloon* balloon) { - theme_provider_ = GtkThemeProvider::GetFrom(balloon->profile()); + theme_service_ = GtkThemeService::GetFrom(balloon->profile()); const std::string source_label_text = l10n_util::GetStringFUTF8( IDS_NOTIFICATION_BALLOON_SOURCE_LABEL, diff --git a/chrome/browser/ui/gtk/notifications/balloon_view_gtk.h b/chrome/browser/ui/gtk/notifications/balloon_view_gtk.h index f065af9..49fa4db 100644 --- a/chrome/browser/ui/gtk/notifications/balloon_view_gtk.h +++ b/chrome/browser/ui/gtk/notifications/balloon_view_gtk.h @@ -23,7 +23,7 @@ class BalloonCollection; class CustomDrawButton; -class GtkThemeProvider; +class GtkThemeService; class MenuGtk; class NotificationDetails; class NotificationOptionsMenuModel; @@ -96,7 +96,7 @@ class BalloonViewImpl : public BalloonView, // Non-owned pointer to the balloon which owns this object. Balloon* balloon_; - GtkThemeProvider* theme_provider_; + GtkThemeService* theme_service_; // The window that contains the frame of the notification. GtkWidget* frame_container_; diff --git a/chrome/browser/ui/gtk/overflow_button.cc b/chrome/browser/ui/gtk/overflow_button.cc index 7762370..c2cab94 100644 --- a/chrome/browser/ui/gtk/overflow_button.cc +++ b/chrome/browser/ui/gtk/overflow_button.cc @@ -7,19 +7,19 @@ #include <gtk/gtk.h> #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/ui/gtk/gtk_theme_provider.h" +#include "chrome/browser/ui/gtk/gtk_theme_service.h" #include "content/common/notification_service.h" #include "content/common/notification_type.h" #include "grit/theme_resources.h" #include "ui/base/resource/resource_bundle.h" OverflowButton::OverflowButton(Profile* profile) : profile_(profile) { - widget_.Own(GtkThemeProvider::GetFrom(profile)->BuildChromeButton()); + widget_.Own(GtkThemeService::GetFrom(profile)->BuildChromeButton()); gtk_widget_set_no_show_all(widget_.get(), TRUE); registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, NotificationService::AllSources()); - GtkThemeProvider::GetFrom(profile)->InitThemesFor(this); + GtkThemeService::GetFrom(profile)->InitThemesFor(this); } OverflowButton::~OverflowButton() { @@ -34,7 +34,7 @@ void OverflowButton::Observe(NotificationType type, gtk_widget_destroy(former_child); GtkWidget* new_child = - GtkThemeProvider::GetFrom(profile_)->UseGtkTheme() ? + GtkThemeService::GetFrom(profile_)->UseGtkTheme() ? gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_NONE) : gtk_image_new_from_pixbuf(ResourceBundle::GetSharedInstance(). GetRTLEnabledPixbufNamed(IDR_BOOKMARK_BAR_CHEVRONS)); diff --git a/chrome/browser/ui/gtk/page_info_bubble_gtk.cc b/chrome/browser/ui/gtk/page_info_bubble_gtk.cc index 76b09cd..5a6ee14 100644 --- a/chrome/browser/ui/gtk/page_info_bubble_gtk.cc +++ b/chrome/browser/ui/gtk/page_info_bubble_gtk.cc @@ -15,7 +15,7 @@ #include "chrome/browser/ui/gtk/browser_toolbar_gtk.h" #include "chrome/browser/ui/gtk/browser_window_gtk.h" #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h" -#include "chrome/browser/ui/gtk/gtk_theme_provider.h" +#include "chrome/browser/ui/gtk/gtk_theme_service.h" #include "chrome/browser/ui/gtk/gtk_util.h" #include "chrome/browser/ui/gtk/info_bubble_gtk.h" #include "chrome/browser/ui/gtk/location_bar_view_gtk.h" @@ -86,7 +86,7 @@ class PageInfoBubbleGtk : public PageInfoModel::PageInfoModelObserver, GtkWidget* anchor_; // Provides colors and stuff. - GtkThemeProvider* theme_provider_; + GtkThemeService* theme_service_; // The various elements in the interface we keep track of for theme changes. std::vector<GtkWidget*> labels_; @@ -110,7 +110,7 @@ PageInfoBubbleGtk::PageInfoBubbleGtk(gfx::NativeWindow parent, cert_id_(ssl.cert_id()), parent_(parent), contents_(NULL), - theme_provider_(GtkThemeProvider::GetFrom(profile)) { + theme_service_(GtkThemeService::GetFrom(profile)) { BrowserWindowGtk* browser_window = BrowserWindowGtk::GetBrowserWindowForNativeWindow(parent); @@ -131,7 +131,7 @@ PageInfoBubbleGtk::PageInfoBubbleGtk(gfx::NativeWindow parent, arrow_location, true, // |match_system_theme| true, // |grab_input| - theme_provider_, + theme_service_, this); // |delegate| if (!bubble_) { NOTREACHED(); @@ -155,10 +155,10 @@ void PageInfoBubbleGtk::Observe(NotificationType type, it != links_.end(); ++it) { gtk_chrome_link_button_set_use_gtk_theme( GTK_CHROME_LINK_BUTTON(*it), - theme_provider_->UseGtkTheme()); + theme_service_->UseGtkTheme()); } - if (theme_provider_->UseGtkTheme()) { + if (theme_service_->UseGtkTheme()) { for (std::vector<GtkWidget*>::iterator it = labels_.begin(); it != labels_.end(); ++it) { gtk_widget_modify_fg(*it, GTK_STATE_NORMAL, NULL); @@ -206,7 +206,7 @@ void PageInfoBubbleGtk::InitContents() { g_signal_connect(help_link, "clicked", G_CALLBACK(OnHelpLinkClickedThunk), this); - theme_provider_->InitThemesFor(this); + theme_service_->InitThemesFor(this); gtk_widget_show_all(contents_); } diff --git a/chrome/browser/ui/gtk/reload_button_gtk.cc b/chrome/browser/ui/gtk/reload_button_gtk.cc index a91931f..34ffdf9 100644 --- a/chrome/browser/ui/gtk/reload_button_gtk.cc +++ b/chrome/browser/ui/gtk/reload_button_gtk.cc @@ -10,7 +10,7 @@ #include "chrome/app/chrome_command_ids.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/gtk/gtk_chrome_button.h" -#include "chrome/browser/ui/gtk/gtk_theme_provider.h" +#include "chrome/browser/ui/gtk/gtk_theme_service.h" #include "chrome/browser/ui/gtk/gtk_util.h" #include "chrome/browser/ui/gtk/location_bar_view_gtk.h" #include "content/common/notification_source.h" @@ -32,10 +32,10 @@ ReloadButtonGtk::ReloadButtonGtk(LocationBarViewGtk* location_bar, browser_(browser), intended_mode_(MODE_RELOAD), visible_mode_(MODE_RELOAD), - theme_provider_(browser ? - GtkThemeProvider::GetFrom(browser->profile()) : NULL), - reload_(theme_provider_, IDR_RELOAD, IDR_RELOAD_P, IDR_RELOAD_H, 0), - stop_(theme_provider_, IDR_STOP, IDR_STOP_P, IDR_STOP_H, IDR_STOP_D), + theme_service_(browser ? + GtkThemeService::GetFrom(browser->profile()) : NULL), + reload_(theme_service_, IDR_RELOAD, IDR_RELOAD_P, IDR_RELOAD_H, 0), + stop_(theme_service_, IDR_STOP, IDR_STOP_P, IDR_STOP_H, IDR_STOP_D), widget_(gtk_chrome_button_new()), stop_to_reload_timer_delay_(base::TimeDelta::FromMilliseconds(1350)), testing_mouse_hovered_(false), @@ -57,11 +57,11 @@ ReloadButtonGtk::ReloadButtonGtk(LocationBarViewGtk* location_bar, hover_controller_.Init(widget()); gtk_util::SetButtonTriggersNavigation(widget()); - if (theme_provider_) { - theme_provider_->InitThemesFor(this); + if (theme_service_) { + theme_service_->InitThemesFor(this); registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, - Source<GtkThemeProvider>(theme_provider_)); + Source<GtkThemeService>(theme_service_)); } // Set the default double-click timer delay to the system double-click time. @@ -131,9 +131,9 @@ void ReloadButtonGtk::Observe(NotificationType type, const NotificationDetails& /* details */) { DCHECK(NotificationType::BROWSER_THEME_CHANGED == type); - GtkThemeProvider* provider = static_cast<GtkThemeProvider*>( - Source<GtkThemeProvider>(source).ptr()); - DCHECK_EQ(provider, theme_provider_); + GtkThemeService* provider = static_cast<GtkThemeService*>( + Source<GtkThemeService>(source).ptr()); + DCHECK_EQ(provider, theme_service_); GtkButtonWidth = 0; UpdateThemeButtons(); } @@ -194,7 +194,7 @@ void ReloadButtonGtk::OnClicked(GtkWidget* /* sender */) { gboolean ReloadButtonGtk::OnExpose(GtkWidget* widget, GdkEventExpose* e) { - if (theme_provider_ && theme_provider_->UseGtkTheme()) + if (theme_service_ && theme_service_->UseGtkTheme()) return FALSE; return ((visible_mode_ == MODE_RELOAD) ? reload_ : stop_).OnExpose( widget, e, hover_controller_.GetCurrentValue()); @@ -222,7 +222,7 @@ gboolean ReloadButtonGtk::OnQueryTooltip(GtkWidget* /* sender */, } void ReloadButtonGtk::UpdateThemeButtons() { - bool use_gtk = theme_provider_ && theme_provider_->UseGtkTheme(); + bool use_gtk = theme_service_ && theme_service_->UseGtkTheme(); if (use_gtk) { gtk_widget_ensure_style(widget()); diff --git a/chrome/browser/ui/gtk/reload_button_gtk.h b/chrome/browser/ui/gtk/reload_button_gtk.h index 356b1e6..d5752fa 100644 --- a/chrome/browser/ui/gtk/reload_button_gtk.h +++ b/chrome/browser/ui/gtk/reload_button_gtk.h @@ -17,7 +17,7 @@ #include "ui/base/gtk/gtk_signal.h" class Browser; -class GtkThemeProvider; +class GtkThemeService; class LocationBarViewGtk; class Task; @@ -77,7 +77,7 @@ class ReloadButtonGtk : public NotificationObserver { // Used to listen for theme change notifications. NotificationRegistrar registrar_; - GtkThemeProvider* theme_provider_; + GtkThemeService* theme_service_; CustomDrawButtonBase reload_; CustomDrawButtonBase stop_; diff --git a/chrome/browser/ui/gtk/status_bubble_gtk.cc b/chrome/browser/ui/gtk/status_bubble_gtk.cc index de735bb..1be0c4f 100644 --- a/chrome/browser/ui/gtk/status_bubble_gtk.cc +++ b/chrome/browser/ui/gtk/status_bubble_gtk.cc @@ -11,7 +11,7 @@ #include "base/i18n/rtl.h" #include "base/message_loop.h" #include "base/utf_string_conversions.h" -#include "chrome/browser/ui/gtk/gtk_theme_provider.h" +#include "chrome/browser/ui/gtk/gtk_theme_service.h" #include "chrome/browser/ui/gtk/gtk_util.h" #include "chrome/browser/ui/gtk/rounded_window.h" #include "chrome/browser/ui/gtk/slide_animator_gtk.h" @@ -38,7 +38,7 @@ const int kMousePadding = 20; } // namespace StatusBubbleGtk::StatusBubbleGtk(Profile* profile) - : theme_provider_(GtkThemeProvider::GetFrom(profile)), + : theme_service_(GtkThemeService::GetFrom(profile)), padding_(NULL), flip_horizontally_(false), y_offset_(0), @@ -48,7 +48,7 @@ StatusBubbleGtk::StatusBubbleGtk(Profile* profile) ignore_next_left_content_(false) { InitWidgets(); - theme_provider_->InitThemesFor(this); + theme_service_->InitThemesFor(this); registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, NotificationService::AllSources()); } @@ -278,7 +278,7 @@ void StatusBubbleGtk::InitWidgets() { } void StatusBubbleGtk::UserChangedTheme() { - if (theme_provider_->UseGtkTheme()) { + if (theme_service_->UseGtkTheme()) { gtk_widget_modify_fg(label_.get(), GTK_STATE_NORMAL, NULL); gtk_widget_modify_bg(container_.get(), GTK_STATE_NORMAL, NULL); } else { @@ -286,16 +286,16 @@ void StatusBubbleGtk::UserChangedTheme() { // toolbar" that I can find. Maybe in later iterations of the theme system, // there will be a better color to pick. GdkColor bookmark_text = - theme_provider_->GetGdkColor(BrowserThemeProvider::COLOR_BOOKMARK_TEXT); + theme_service_->GetGdkColor(ThemeService::COLOR_BOOKMARK_TEXT); gtk_widget_modify_fg(label_.get(), GTK_STATE_NORMAL, &bookmark_text); GdkColor toolbar_color = - theme_provider_->GetGdkColor(BrowserThemeProvider::COLOR_TOOLBAR); + theme_service_->GetGdkColor(ThemeService::COLOR_TOOLBAR); gtk_widget_modify_bg(container_.get(), GTK_STATE_NORMAL, &toolbar_color); } gtk_util::SetRoundedWindowBorderColor(container_.get(), - theme_provider_->GetBorderColor()); + theme_service_->GetBorderColor()); } void StatusBubbleGtk::SetFlipHorizontally(bool flip_horizontally) { diff --git a/chrome/browser/ui/gtk/status_bubble_gtk.h b/chrome/browser/ui/gtk/status_bubble_gtk.h index 484d852..6d8c2c7 100644 --- a/chrome/browser/ui/gtk/status_bubble_gtk.h +++ b/chrome/browser/ui/gtk/status_bubble_gtk.h @@ -21,7 +21,7 @@ #include "ui/base/gtk/gtk_signal.h" #include "ui/gfx/point.h" -class GtkThemeProvider; +class GtkThemeService; class Profile; namespace ui { @@ -114,7 +114,7 @@ class StatusBubbleGtk : public StatusBubble, NotificationRegistrar registrar_; // Provides colors. - GtkThemeProvider* theme_provider_; + GtkThemeService* theme_service_; // The toplevel event box. OwnedWidgetGtk container_; diff --git a/chrome/browser/ui/gtk/tabs/dragged_tab_gtk.cc b/chrome/browser/ui/gtk/tabs/dragged_tab_gtk.cc index a557fe3..f3ff218 100644 --- a/chrome/browser/ui/gtk/tabs/dragged_tab_gtk.cc +++ b/chrome/browser/ui/gtk/tabs/dragged_tab_gtk.cc @@ -11,8 +11,8 @@ #include "base/i18n/rtl.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/tabs/tab_strip_model.h" -#include "chrome/browser/themes/browser_theme_provider.h" #include "chrome/browser/themes/theme_service.h" +#include "chrome/browser/themes/theme_service_factory.h" #include "chrome/browser/ui/gtk/gtk_util.h" #include "chrome/browser/ui/gtk/tabs/tab_renderer_gtk.h" #include "content/browser/renderer_host/backing_store_x.h" diff --git a/chrome/browser/ui/gtk/tabs/tab_renderer_gtk.cc b/chrome/browser/ui/gtk/tabs/tab_renderer_gtk.cc index 18f0867..77ec714 100644 --- a/chrome/browser/ui/gtk/tabs/tab_renderer_gtk.cc +++ b/chrome/browser/ui/gtk/tabs/tab_renderer_gtk.cc @@ -13,7 +13,7 @@ #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.h" #include "chrome/browser/ui/gtk/custom_button.h" -#include "chrome/browser/ui/gtk/gtk_theme_provider.h" +#include "chrome/browser/ui/gtk/gtk_theme_service.h" #include "chrome/browser/ui/gtk/gtk_util.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "content/browser/tab_contents/tab_contents.h" @@ -149,7 +149,7 @@ SkColor TabRendererGtk::unselected_title_color_ = SkColorSetRGB(64, 64, 64); TabRendererGtk::LoadingAnimation::LoadingAnimation( ui::ThemeProvider* theme_provider) : data_(new Data(theme_provider)), - theme_provider_(theme_provider), + theme_service_(theme_provider), animation_state_(ANIMATION_NONE), animation_frame_(0) { registrar_.Add(this, @@ -160,7 +160,7 @@ TabRendererGtk::LoadingAnimation::LoadingAnimation( TabRendererGtk::LoadingAnimation::LoadingAnimation( const LoadingAnimation::Data& data) : data_(new Data(data)), - theme_provider_(NULL), + theme_service_(NULL), animation_state_(ANIMATION_NONE), animation_frame_(0) { } @@ -201,7 +201,7 @@ void TabRendererGtk::LoadingAnimation::Observe( const NotificationSource& source, const NotificationDetails& details) { DCHECK(type == NotificationType::BROWSER_THEME_CHANGED); - data_.reset(new Data(theme_provider_)); + data_.reset(new Data(theme_service_)); } //////////////////////////////////////////////////////////////////////////////// @@ -285,7 +285,7 @@ void TabRendererGtk::UpdateData(TabContents* contents, bool app, bool loading_only) { DCHECK(contents); - theme_provider_ = GtkThemeProvider::GetFrom(contents->profile()); + theme_service_ = GtkThemeService::GetFrom(contents->profile()); if (!loading_only) { data_.title = contents->GetTitle(); @@ -391,10 +391,10 @@ void TabRendererGtk::PaintFaviconArea(GdkEventExpose* event) { } else { theme_id = IDR_THEME_TAB_BACKGROUND_INCOGNITO; } - if (!theme_provider_->HasCustomImage(theme_id)) + if (!theme_service_->HasCustomImage(theme_id)) offset_y = background_offset_y_; } - SkBitmap* tab_bg = theme_provider_->GetBitmapNamed(theme_id); + SkBitmap* tab_bg = theme_service_->GetBitmapNamed(theme_id); canvas.TileImageInt(*tab_bg, x() + favicon_bounds_.x(), offset_y + favicon_bounds_.y(), favicon_bounds_.x(), favicon_bounds_.y(), @@ -409,7 +409,7 @@ void TabRendererGtk::PaintFaviconArea(GdkEventExpose* event) { canvas.saveLayerAlpha(&bounds, static_cast<int>(throb_value * 0xff), SkCanvas::kARGB_ClipLayer_SaveFlag); canvas.drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode); - SkBitmap* active_bg = theme_provider_->GetBitmapNamed(IDR_THEME_TOOLBAR); + SkBitmap* active_bg = theme_service_->GetBitmapNamed(IDR_THEME_TOOLBAR); canvas.TileImageInt(*active_bg, x() + favicon_bounds_.x(), favicon_bounds_.y(), favicon_bounds_.x(), favicon_bounds_.y(), @@ -702,9 +702,9 @@ void TabRendererGtk::Layout() { close_button_height_); // If the close button color has changed, generate a new one. - if (theme_provider_) { + if (theme_service_) { SkColor tab_text_color = - theme_provider_->GetColor(BrowserThemeProvider::COLOR_TAB_TEXT); + theme_service_->GetColor(ThemeService::COLOR_TAB_TEXT); if (!close_button_color_ || tab_text_color != close_button_color_) { close_button_color_ = tab_text_color; ResourceBundle& rb = ResourceBundle::GetSharedInstance(); @@ -837,8 +837,8 @@ void TabRendererGtk::PaintIcon(gfx::Canvas* canvas) { true); } else { if (!data_.favicon.isNull()) { - if (data_.is_default_favicon && theme_provider_->UseGtkTheme()) { - GdkPixbuf* favicon = GtkThemeProvider::GetDefaultFavicon(true); + if (data_.is_default_favicon && theme_service_->UseGtkTheme()) { + GdkPixbuf* favicon = GtkThemeService::GetDefaultFavicon(true); canvas->AsCanvasSkia()->DrawGdkPixbuf( favicon, favicon_bounds_.x(), favicon_bounds_.y() + favicon_hiding_offset_); @@ -897,12 +897,12 @@ void TabRendererGtk::PaintInactiveTabBackground(gfx::Canvas* canvas) { int tab_id = data_.incognito ? IDR_THEME_TAB_BACKGROUND_INCOGNITO : IDR_THEME_TAB_BACKGROUND; - SkBitmap* tab_bg = theme_provider_->GetBitmapNamed(tab_id); + SkBitmap* tab_bg = theme_service_->GetBitmapNamed(tab_id); // If the theme is providing a custom background image, then its top edge // should be at the top of the tab. Otherwise, we assume that the background // image is a composited foreground + frame image. - int offset_y = theme_provider_->HasCustomImage(tab_id) ? + int offset_y = theme_service_->HasCustomImage(tab_id) ? 0 : background_offset_y_; // Draw left edge. @@ -932,7 +932,7 @@ void TabRendererGtk::PaintInactiveTabBackground(gfx::Canvas* canvas) { void TabRendererGtk::PaintActiveTabBackground(gfx::Canvas* canvas) { int offset_x = background_offset_x_; - SkBitmap* tab_bg = theme_provider_->GetBitmapNamed(IDR_THEME_TOOLBAR); + SkBitmap* tab_bg = theme_service_->GetBitmapNamed(IDR_THEME_TOOLBAR); // Draw left edge. SkBitmap* theme_l = GetMaskedBitmap(tab_alpha_.image_l, tab_bg, offset_x, 0); diff --git a/chrome/browser/ui/gtk/tabs/tab_renderer_gtk.h b/chrome/browser/ui/gtk/tabs/tab_renderer_gtk.h index 43c6b36..d061710 100644 --- a/chrome/browser/ui/gtk/tabs/tab_renderer_gtk.h +++ b/chrome/browser/ui/gtk/tabs/tab_renderer_gtk.h @@ -27,7 +27,7 @@ class Size; } // namespace gfx class CustomDrawButton; -class GtkThemeProvider; +class GtkThemeService; class TabContents; namespace ui { @@ -93,7 +93,7 @@ class TabRendererGtk : public ui::AnimationDelegate, NotificationRegistrar registrar_; // Gives us our throbber images. - ui::ThemeProvider* theme_provider_; + ui::ThemeProvider* theme_service_; // Current state of the animation. AnimationState animation_state_; @@ -439,7 +439,7 @@ class TabRendererGtk : public ui::AnimationDelegate, // alignment in the BrowserTitlebar. int background_offset_y_; - GtkThemeProvider* theme_provider_; + GtkThemeService* theme_service_; // The close button. scoped_ptr<CustomDrawButton> close_button_; diff --git a/chrome/browser/ui/gtk/tabs/tab_strip_gtk.cc b/chrome/browser/ui/gtk/tabs/tab_strip_gtk.cc index 383fbf0..aa22e47 100644 --- a/chrome/browser/ui/gtk/tabs/tab_strip_gtk.cc +++ b/chrome/browser/ui/gtk/tabs/tab_strip_gtk.cc @@ -14,12 +14,12 @@ #include "chrome/browser/autocomplete/autocomplete_match.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/tabs/tab_strip_model_delegate.h" -#include "chrome/browser/themes/browser_theme_provider.h" +#include "chrome/browser/themes/theme_service.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_navigator.h" #include "chrome/browser/ui/gtk/browser_window_gtk.h" #include "chrome/browser/ui/gtk/custom_button.h" -#include "chrome/browser/ui/gtk/gtk_theme_provider.h" +#include "chrome/browser/ui/gtk/gtk_theme_service.h" #include "chrome/browser/ui/gtk/gtk_util.h" #include "chrome/browser/ui/gtk/tabs/dragged_tab_controller_gtk.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" @@ -697,10 +697,10 @@ TabStripGtk::TabStripGtk(TabStripModel* model, BrowserWindowGtk* window) tab_vertical_offset_(0), model_(model), window_(window), - theme_provider_(GtkThemeProvider::GetFrom(model->profile())), + theme_service_(GtkThemeService::GetFrom(model->profile())), resize_layout_factory_(this), added_as_message_loop_observer_(false) { - theme_provider_->InitThemesFor(this); + theme_service_->InitThemesFor(this); registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, NotificationService::AllSources()); } @@ -1207,7 +1207,7 @@ bool TabStripGtk::HasAvailableDragActions() const { } ui::ThemeProvider* TabStripGtk::GetThemeProvider() { - return theme_provider_; + return theme_service_; } /////////////////////////////////////////////////////////////////////////////// @@ -1235,10 +1235,10 @@ void TabStripGtk::Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { if (type == NotificationType::BROWSER_THEME_CHANGED) { - TabRendererGtk::SetSelectedTitleColor(theme_provider_->GetColor( - BrowserThemeProvider::COLOR_TAB_TEXT)); - TabRendererGtk::SetUnselectedTitleColor(theme_provider_->GetColor( - BrowserThemeProvider::COLOR_BACKGROUND_TAB_TEXT)); + TabRendererGtk::SetSelectedTitleColor(theme_service_->GetColor( + ThemeService::COLOR_TAB_TEXT)); + TabRendererGtk::SetUnselectedTitleColor(theme_service_->GetColor( + ThemeService::COLOR_BACKGROUND_TAB_TEXT)); } } diff --git a/chrome/browser/ui/gtk/tabs/tab_strip_gtk.h b/chrome/browser/ui/gtk/tabs/tab_strip_gtk.h index c3391ba..febe4bc 100644 --- a/chrome/browser/ui/gtk/tabs/tab_strip_gtk.h +++ b/chrome/browser/ui/gtk/tabs/tab_strip_gtk.h @@ -24,7 +24,7 @@ class BrowserWindowGtk; class CustomDrawButton; class DraggedTabControllerGtk; -class GtkThemeProvider; +class GtkThemeService; class TabStripGtk : public TabStripModelObserver, public TabGtk::TabDelegate, @@ -438,7 +438,7 @@ class TabStripGtk : public TabStripModelObserver, BrowserWindowGtk* window_; // Theme resources. - GtkThemeProvider* theme_provider_; + GtkThemeService* theme_service_; // The currently running animation. scoped_ptr<TabAnimation> active_animation_; diff --git a/chrome/browser/ui/gtk/task_manager_gtk.cc b/chrome/browser/ui/gtk/task_manager_gtk.cc index 62a3a4e..d137122 100644 --- a/chrome/browser/ui/gtk/task_manager_gtk.cc +++ b/chrome/browser/ui/gtk/task_manager_gtk.cc @@ -20,7 +20,7 @@ #include "chrome/browser/memory_purger.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h" -#include "chrome/browser/ui/gtk/gtk_theme_provider.h" +#include "chrome/browser/ui/gtk/gtk_theme_service.h" #include "chrome/browser/ui/gtk/gtk_tree.h" #include "chrome/browser/ui/gtk/gtk_util.h" #include "chrome/common/chrome_switches.h" @@ -724,7 +724,7 @@ GdkPixbuf* TaskManagerGtk::GetModelIcon(int row) { ResourceBundle::GetSharedInstance().GetBitmapNamed( IDR_DEFAULT_FAVICON)->pixelRef()) { return static_cast<GdkPixbuf*>(g_object_ref( - GtkThemeProvider::GetDefaultFavicon(true))); + GtkThemeService::GetDefaultFavicon(true))); } return gfx::GdkPixbufFromSkBitmap(&icon); diff --git a/chrome/browser/ui/touch/tabs/touch_tab.cc b/chrome/browser/ui/touch/tabs/touch_tab.cc index 1245799..b5812a9 100644 --- a/chrome/browser/ui/touch/tabs/touch_tab.cc +++ b/chrome/browser/ui/touch/tabs/touch_tab.cc @@ -5,7 +5,7 @@ #include "chrome/browser/ui/touch/tabs/touch_tab.h" #include "base/logging.h" -#include "chrome/browser/themes/browser_theme_provider.h" +#include "chrome/browser/themes/theme_service.h" #include "grit/app_resources.h" #include "grit/theme_resources.h" #include "ui/base/resource/resource_bundle.h" @@ -67,8 +67,8 @@ void TouchTab::OnPaint(gfx::Canvas* canvas) { SkColor title_color = GetThemeProvider()-> GetColor(IsSelected() ? - BrowserThemeProvider::COLOR_TAB_TEXT : - BrowserThemeProvider::COLOR_BACKGROUND_TAB_TEXT); + ThemeService::COLOR_TAB_TEXT : + ThemeService::COLOR_BACKGROUND_TAB_TEXT); PaintTitle(canvas, title_color); PaintIcon(canvas); diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_instructions_view.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_instructions_view.cc index 28c3a31..79f56ea 100644 --- a/chrome/browser/ui/views/bookmarks/bookmark_bar_instructions_view.cc +++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_instructions_view.cc @@ -6,7 +6,7 @@ #include "base/utf_string_conversions.h" #include "chrome/browser/defaults.h" -#include "chrome/browser/themes/browser_theme_provider.h" +#include "chrome/browser/themes/theme_service.h" #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" #include "views/controls/label.h" @@ -103,7 +103,7 @@ void BookmarkBarInstructionsView::UpdateColors() { return; updated_colors_ = true; SkColor text_color = - theme_provider->GetColor(BrowserThemeProvider::COLOR_BOOKMARK_TEXT); + theme_provider->GetColor(ThemeService::COLOR_BOOKMARK_TEXT); instructions_->SetColor(text_color); if (import_link_) import_link_->SetColor(text_color); diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc index f34369fb..65b4a20 100644 --- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc +++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc @@ -21,7 +21,7 @@ #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/sync/sync_ui_util.h" -#include "chrome/browser/themes/browser_theme_provider.h" +#include "chrome/browser/themes/theme_service.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/view_ids.h" #include "chrome/browser/ui/views/bookmarks/bookmark_context_menu.h" @@ -298,7 +298,7 @@ class BookmarkBarView::ButtonSeparatorView : public views::View { canvas, kSeparatorStartX, height(), 1, DetachableToolbarView::kEdgeDividerColor, DetachableToolbarView::kMiddleDividerColor, - GetThemeProvider()->GetColor(BrowserThemeProvider::COLOR_TOOLBAR)); + GetThemeProvider()->GetColor(ThemeService::COLOR_TOOLBAR)); } virtual gfx::Size GetPreferredSize() OVERRIDE { @@ -1263,7 +1263,7 @@ void BookmarkBarView::ConfigureButton(const BookmarkNode* node, // We don't always have a theme provider (ui tests, for example). if (GetThemeProvider()) { button->SetEnabledColor(GetThemeProvider()->GetColor( - BrowserThemeProvider::COLOR_BOOKMARK_TEXT)); + ThemeService::COLOR_BOOKMARK_TEXT)); } button->ClearMaxTextSize(); @@ -1608,7 +1608,7 @@ void BookmarkBarView::UpdateColors() { if (!theme_provider) return; SkColor text_color = - theme_provider->GetColor(BrowserThemeProvider::COLOR_BOOKMARK_TEXT); + theme_provider->GetColor(ThemeService::COLOR_BOOKMARK_TEXT); for (int i = 0; i < GetBookmarkButtonCount(); ++i) GetBookmarkButton(i)->SetEnabledColor(text_color); other_bookmarked_button()->SetEnabledColor(text_color); diff --git a/chrome/browser/ui/views/browser_actions_container.cc b/chrome/browser/ui/views/browser_actions_container.cc index f2b9b1a..24795ba 100644 --- a/chrome/browser/ui/views/browser_actions_container.cc +++ b/chrome/browser/ui/views/browser_actions_container.cc @@ -13,7 +13,6 @@ #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_tabs_module.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/themes/browser_theme_provider.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/view_ids.h" #include "chrome/browser/ui/views/detachable_toolbar_view.h" @@ -36,6 +35,7 @@ #include "ui/base/animation/slide_animation.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" +#include "ui/base/theme_provider.h" #include "ui/gfx/canvas.h" #include "ui/gfx/canvas_skia.h" #include "views/controls/button/menu_button.h" diff --git a/chrome/browser/ui/views/detachable_toolbar_view.cc b/chrome/browser/ui/views/detachable_toolbar_view.cc index f87010f..5e92c489 100644 --- a/chrome/browser/ui/views/detachable_toolbar_view.cc +++ b/chrome/browser/ui/views/detachable_toolbar_view.cc @@ -4,7 +4,7 @@ #include "chrome/browser/ui/views/detachable_toolbar_view.h" -#include "chrome/browser/themes/browser_theme_provider.h" +#include "chrome/browser/themes/theme_service.h" #include "grit/theme_resources.h" #include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkShader.h" @@ -28,7 +28,7 @@ void DetachableToolbarView::PaintBackgroundAttachedMode( const gfx::Point& background_origin) { ui::ThemeProvider* tp = view->GetThemeProvider(); SkColor theme_toolbar_color = - tp->GetColor(BrowserThemeProvider::COLOR_TOOLBAR); + tp->GetColor(ThemeService::COLOR_TOOLBAR); canvas->FillRectInt(theme_toolbar_color, 0, 0, view->width(), view->height()); canvas->TileImageInt(*tp->GetBitmapNamed(IDR_THEME_TOOLBAR), @@ -67,7 +67,7 @@ void DetachableToolbarView::PaintContentAreaBackground( const SkRect& rect, double roundness) { SkPaint paint; paint.setAntiAlias(true); - paint.setColor(theme_provider->GetColor(BrowserThemeProvider::COLOR_TOOLBAR)); + paint.setColor(theme_provider->GetColor(ThemeService::COLOR_TOOLBAR)); canvas->AsCanvasSkia()->drawRoundRect( rect, SkDoubleToScalar(roundness), SkDoubleToScalar(roundness), paint); @@ -79,7 +79,7 @@ void DetachableToolbarView::PaintContentAreaBorder( const SkRect& rect, double roundness) { SkPaint border_paint; border_paint.setColor( - theme_provider->GetColor(BrowserThemeProvider::COLOR_NTP_HEADER)); + theme_provider->GetColor(ThemeService::COLOR_NTP_HEADER)); border_paint.setStyle(SkPaint::kStroke_Style); border_paint.setAlpha(96); border_paint.setAntiAlias(true); diff --git a/chrome/browser/ui/views/download_item_view.cc b/chrome/browser/ui/views/download_item_view.cc index 9bc4dc2..b644718 100644 --- a/chrome/browser/ui/views/download_item_view.cc +++ b/chrome/browser/ui/views/download_item_view.cc @@ -16,7 +16,7 @@ #include "chrome/browser/browser_process.h" #include "chrome/browser/download/download_item_model.h" #include "chrome/browser/download/download_util.h" -#include "chrome/browser/themes/browser_theme_provider.h" +#include "chrome/browser/themes/theme_service.h" #include "chrome/browser/ui/views/download_shelf_view.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" @@ -434,7 +434,7 @@ void DownloadItemView::OnDownloadOpened(DownloadItem* download) { void DownloadItemView::Layout() { if (IsDangerousMode()) { dangerous_download_label_->SetColor( - GetThemeProvider()->GetColor(BrowserThemeProvider::COLOR_BOOKMARK_TEXT)); + GetThemeProvider()->GetColor(ThemeService::COLOR_BOOKMARK_TEXT)); int x = kLeftPadding + dangerous_mode_body_image_set_.top_left->width() + warning_icon_->width() + kLabelPadding; @@ -743,7 +743,7 @@ void DownloadItemView::OnPaint(gfx::Canvas* canvas) { int y = box_y_ + kVerticalPadding + font_.GetHeight() + kVerticalTextPadding; SkColor file_name_color = GetThemeProvider()->GetColor( - BrowserThemeProvider::COLOR_BOOKMARK_TEXT); + ThemeService::COLOR_BOOKMARK_TEXT); // If text is light-on-dark, lightening it alone will do nothing. // Therefore we mute luminance a wee bit before drawing in this case. if (color_utils::RelativeLuminance(file_name_color) > 0.5) @@ -867,7 +867,7 @@ void DownloadItemView::OnPaint(gfx::Canvas* canvas) { int mirrored_x = GetMirroredXWithWidthInView( download_util::kSmallProgressIconSize, kTextWidth); SkColor file_name_color = GetThemeProvider()->GetColor( - BrowserThemeProvider::COLOR_BOOKMARK_TEXT); + ThemeService::COLOR_BOOKMARK_TEXT); int y = box_y_ + (show_status_text_ ? kVerticalPadding : (box_height_ - font_.GetHeight()) / 2); diff --git a/chrome/browser/ui/views/download_shelf_view.cc b/chrome/browser/ui/views/download_shelf_view.cc index a8180f9..7b1032f 100644 --- a/chrome/browser/ui/views/download_shelf_view.cc +++ b/chrome/browser/ui/views/download_shelf_view.cc @@ -11,7 +11,7 @@ #include "chrome/browser/download/download_item.h" #include "chrome/browser/download/download_item_model.h" #include "chrome/browser/download/download_manager.h" -#include "chrome/browser/themes/browser_theme_provider.h" +#include "chrome/browser/themes/theme_service.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/view_ids.h" #include "chrome/browser/ui/views/download_item_view.h" @@ -250,9 +250,9 @@ void DownloadShelfView::AnimationEnded(const ui::Animation *animation) { void DownloadShelfView::Layout() { // Now that we know we have a parent, we can safely set our theme colors. show_all_view_->SetColor( - GetThemeProvider()->GetColor(BrowserThemeProvider::COLOR_BOOKMARK_TEXT)); + GetThemeProvider()->GetColor(ThemeService::COLOR_BOOKMARK_TEXT)); set_background(views::Background::CreateSolidBackground( - GetThemeProvider()->GetColor(BrowserThemeProvider::COLOR_TOOLBAR))); + GetThemeProvider()->GetColor(ThemeService::COLOR_TOOLBAR))); // Let our base class layout our child views views::View::Layout(); @@ -349,7 +349,7 @@ void DownloadShelfView::UpdateButtonColors() { ResourceBundle& rb = ResourceBundle::GetSharedInstance(); if (GetThemeProvider()) { close_button_->SetBackground( - GetThemeProvider()->GetColor(BrowserThemeProvider::COLOR_TAB_TEXT), + GetThemeProvider()->GetColor(ThemeService::COLOR_TAB_TEXT), rb.GetBitmapNamed(IDR_CLOSE_BAR), rb.GetBitmapNamed(IDR_CLOSE_BAR_MASK)); } diff --git a/chrome/browser/ui/views/find_bar_view.cc b/chrome/browser/ui/views/find_bar_view.cc index 109cc2c..db874ca 100644 --- a/chrome/browser/ui/views/find_bar_view.cc +++ b/chrome/browser/ui/views/find_bar_view.cc @@ -10,7 +10,7 @@ #include "base/string_util.h" #include "base/utf_string_conversions.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/themes/browser_theme_provider.h" +#include "chrome/browser/themes/theme_service.h" #include "chrome/browser/ui/find_bar/find_bar_controller.h" #include "chrome/browser/ui/find_bar/find_bar_state.h" #include "chrome/browser/ui/find_bar/find_tab_helper.h" @@ -572,7 +572,7 @@ void FindBarView::OnThemeChanged() { ResourceBundle& rb = ResourceBundle::GetSharedInstance(); if (GetThemeProvider()) { close_button_->SetBackground( - GetThemeProvider()->GetColor(BrowserThemeProvider::COLOR_TAB_TEXT), + GetThemeProvider()->GetColor(ThemeService::COLOR_TAB_TEXT), rb.GetBitmapNamed(IDR_CLOSE_BAR), rb.GetBitmapNamed(IDR_CLOSE_BAR_MASK)); } diff --git a/chrome/browser/ui/views/frame/browser_frame_gtk.cc b/chrome/browser/ui/views/frame/browser_frame_gtk.cc index a742cc8..8c423d4 100644 --- a/chrome/browser/ui/views/frame/browser_frame_gtk.cc +++ b/chrome/browser/ui/views/frame/browser_frame_gtk.cc @@ -6,8 +6,8 @@ #include "base/logging.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/themes/browser_theme_provider.h" #include "chrome/browser/themes/theme_service.h" +#include "chrome/browser/themes/theme_service_factory.h" #include "chrome/browser/ui/status_bubble.h" #include "chrome/browser/ui/views/frame/app_panel_browser_frame_view.h" #include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h" diff --git a/chrome/browser/ui/views/frame/browser_frame_win.cc b/chrome/browser/ui/views/frame/browser_frame_win.cc index 2bb3e75..9603c96 100644 --- a/chrome/browser/ui/views/frame/browser_frame_win.cc +++ b/chrome/browser/ui/views/frame/browser_frame_win.cc @@ -12,8 +12,8 @@ #include "chrome/browser/accessibility/browser_accessibility_state.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/browser_list.h" -#include "chrome/browser/themes/browser_theme_provider.h" #include "chrome/browser/themes/theme_service.h" +#include "chrome/browser/themes/theme_service_factory.h" #include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h" #include "chrome/browser/ui/views/frame/browser_view.h" #include "chrome/browser/ui/views/frame/glass_browser_frame_view.h" diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc index 4fd606b..97298b0 100644 --- a/chrome/browser/ui/views/frame/browser_view.cc +++ b/chrome/browser/ui/views/frame/browser_view.cc @@ -33,7 +33,7 @@ #include "chrome/browser/sidebar/sidebar_container.h" #include "chrome/browser/sidebar/sidebar_manager.h" #include "chrome/browser/tabs/tab_strip_model.h" -#include "chrome/browser/themes/browser_theme_provider.h" +#include "chrome/browser/themes/theme_service.h" #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_dialogs.h" @@ -1855,7 +1855,7 @@ void BrowserView::Init() { contents_ = new ContentsContainer(contents_container_); SkColor bg_color = GetWidget()->GetThemeProvider()-> - GetColor(BrowserThemeProvider::COLOR_TOOLBAR); + GetColor(ThemeService::COLOR_TOOLBAR); bool sidebar_allowed = SidebarManager::IsSidebarAllowed(); if (sidebar_allowed) { diff --git a/chrome/browser/ui/views/frame/glass_browser_frame_view.cc b/chrome/browser/ui/views/frame/glass_browser_frame_view.cc index 784914d..9fa33d5 100644 --- a/chrome/browser/ui/views/frame/glass_browser_frame_view.cc +++ b/chrome/browser/ui/views/frame/glass_browser_frame_view.cc @@ -10,7 +10,7 @@ #include "chrome/app/chrome_dll_resource.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/themes/browser_theme_provider.h" +#include "chrome/browser/themes/theme_service.h" #include "chrome/browser/ui/views/frame/browser_view.h" #include "chrome/browser/ui/views/profile_menu_button.h" #include "chrome/browser/ui/views/profile_menu_model.h" @@ -464,7 +464,7 @@ void GlassBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) { // where not covered by the toolbar image. NOTE: We do this after drawing the // images because the images are meant to alpha-blend atop the frame whereas // these rects are meant to be fully opaque, without anything overlaid. - SkColor toolbar_color = tp->GetColor(BrowserThemeProvider::COLOR_TOOLBAR); + SkColor toolbar_color = tp->GetColor(ThemeService::COLOR_TOOLBAR); canvas->FillRectInt(toolbar_color, client_area_bounds.x() - kClientEdgeThickness, client_area_top, kClientEdgeThickness, diff --git a/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc b/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc index 9fd906d..29237c8 100644 --- a/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc +++ b/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc @@ -6,7 +6,7 @@ #include "base/compiler_specific.h" #include "base/utf_string_conversions.h" -#include "chrome/browser/themes/browser_theme_provider.h" +#include "chrome/browser/themes/theme_service.h" #include "chrome/browser/ui/views/frame/browser_frame.h" #include "chrome/browser/ui/views/frame/browser_view.h" #include "chrome/browser/ui/views/tabs/tab_strip.h" @@ -109,7 +109,7 @@ OpaqueBrowserFrameView::OpaqueBrowserFrameView(BrowserFrame* frame, frame_(frame), browser_view_(browser_view) { ui::ThemeProvider* tp = frame_->GetThemeProviderForFrame(); - SkColor color = tp->GetColor(BrowserThemeProvider::COLOR_BUTTON_BACKGROUND); + SkColor color = tp->GetColor(ThemeService::COLOR_BUTTON_BACKGROUND); SkBitmap* background = tp->GetBitmapNamed(IDR_THEME_WINDOW_CONTROL_BACKGROUND); minimize_button_->SetImage(views::CustomButton::BS_NORMAL, @@ -589,18 +589,18 @@ void OpaqueBrowserFrameView::PaintRestoredFrameBorder(gfx::Canvas* canvas) { } else if (!browser_view_->IsOffTheRecord()) { if (ShouldPaintAsActive()) { theme_frame = tp->GetBitmapNamed(IDR_THEME_FRAME); - frame_color = tp->GetColor(BrowserThemeProvider::COLOR_FRAME); + frame_color = tp->GetColor(ThemeService::COLOR_FRAME); } else { theme_frame = tp->GetBitmapNamed(IDR_THEME_FRAME_INACTIVE); - frame_color = tp->GetColor(BrowserThemeProvider::COLOR_FRAME_INACTIVE); + frame_color = tp->GetColor(ThemeService::COLOR_FRAME_INACTIVE); } } else if (ShouldPaintAsActive()) { theme_frame = tp->GetBitmapNamed(IDR_THEME_FRAME_INCOGNITO); - frame_color = tp->GetColor(BrowserThemeProvider::COLOR_FRAME_INCOGNITO); + frame_color = tp->GetColor(ThemeService::COLOR_FRAME_INCOGNITO); } else { theme_frame = tp->GetBitmapNamed(IDR_THEME_FRAME_INCOGNITO_INACTIVE); frame_color = tp->GetColor( - BrowserThemeProvider::COLOR_FRAME_INCOGNITO_INACTIVE); + ThemeService::COLOR_FRAME_INCOGNITO_INACTIVE); } // Fill with the frame color first so we have a constant background for @@ -774,7 +774,7 @@ void OpaqueBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) { canvas->AsCanvasSkia()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode); SkColor theme_toolbar_color = - tp->GetColor(BrowserThemeProvider::COLOR_TOOLBAR); + tp->GetColor(ThemeService::COLOR_TOOLBAR); canvas->FillRectInt(theme_toolbar_color, x, bottom_y, w, bottom_edge_height); // Tile the toolbar image starting at the frame edge on the left and where the @@ -872,7 +872,7 @@ void OpaqueBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) { int image_top = client_area_top; gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height()); - SkColor toolbar_color = tp->GetColor(BrowserThemeProvider::COLOR_TOOLBAR); + SkColor toolbar_color = tp->GetColor(ThemeService::COLOR_TOOLBAR); if (browser_view_->IsToolbarVisible()) { // The client edge images always start below the toolbar corner images. The diff --git a/chrome/browser/ui/views/notifications/balloon_view.cc b/chrome/browser/ui/views/notifications/balloon_view.cc index a4aba18..74e3101 100644 --- a/chrome/browser/ui/views/notifications/balloon_view.cc +++ b/chrome/browser/ui/views/notifications/balloon_view.cc @@ -13,7 +13,6 @@ #include "chrome/browser/notifications/desktop_notification_service.h" #include "chrome/browser/notifications/notification.h" #include "chrome/browser/notifications/notification_options_menu_model.h" -#include "chrome/browser/themes/browser_theme_provider.h" #include "chrome/browser/ui/views/bubble_border.h" #include "chrome/browser/ui/views/notifications/balloon_view_host.h" #include "content/browser/renderer_host/render_view_host.h" diff --git a/chrome/browser/ui/views/status_bubble_views.cc b/chrome/browser/ui/views/status_bubble_views.cc index 398ae3e..1af27c5 100644 --- a/chrome/browser/ui/views/status_bubble_views.cc +++ b/chrome/browser/ui/views/status_bubble_views.cc @@ -10,7 +10,7 @@ #include "base/message_loop.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" -#include "chrome/browser/themes/browser_theme_provider.h" +#include "chrome/browser/themes/theme_service.h" #include "googleurl/src/gurl.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" @@ -82,7 +82,7 @@ class StatusBubbleViews::StatusView : public views::Label, popup_(popup), opacity_start_(0), opacity_end_(0), - theme_provider_(theme_provider) { + theme_service_(theme_provider) { ResourceBundle& rb = ResourceBundle::GetSharedInstance(); gfx::Font font(rb.GetFont(ResourceBundle::BaseFont)); SetFont(font); @@ -174,7 +174,7 @@ class StatusBubbleViews::StatusView : public views::Label, double opacity_end_; // Holds the theme provider of the frame that created us. - ui::ThemeProvider* theme_provider_; + ui::ThemeProvider* theme_service_; }; void StatusBubbleViews::StatusView::SetText(const string16& text, @@ -340,7 +340,7 @@ void StatusBubbleViews::StatusView::OnPaint(gfx::Canvas* canvas) { paint.setStyle(SkPaint::kFill_Style); paint.setFlags(SkPaint::kAntiAlias_Flag); SkColor toolbar_color = - theme_provider_->GetColor(BrowserThemeProvider::COLOR_TOOLBAR); + theme_service_->GetColor(ThemeService::COLOR_TOOLBAR); paint.setColor(toolbar_color); gfx::Rect popup_bounds = popup_->GetWindowScreenBounds(); @@ -438,7 +438,7 @@ void StatusBubbleViews::StatusView::OnPaint(gfx::Canvas* canvas) { std::max(0, text_height)); body_bounds.set_x(GetMirroredXForRect(body_bounds)); SkColor text_color = - theme_provider_->GetColor(BrowserThemeProvider::COLOR_TAB_TEXT); + theme_service_->GetColor(ThemeService::COLOR_TAB_TEXT); // DrawStringInt doesn't handle alpha, so we'll do the blending ourselves. text_color = SkColorSetARGB( diff --git a/chrome/browser/ui/views/tabs/tab.cc b/chrome/browser/ui/views/tabs/tab.cc index 8f51117..7628b79 100644 --- a/chrome/browser/ui/views/tabs/tab.cc +++ b/chrome/browser/ui/views/tabs/tab.cc @@ -8,7 +8,7 @@ #include "base/utf_string_conversions.h" #include "chrome/browser/defaults.h" -#include "chrome/browser/themes/browser_theme_provider.h" +#include "chrome/browser/themes/theme_service.h" #include "grit/app_resources.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" @@ -206,8 +206,8 @@ void Tab::OnPaint(gfx::Canvas* canvas) { SkColor title_color = GetThemeProvider()-> GetColor(IsSelected() ? - BrowserThemeProvider::COLOR_TAB_TEXT : - BrowserThemeProvider::COLOR_BACKGROUND_TAB_TEXT); + ThemeService::COLOR_TAB_TEXT : + ThemeService::COLOR_BACKGROUND_TAB_TEXT); if (!data().mini || width() > kMiniTabRendererAsNormalTabWidth) PaintTitle(canvas, title_color); diff --git a/chrome/browser/ui/views/tabs/tab_strip.cc b/chrome/browser/ui/views/tabs/tab_strip.cc index 3163a1b..7a929de 100644 --- a/chrome/browser/ui/views/tabs/tab_strip.cc +++ b/chrome/browser/ui/views/tabs/tab_strip.cc @@ -10,7 +10,7 @@ #include "base/stl_util-inl.h" #include "base/utf_string_conversions.h" #include "chrome/browser/defaults.h" -#include "chrome/browser/themes/browser_theme_provider.h" +#include "chrome/browser/themes/theme_service.h" #include "chrome/browser/ui/view_ids.h" #include "chrome/browser/ui/views/tabs/tab.h" #include "chrome/browser/ui/views/tabs/tab_strip_controller.h" @@ -558,7 +558,7 @@ void TabStrip::LoadNewTabButtonImage() { } SkBitmap* bitmap = tp->GetBitmapNamed(IDR_NEWTAB_BUTTON); - SkColor color = tp->GetColor(BrowserThemeProvider::COLOR_BUTTON_BACKGROUND); + SkColor color = tp->GetColor(ThemeService::COLOR_BUTTON_BACKGROUND); SkBitmap* background = tp->GetBitmapNamed( IDR_THEME_WINDOW_CONTROL_BACKGROUND); diff --git a/chrome/browser/ui/views/theme_background.cc b/chrome/browser/ui/views/theme_background.cc index e3eb665..6fd601b 100644 --- a/chrome/browser/ui/views/theme_background.cc +++ b/chrome/browser/ui/views/theme_background.cc @@ -5,8 +5,8 @@ #include "chrome/browser/ui/views/theme_background.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/themes/browser_theme_provider.h" #include "chrome/browser/themes/theme_service.h" +#include "chrome/browser/themes/theme_service_factory.h" #include "chrome/browser/ui/views/frame/browser_view.h" #include "grit/app_resources.h" #include "grit/generated_resources.h" diff --git a/chrome/browser/ui/views/toolbar_view.cc b/chrome/browser/ui/views/toolbar_view.cc index 184be8a..a9a02bc 100644 --- a/chrome/browser/ui/views/toolbar_view.cc +++ b/chrome/browser/ui/views/toolbar_view.cc @@ -11,7 +11,6 @@ #include "chrome/browser/metrics/user_metrics.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/themes/browser_theme_provider.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/toolbar/wrench_menu_model.h" @@ -28,6 +27,7 @@ #include "ui/base/accessibility/accessible_view_state.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" +#include "ui/base/theme_provider.h" #include "ui/gfx/canvas.h" #include "ui/gfx/canvas_skia.h" #include "ui/gfx/skbitmap_operations.h" diff --git a/chrome/browser/ui/webui/new_tab_ui.cc b/chrome/browser/ui/webui/new_tab_ui.cc index 9389ab6..cca67e9 100644 --- a/chrome/browser/ui/webui/new_tab_ui.cc +++ b/chrome/browser/ui/webui/new_tab_ui.cc @@ -24,8 +24,8 @@ #include "chrome/browser/sessions/tab_restore_service_delegate.h" #include "chrome/browser/sessions/tab_restore_service_observer.h" #include "chrome/browser/sync/profile_sync_service.h" -#include "chrome/browser/themes/browser_theme_provider.h" #include "chrome/browser/themes/theme_service.h" +#include "chrome/browser/themes/theme_service_factory.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/webui/app_launcher_handler.h" #include "chrome/browser/ui/webui/foreign_session_handler.h" diff --git a/chrome/browser/ui/webui/ntp_resource_cache.cc b/chrome/browser/ui/webui/ntp_resource_cache.cc index e634668..655f813c 100644 --- a/chrome/browser/ui/webui/ntp_resource_cache.cc +++ b/chrome/browser/ui/webui/ntp_resource_cache.cc @@ -19,8 +19,8 @@ #include "chrome/browser/metrics/user_metrics.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/themes/browser_theme_provider.h" #include "chrome/browser/themes/theme_service.h" +#include "chrome/browser/themes/theme_service_factory.h" #include "chrome/browser/ui/webui/chrome_url_data_manager.h" #include "chrome/browser/ui/webui/shown_sections_handler.h" #include "chrome/browser/web_resource/promo_resource_service.h" @@ -94,7 +94,7 @@ std::string GetNewTabBackgroundCSS(const ui::ThemeProvider* theme_provider, bool bar_attached) { int alignment; theme_provider->GetDisplayProperty( - BrowserThemeProvider::NTP_BACKGROUND_ALIGNMENT, &alignment); + ThemeService::NTP_BACKGROUND_ALIGNMENT, &alignment); // TODO(glen): This is a quick workaround to hide the notused.png image when // no image is provided - we don't have time right now to figure out why @@ -105,7 +105,7 @@ std::string GetNewTabBackgroundCSS(const ui::ThemeProvider* theme_provider, } if (bar_attached) - return BrowserThemeProvider::AlignmentToString(alignment); + return ThemeService::AlignmentToString(alignment); // The bar is detached, so we must offset the background by the bar size // if it's a top-aligned bar. @@ -119,24 +119,24 @@ std::string GetNewTabBackgroundCSS(const ui::ThemeProvider* theme_provider, int offset = 0; #endif - if (alignment & BrowserThemeProvider::ALIGN_TOP) { - if (alignment & BrowserThemeProvider::ALIGN_LEFT) + if (alignment & ThemeService::ALIGN_TOP) { + if (alignment & ThemeService::ALIGN_LEFT) return "0% " + base::IntToString(-offset) + "px"; - else if (alignment & BrowserThemeProvider::ALIGN_RIGHT) + else if (alignment & ThemeService::ALIGN_RIGHT) return "100% " + base::IntToString(-offset) + "px"; return "center " + base::IntToString(-offset) + "px"; } - return BrowserThemeProvider::AlignmentToString(alignment); + return ThemeService::AlignmentToString(alignment); } // How the background image on the new tab page should be tiled (see tiling -// masks in browser_theme_provider.h). +// masks in theme_service.h). std::string GetNewTabBackgroundTilingCSS( const ui::ThemeProvider* theme_provider) { int repeat_mode; theme_provider->GetDisplayProperty( - BrowserThemeProvider::NTP_BACKGROUND_TILING, &repeat_mode); - return BrowserThemeProvider::TilingToString(repeat_mode); + ThemeService::NTP_BACKGROUND_TILING, &repeat_mode); + return ThemeService::TilingToString(repeat_mode); } // Is the current time within a given date range? @@ -439,7 +439,7 @@ void NTPResourceCache::CreateNewTabIncognitoCSS() { // Get our theme colors SkColor color_background = - tp->GetColor(BrowserThemeProvider::COLOR_NTP_BACKGROUND); + tp->GetColor(ThemeService::COLOR_NTP_BACKGROUND); // Generate the replacements. std::vector<std::string> subst; @@ -475,33 +475,33 @@ void NTPResourceCache::CreateNewTabCSS() { // Get our theme colors SkColor color_background = - tp->GetColor(BrowserThemeProvider::COLOR_NTP_BACKGROUND); - SkColor color_text = tp->GetColor(BrowserThemeProvider::COLOR_NTP_TEXT); - SkColor color_link = tp->GetColor(BrowserThemeProvider::COLOR_NTP_LINK); + tp->GetColor(ThemeService::COLOR_NTP_BACKGROUND); + SkColor color_text = tp->GetColor(ThemeService::COLOR_NTP_TEXT); + SkColor color_link = tp->GetColor(ThemeService::COLOR_NTP_LINK); SkColor color_link_underline = - tp->GetColor(BrowserThemeProvider::COLOR_NTP_LINK_UNDERLINE); + tp->GetColor(ThemeService::COLOR_NTP_LINK_UNDERLINE); SkColor color_section = - tp->GetColor(BrowserThemeProvider::COLOR_NTP_SECTION); + tp->GetColor(ThemeService::COLOR_NTP_SECTION); SkColor color_section_text = - tp->GetColor(BrowserThemeProvider::COLOR_NTP_SECTION_TEXT); + tp->GetColor(ThemeService::COLOR_NTP_SECTION_TEXT); SkColor color_section_link = - tp->GetColor(BrowserThemeProvider::COLOR_NTP_SECTION_LINK); + tp->GetColor(ThemeService::COLOR_NTP_SECTION_LINK); SkColor color_section_link_underline = - tp->GetColor(BrowserThemeProvider::COLOR_NTP_SECTION_LINK_UNDERLINE); + tp->GetColor(ThemeService::COLOR_NTP_SECTION_LINK_UNDERLINE); SkColor color_section_header_text = - tp->GetColor(BrowserThemeProvider::COLOR_NTP_SECTION_HEADER_TEXT); + tp->GetColor(ThemeService::COLOR_NTP_SECTION_HEADER_TEXT); SkColor color_section_header_text_hover = - tp->GetColor(BrowserThemeProvider::COLOR_NTP_SECTION_HEADER_TEXT_HOVER); + tp->GetColor(ThemeService::COLOR_NTP_SECTION_HEADER_TEXT_HOVER); SkColor color_section_header_rule = - tp->GetColor(BrowserThemeProvider::COLOR_NTP_SECTION_HEADER_RULE); + tp->GetColor(ThemeService::COLOR_NTP_SECTION_HEADER_RULE); SkColor color_section_header_rule_light = - tp->GetColor(BrowserThemeProvider::COLOR_NTP_SECTION_HEADER_RULE_LIGHT); + tp->GetColor(ThemeService::COLOR_NTP_SECTION_HEADER_RULE_LIGHT); SkColor color_text_light = - tp->GetColor(BrowserThemeProvider::COLOR_NTP_TEXT_LIGHT); + tp->GetColor(ThemeService::COLOR_NTP_TEXT_LIGHT); SkColor color_header = - tp->GetColor(BrowserThemeProvider::COLOR_NTP_HEADER); + tp->GetColor(ThemeService::COLOR_NTP_HEADER); // Generate a lighter color for the header gradients. color_utils::HSL header_lighter; color_utils::SkColorToHSL(color_header, &header_lighter); diff --git a/chrome/browser/ui/webui/options/personal_options_handler.cc b/chrome/browser/ui/webui/options/personal_options_handler.cc index c554201..3b3b20b 100644 --- a/chrome/browser/ui/webui/options/personal_options_handler.cc +++ b/chrome/browser/ui/webui/options/personal_options_handler.cc @@ -22,8 +22,8 @@ #include "chrome/browser/sync/profile_sync_service.h" #include "chrome/browser/sync/sync_setup_flow.h" #include "chrome/browser/sync/sync_ui_util.h" -#include "chrome/browser/themes/browser_theme_provider.h" #include "chrome/browser/themes/theme_service.h" +#include "chrome/browser/themes/theme_service_factory.h" #include "chrome/browser/ui/options/options_page_base.h" #include "chrome/browser/ui/options/options_window.h" #include "chrome/browser/ui/webui/options/options_managed_banner_handler.h" @@ -44,7 +44,7 @@ #include "third_party/skia/include/core/SkBitmap.h" #endif // defined(OS_CHROMEOS) #if defined(TOOLKIT_GTK) -#include "chrome/browser/ui/gtk/gtk_theme_provider.h" +#include "chrome/browser/ui/gtk/gtk_theme_service.h" #endif // defined(TOOLKIT_GTK) PersonalOptionsHandler::PersonalOptionsHandler() { @@ -331,13 +331,13 @@ void PersonalOptionsHandler::OnLoginFailure( void PersonalOptionsHandler::ObserveThemeChanged() { Profile* profile = web_ui_->GetProfile(); #if defined(TOOLKIT_GTK) - GtkThemeProvider* provider = GtkThemeProvider::GetFrom(profile); + GtkThemeService* provider = GtkThemeService::GetFrom(profile); bool is_gtk_theme = provider->UseGtkTheme(); FundamentalValue gtk_enabled(!is_gtk_theme); web_ui_->CallJavascriptFunction( "options.PersonalOptions.setGtkThemeButtonEnabled", gtk_enabled); #else - BrowserThemeProvider* provider = ThemeServiceFactory::GetForProfile(profile); + ThemeService* provider = ThemeServiceFactory::GetForProfile(profile); bool is_gtk_theme = false; #endif diff --git a/chrome/browser/ui/webui/theme_source.cc b/chrome/browser/ui/webui/theme_source.cc index 3c686e7..f8ea63f 100644 --- a/chrome/browser/ui/webui/theme_source.cc +++ b/chrome/browser/ui/webui/theme_source.cc @@ -8,8 +8,8 @@ #include "base/ref_counted_memory.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/resources_util.h" -#include "chrome/browser/themes/browser_theme_provider.h" #include "chrome/browser/themes/theme_service.h" +#include "chrome/browser/themes/theme_service_factory.h" #include "chrome/browser/ui/webui/ntp_resource_cache.h" #include "chrome/common/url_constants.h" #include "content/browser/browser_thread.h" @@ -89,7 +89,7 @@ MessageLoop* ThemeSource::MessageLoopForRequestPath( // If it's not a themeable image, we don't need to go to the UI thread. int resource_id = ResourcesUtil::GetThemeResourceId(uncached_path); - if (!BrowserThemeProvider::IsThemeableImage(resource_id)) + if (!ThemeService::IsThemeableImage(resource_id)) return NULL; return DataSource::MessageLoopForRequestPath(path); @@ -105,7 +105,7 @@ bool ThemeSource::ShouldReplaceExistingSource() const { // ThemeSource, private: void ThemeSource::SendThemeBitmap(int request_id, int resource_id) { - if (BrowserThemeProvider::IsThemeableImage(resource_id)) { + if (ThemeService::IsThemeableImage(resource_id)) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); ui::ThemeProvider* tp = ThemeServiceFactory::GetForProfile(profile_); DCHECK(tp); diff --git a/chrome/browser/ui/webui/theme_source_unittest.cc b/chrome/browser/ui/webui/theme_source_unittest.cc index 59511c3..3bbaf93 100644 --- a/chrome/browser/ui/webui/theme_source_unittest.cc +++ b/chrome/browser/ui/webui/theme_source_unittest.cc @@ -4,7 +4,6 @@ #include "base/ref_counted_memory.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/themes/browser_theme_provider.h" #include "chrome/browser/ui/webui/theme_source.h" #include "chrome/common/url_constants.h" #include "chrome/test/testing_profile.h" diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index c2b77ec..d9cccbf 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -2030,12 +2030,12 @@ 'browser/task_manager/task_manager_resource_providers.h', 'browser/themes/browser_theme_pack.cc', 'browser/themes/browser_theme_pack.h', - 'browser/themes/browser_theme_provider.cc', - 'browser/themes/browser_theme_provider.h', - 'browser/themes/browser_theme_provider_gtk.cc', - 'browser/themes/browser_theme_provider_mac.mm', 'browser/themes/theme_service.cc', 'browser/themes/theme_service.h', + 'browser/themes/theme_service_factory.cc', + 'browser/themes/theme_service_factory.h', + 'browser/themes/theme_service_gtk.cc', + 'browser/themes/theme_service_mac.mm', 'browser/translate/languages_menu_model.cc', 'browser/translate/languages_menu_model.h', 'browser/translate/options_menu_model.cc', @@ -2600,8 +2600,8 @@ 'browser/ui/gtk/gtk_expanded_container.h', 'browser/ui/gtk/gtk_floating_container.cc', 'browser/ui/gtk/gtk_floating_container.h', - 'browser/ui/gtk/gtk_theme_provider.cc', - 'browser/ui/gtk/gtk_theme_provider.h', + 'browser/ui/gtk/gtk_theme_service.cc', + 'browser/ui/gtk/gtk_theme_service.h', 'browser/ui/gtk/gtk_tree.cc', 'browser/ui/gtk/gtk_tree.h', 'browser/ui/gtk/gtk_util.cc', @@ -3699,8 +3699,8 @@ ['include', '^browser/ui/gtk/gtk_custom_menu_item.cc'], ['include', '^browser/ui/gtk/gtk_floating_container.cc'], ['include', '^browser/ui/gtk/gtk_floating_container.h'], - ['include', '^browser/ui/gtk/gtk_theme_provider.cc'], - ['include', '^browser/ui/gtk/gtk_theme_provider.h'], + ['include', '^browser/ui/gtk/gtk_theme_service.cc'], + ['include', '^browser/ui/gtk/gtk_theme_service.h'], ['include', '^browser/ui/gtk/gtk_tree.cc'], ['include', '^browser/ui/gtk/gtk_tree.h'], ['include', '^browser/ui/gtk/gtk_util.cc'], diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index c0b24d5..7ba1536 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -1304,7 +1304,7 @@ 'browser/ui/gtk/bookmarks/bookmark_utils_gtk_unittest.cc', 'browser/ui/gtk/gtk_chrome_shrinkable_hbox_unittest.cc', 'browser/ui/gtk/gtk_expanded_container_unittest.cc', - 'browser/ui/gtk/gtk_theme_provider_unittest.cc', + 'browser/ui/gtk/gtk_theme_service_unittest.cc', 'browser/ui/gtk/reload_button_gtk_unittest.cc', 'browser/ui/gtk/status_icons/status_tray_gtk_unittest.cc', 'browser/ui/gtk/tabs/tab_renderer_gtk_unittest.cc', @@ -1524,7 +1524,7 @@ 'browser/tabs/tab_strip_selection_model_unittest.cc', 'browser/task_manager/task_manager_unittest.cc', 'browser/themes/browser_theme_pack_unittest.cc', - 'browser/themes/browser_theme_provider_unittest.cc', + 'browser/themes/theme_service_unittest.cc', # It is safe to list */cocoa/* files in the "common" file list # without an explicit exclusion since gyp is smart enough to # exclude them from non-Mac builds. @@ -1902,7 +1902,7 @@ 'browser/ui/gtk/bookmarks/bookmark_editor_gtk_unittest.cc', 'browser/ui/gtk/gtk_chrome_shrinkable_hbox_unittest.cc', 'browser/ui/gtk/gtk_expanded_container_unittest.cc', - 'browser/ui/gtk/gtk_theme_provider_unittest.cc', + 'browser/ui/gtk/gtk_theme_service_unittest.cc', 'browser/ui/gtk/options/cookies_view_unittest.cc', 'browser/ui/gtk/options/languages_page_gtk_unittest.cc', 'browser/ui/gtk/reload_button_gtk_unittest.cc', diff --git a/chrome/common/extensions/docs/static/themes.html b/chrome/common/extensions/docs/static/themes.html index 651a74d..8be5c52 100644 --- a/chrome/common/extensions/docs/static/themes.html +++ b/chrome/common/extensions/docs/static/themes.html @@ -66,7 +66,7 @@ file for a theme: Colors are in RGB format. To find the strings you can use within the "colors" field, look for kColor* strings in -<a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/browser/themes/browser_theme_provider.cc"><code>browser_theme_provider.cc</code></a>. +<a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/browser/themes/theme_service.cc"><code>theme_service.cc</code></a>. </p> <h3 id="images">images</h3> @@ -75,7 +75,7 @@ look for kColor* strings in Image resources use paths relative to the root of the extension. You can override any of the images that are specified by <code>kThemeableImages</code> in -<a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/browser/themes/browser_theme_provider.cc"><code>browser_theme_provider.cc</code></a>. +<a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/browser/themes/theme_service.cc"><code>theme_service.cc</code></a>. Just remove the "IDR_" and convert the remaining characters to lowercase. For example, <code>IDR_THEME_NTP_BACKGROUND</code> @@ -92,7 +92,7 @@ properties such as background alignment, background repeat, and an alternate logo. To see the properties and the values they can have, see -<a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/browser/themes/browser_theme_provider.cc"><code>browser_theme_provider.cc</code></a>. +<a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/browser/themes/theme_service.cc"><code>theme_service.cc</code></a>. <!-- [PENDING: We should flesh this out.] --> </p> @@ -106,7 +106,7 @@ because images don't work across platforms and are brittle in the case of adding new buttons. To find the strings you can use within the "tints" field, look for kTint* strings in -<a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/browser/themes/browser_theme_provider.cc"><code>browser_theme_provider.cc</code></a>. +<a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/browser/themes/theme_service.cc"><code>theme_service.cc</code></a>. </p> <p> diff --git a/chrome/common/extensions/docs/themes.html b/chrome/common/extensions/docs/themes.html index d2eafef..9bcbfec 100644 --- a/chrome/common/extensions/docs/themes.html +++ b/chrome/common/extensions/docs/themes.html @@ -389,7 +389,7 @@ file for a theme: Colors are in RGB format. To find the strings you can use within the "colors" field, look for kColor* strings in -<a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/browser/themes/browser_theme_provider.cc"><code>browser_theme_provider.cc</code></a>. +<a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/browser/themes/theme_service.cc"><code>theme_service.cc</code></a>. </p> <h3 id="images">images</h3> @@ -398,7 +398,7 @@ look for kColor* strings in Image resources use paths relative to the root of the extension. You can override any of the images that are specified by <code>kThemeableImages</code> in -<a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/browser/themes/browser_theme_provider.cc"><code>browser_theme_provider.cc</code></a>. +<a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/browser/themes/theme_service.cc"><code>theme_service.cc</code></a>. Just remove the "IDR_" and convert the remaining characters to lowercase. For example, <code>IDR_THEME_NTP_BACKGROUND</code> @@ -415,7 +415,7 @@ properties such as background alignment, background repeat, and an alternate logo. To see the properties and the values they can have, see -<a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/browser/themes/browser_theme_provider.cc"><code>browser_theme_provider.cc</code></a>. +<a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/browser/themes/theme_service.cc"><code>theme_service.cc</code></a>. <!-- [PENDING: We should flesh this out.] --> </p> @@ -429,7 +429,7 @@ because images don't work across platforms and are brittle in the case of adding new buttons. To find the strings you can use within the "tints" field, look for kTint* strings in -<a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/browser/themes/browser_theme_provider.cc"><code>browser_theme_provider.cc</code></a>. +<a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/browser/themes/theme_service.cc"><code>theme_service.cc</code></a>. </p> <p> diff --git a/chrome/test/live_sync/live_extensions_sync_test.cc b/chrome/test/live_sync/live_extensions_sync_test.cc index 258b82e..9b2e64a 100644 --- a/chrome/test/live_sync/live_extensions_sync_test.cc +++ b/chrome/test/live_sync/live_extensions_sync_test.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -11,7 +11,7 @@ #include "base/ref_counted.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/themes/browser_theme_provider.h" +#include "chrome/browser/themes/theme_service.h" #include "chrome/common/extensions/extension.h" LiveExtensionsSyncTest::LiveExtensionsSyncTest(TestType test_type) diff --git a/chrome/test/live_sync/live_themes_sync_test.cc b/chrome/test/live_sync/live_themes_sync_test.cc index 3c65359..0537565 100644 --- a/chrome/test/live_sync/live_themes_sync_test.cc +++ b/chrome/test/live_sync/live_themes_sync_test.cc @@ -9,8 +9,8 @@ #include "base/logging.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/themes/browser_theme_provider.h" #include "chrome/browser/themes/theme_service.h" +#include "chrome/browser/themes/theme_service_factory.h" #include "chrome/common/extensions/extension.h" LiveThemesSyncTest::LiveThemesSyncTest(TestType test_type) diff --git a/chrome/test/testing_profile.cc b/chrome/test/testing_profile.cc index 26e452c..484d780 100644 --- a/chrome/test/testing_profile.cc +++ b/chrome/test/testing_profile.cc @@ -323,7 +323,7 @@ void TestingProfile::SetTemplateURLModel(TemplateURLModel* model) { template_url_model_.reset(model); } -void TestingProfile::UseThemeProvider(BrowserThemeProvider* theme_provider) { +void TestingProfile::UseThemeProvider(ThemeService* theme_provider) { NOTREACHED() << "This needs to go away for a different testing interface."; } diff --git a/chrome/test/testing_profile.h b/chrome/test/testing_profile.h index befc5a6..91d63aa 100644 --- a/chrome/test/testing_profile.h +++ b/chrome/test/testing_profile.h @@ -22,7 +22,6 @@ class CookieMonster; class AutocompleteClassifier; class BookmarkModel; -class BrowserThemeProvider; class CommandLine; class DesktopNotificationService; class ExtensionPrefs; @@ -40,6 +39,7 @@ class ProfileSyncService; class SessionService; class TemplateURLModel; class TestingPrefService; +class ThemeService; class URLRequestContextGetter; class WebKitContext; @@ -115,7 +115,7 @@ class TestingProfile : public Profile { // Uses a specific theme provider for this profile. TestingProfile takes // ownership of |theme_provider|. - void UseThemeProvider(BrowserThemeProvider* theme_provider); + void UseThemeProvider(ThemeService* theme_provider); // Creates an ExtensionService initialized with the testing profile and // returns it. The profile keeps its own copy of a scoped_refptr to the diff --git a/content/browser/tab_contents/interstitial_page.cc b/content/browser/tab_contents/interstitial_page.cc index 59d5886..1b5aa79 100644 --- a/content/browser/tab_contents/interstitial_page.cc +++ b/content/browser/tab_contents/interstitial_page.cc @@ -35,10 +35,6 @@ #include "content/common/page_transition_types.h" #include "net/base/escape.h" -#if defined(TOOLKIT_GTK) -#include "chrome/browser/ui/gtk/gtk_theme_provider.h" -#endif - using WebKit::WebDragOperation; using WebKit::WebDragOperationsMask; diff --git a/content/browser/webui/web_ui.cc b/content/browser/webui/web_ui.cc index 6d7ca77..6a8e8c4 100644 --- a/content/browser/webui/web_ui.cc +++ b/content/browser/webui/web_ui.cc @@ -11,8 +11,6 @@ #include "base/utf_string_conversions.h" #include "base/values.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/themes/browser_theme_provider.h" -#include "chrome/browser/themes/theme_service.h" #include "chrome/browser/ui/webui/generic_handler.h" #include "chrome/common/bindings_policy.h" #include "chrome/common/render_messages.h" @@ -129,10 +127,6 @@ void WebUI::CallJavascriptFunction( ExecuteJavascript(GetJavascript(function_name, args)); } -ui::ThemeProvider* WebUI::GetThemeProvider() const { - return ThemeServiceFactory::GetForProfile(GetProfile()); -} - void WebUI::RegisterMessageCallback(const std::string &message, MessageCallback *callback) { std::pair<MessageCallbackMap::iterator, bool> result = diff --git a/content/browser/webui/web_ui.h b/content/browser/webui/web_ui.h index 2272b13..4bcda5d 100644 --- a/content/browser/webui/web_ui.h +++ b/content/browser/webui/web_ui.h @@ -24,10 +24,6 @@ class TabContents; class Value; struct ViewHostMsg_DomMessage_Params; -namespace ui { -class ThemeProvider; -} - // A WebUI sets up the datasources and message handlers for a given HTML-based // UI. It is contained by a WebUIManager. class WebUI { @@ -139,8 +135,6 @@ class WebUI { void CallJavascriptFunction(const std::string& function_name, const std::vector<const Value*>& args); - ui::ThemeProvider* GetThemeProvider() const; - // May be overridden by WebUI's which do not have a tab contents. virtual Profile* GetProfile() const; |