| Index: chrome/browser/ui/gtk/gtk_theme_service.cc
|
| diff --git a/chrome/browser/ui/gtk/theme_service_gtk.cc b/chrome/browser/ui/gtk/gtk_theme_service.cc
|
| similarity index 92%
|
| rename from chrome/browser/ui/gtk/theme_service_gtk.cc
|
| rename to chrome/browser/ui/gtk/gtk_theme_service.cc
|
| index 733eaf3feb56edd1203d59b12c69c14455ba8a8f..f2ff27b8f8036149658350fbcf17db0956b3abde 100644
|
| --- a/chrome/browser/ui/gtk/theme_service_gtk.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/theme_service_gtk.h"
|
| +#include "chrome/browser/ui/gtk/gtk_theme_service.h"
|
|
|
| #include <gtk/gtk.h>
|
|
|
| @@ -243,17 +243,17 @@ void GdkColorHSLShift(const color_utils::HSL& shift, GdkColor* frame_color) {
|
|
|
| } // namespace
|
|
|
| -GtkWidget* ThemeServiceGtk::icon_widget_ = NULL;
|
| -gfx::Image* ThemeServiceGtk::default_folder_icon_ = NULL;
|
| -gfx::Image* ThemeServiceGtk::default_bookmark_icon_ = NULL;
|
| +GtkWidget* GtkThemeService::icon_widget_ = NULL;
|
| +gfx::Image* GtkThemeService::default_folder_icon_ = NULL;
|
| +gfx::Image* GtkThemeService::default_bookmark_icon_ = NULL;
|
|
|
| // static
|
| -ThemeServiceGtk* ThemeServiceGtk::GetFrom(Profile* profile) {
|
| - return static_cast<ThemeServiceGtk*>(
|
| +GtkThemeService* GtkThemeService::GetFrom(Profile* profile) {
|
| + return static_cast<GtkThemeService*>(
|
| ThemeServiceFactory::GetForProfile(profile));
|
| }
|
|
|
| -ThemeServiceGtk::ThemeServiceGtk()
|
| +GtkThemeService::GtkThemeService()
|
| : ThemeService(),
|
| use_gtk_(false),
|
| fake_window_(gtk_window_new(GTK_WINDOW_TOPLEVEL)),
|
| @@ -273,7 +273,7 @@ ThemeServiceGtk::ThemeServiceGtk()
|
| G_CALLBACK(&OnStyleSetThunk), this);
|
| }
|
|
|
| -ThemeServiceGtk::~ThemeServiceGtk() {
|
| +GtkThemeService::~GtkThemeService() {
|
| gtk_widget_destroy(fake_window_);
|
| gtk_widget_destroy(fake_frame_);
|
| fake_label_.Destroy();
|
| @@ -287,21 +287,21 @@ ThemeServiceGtk::~ThemeServiceGtk() {
|
| FreePlatformCaches();
|
| }
|
|
|
| -void ThemeServiceGtk::Init(Profile* profile) {
|
| +void GtkThemeService::Init(Profile* profile) {
|
| registrar_.Init(profile->GetPrefs());
|
| registrar_.Add(prefs::kUsesSystemTheme, this);
|
| use_gtk_ = profile->GetPrefs()->GetBoolean(prefs::kUsesSystemTheme);
|
| ThemeService::Init(profile);
|
| }
|
|
|
| -SkBitmap* ThemeServiceGtk::GetBitmapNamed(int id) const {
|
| +SkBitmap* GtkThemeService::GetBitmapNamed(int id) const {
|
| // TODO(erg): Remove this const cast. The gfx::Image interface returns its
|
| // images const. GetBitmapNamed() also should but doesn't and has a million
|
| // callsites.
|
| return const_cast<SkBitmap*>(GetImageNamed(id)->ToSkBitmap());
|
| }
|
|
|
| -const gfx::Image* ThemeServiceGtk::GetImageNamed(int id) const {
|
| +const gfx::Image* GtkThemeService::GetImageNamed(int id) const {
|
| // Try to get our cached version:
|
| ImageCache::const_iterator it = gtk_images_.find(id);
|
| if (it != gtk_images_.end())
|
| @@ -316,7 +316,7 @@ const gfx::Image* ThemeServiceGtk::GetImageNamed(int id) const {
|
| return ThemeService::GetImageNamed(id);
|
| }
|
|
|
| -SkColor ThemeServiceGtk::GetColor(int id) const {
|
| +SkColor GtkThemeService::GetColor(int id) const {
|
| if (use_gtk_) {
|
| ColorMap::const_iterator it = colors_.find(id);
|
| if (it != colors_.end())
|
| @@ -326,47 +326,47 @@ SkColor ThemeServiceGtk::GetColor(int id) const {
|
| return ThemeService::GetColor(id);
|
| }
|
|
|
| -bool ThemeServiceGtk::HasCustomImage(int id) const {
|
| +bool GtkThemeService::HasCustomImage(int id) const {
|
| if (use_gtk_)
|
| return IsOverridableImage(id);
|
|
|
| return ThemeService::HasCustomImage(id);
|
| }
|
|
|
| -void ThemeServiceGtk::InitThemesFor(NotificationObserver* observer) {
|
| +void GtkThemeService::InitThemesFor(NotificationObserver* observer) {
|
| observer->Observe(chrome::NOTIFICATION_BROWSER_THEME_CHANGED,
|
| content::Source<ThemeService>(this),
|
| content::NotificationService::NoDetails());
|
| }
|
|
|
| -void ThemeServiceGtk::SetTheme(const Extension* extension) {
|
| +void GtkThemeService::SetTheme(const Extension* extension) {
|
| profile()->GetPrefs()->SetBoolean(prefs::kUsesSystemTheme, false);
|
| LoadDefaultValues();
|
| ThemeService::SetTheme(extension);
|
| }
|
|
|
| -void ThemeServiceGtk::UseDefaultTheme() {
|
| +void GtkThemeService::UseDefaultTheme() {
|
| profile()->GetPrefs()->SetBoolean(prefs::kUsesSystemTheme, false);
|
| LoadDefaultValues();
|
| ThemeService::UseDefaultTheme();
|
| }
|
|
|
| -void ThemeServiceGtk::SetNativeTheme() {
|
| +void GtkThemeService::SetNativeTheme() {
|
| profile()->GetPrefs()->SetBoolean(prefs::kUsesSystemTheme, true);
|
| ClearAllThemeData();
|
| LoadGtkValues();
|
| NotifyThemeChanged();
|
| }
|
|
|
| -bool ThemeServiceGtk::UsingDefaultTheme() const {
|
| +bool GtkThemeService::UsingDefaultTheme() const {
|
| return !use_gtk_ && ThemeService::UsingDefaultTheme();
|
| }
|
|
|
| -bool ThemeServiceGtk::UsingNativeTheme() const {
|
| +bool GtkThemeService::UsingNativeTheme() const {
|
| return use_gtk_;
|
| }
|
|
|
| -void ThemeServiceGtk::Observe(int type,
|
| +void GtkThemeService::Observe(int type,
|
| const content::NotificationSource& source,
|
| const content::NotificationDetails& details) {
|
| if ((type == chrome::NOTIFICATION_PREF_CHANGED) &&
|
| @@ -378,7 +378,7 @@ void ThemeServiceGtk::Observe(int type,
|
| }
|
| }
|
|
|
| -GtkWidget* ThemeServiceGtk::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);
|
| @@ -388,7 +388,7 @@ GtkWidget* ThemeServiceGtk::BuildChromeButton() {
|
| return button;
|
| }
|
|
|
| -GtkWidget* ThemeServiceGtk::BuildChromeLinkButton(const std::string& text) {
|
| +GtkWidget* GtkThemeService::BuildChromeLinkButton(const std::string& text) {
|
| GtkWidget* link_button = gtk_chrome_link_button_new(text.c_str());
|
| gtk_chrome_link_button_set_use_gtk_theme(
|
| GTK_CHROME_LINK_BUTTON(link_button),
|
| @@ -401,7 +401,7 @@ GtkWidget* ThemeServiceGtk::BuildChromeLinkButton(const std::string& text) {
|
| return link_button;
|
| }
|
|
|
| -GtkWidget* ThemeServiceGtk::BuildLabel(const std::string& text,
|
| +GtkWidget* GtkThemeService::BuildLabel(const std::string& text,
|
| GdkColor color) {
|
| GtkWidget* label = gtk_label_new(text.empty() ? NULL : text.c_str());
|
| if (!use_gtk_)
|
| @@ -413,7 +413,7 @@ GtkWidget* ThemeServiceGtk::BuildLabel(const std::string& text,
|
| return label;
|
| }
|
|
|
| -GtkWidget* ThemeServiceGtk::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),
|
| @@ -425,11 +425,11 @@ GtkWidget* ThemeServiceGtk::CreateToolbarSeparator() {
|
| return alignment;
|
| }
|
|
|
| -GdkColor ThemeServiceGtk::GetGdkColor(int id) const {
|
| +GdkColor GtkThemeService::GetGdkColor(int id) const {
|
| return gfx::SkColorToGdkColor(GetColor(id));
|
| }
|
|
|
| -GdkColor ThemeServiceGtk::GetBorderColor() const {
|
| +GdkColor GtkThemeService::GetBorderColor() const {
|
| GtkStyle* style = gtk_rc_get_style(fake_window_);
|
|
|
| GdkColor text;
|
| @@ -453,14 +453,14 @@ GdkColor ThemeServiceGtk::GetBorderColor() const {
|
| return color;
|
| }
|
|
|
| -GtkIconSet* ThemeServiceGtk::GetIconSetForId(int id) const {
|
| +GtkIconSet* GtkThemeService::GetIconSetForId(int id) const {
|
| if (id == IDR_FULLSCREEN_MENU_BUTTON)
|
| return fullscreen_icon_set_;
|
|
|
| return NULL;
|
| }
|
|
|
| -void ThemeServiceGtk::GetScrollbarColors(GdkColor* thumb_active_color,
|
| +void GtkThemeService::GetScrollbarColors(GdkColor* thumb_active_color,
|
| GdkColor* thumb_inactive_color,
|
| GdkColor* track_color) {
|
| const GdkColor* theme_thumb_active = NULL;
|
| @@ -561,7 +561,7 @@ void ThemeServiceGtk::GetScrollbarColors(GdkColor* thumb_active_color,
|
| }
|
|
|
| // static
|
| -gfx::Image* ThemeServiceGtk::GetFolderIcon(bool native) {
|
| +gfx::Image* GtkThemeService::GetFolderIcon(bool native) {
|
| if (native) {
|
| if (!icon_widget_)
|
| icon_widget_ = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
| @@ -581,7 +581,7 @@ gfx::Image* ThemeServiceGtk::GetFolderIcon(bool native) {
|
| }
|
|
|
| // static
|
| -gfx::Image* ThemeServiceGtk::GetDefaultFavicon(bool native) {
|
| +gfx::Image* GtkThemeService::GetDefaultFavicon(bool native) {
|
| if (native) {
|
| if (!icon_widget_)
|
| icon_widget_ = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
| @@ -601,7 +601,7 @@ gfx::Image* ThemeServiceGtk::GetDefaultFavicon(bool native) {
|
| }
|
|
|
| // static
|
| -bool ThemeServiceGtk::DefaultUsesSystemTheme() {
|
| +bool GtkThemeService::DefaultUsesSystemTheme() {
|
| scoped_ptr<base::Environment> env(base::Environment::Create());
|
|
|
| switch (base::nix::GetDesktopEnvironment(env.get())) {
|
| @@ -613,14 +613,14 @@ bool ThemeServiceGtk::DefaultUsesSystemTheme() {
|
| }
|
| }
|
|
|
| -void ThemeServiceGtk::ClearAllThemeData() {
|
| +void GtkThemeService::ClearAllThemeData() {
|
| colors_.clear();
|
| tints_.clear();
|
|
|
| ThemeService::ClearAllThemeData();
|
| }
|
|
|
| -void ThemeServiceGtk::LoadThemePrefs() {
|
| +void GtkThemeService::LoadThemePrefs() {
|
| if (use_gtk_) {
|
| LoadGtkValues();
|
| } else {
|
| @@ -631,7 +631,7 @@ void ThemeServiceGtk::LoadThemePrefs() {
|
| RebuildMenuIconSets();
|
| }
|
|
|
| -void ThemeServiceGtk::NotifyThemeChanged() {
|
| +void GtkThemeService::NotifyThemeChanged() {
|
| ThemeService::NotifyThemeChanged();
|
|
|
| // Notify all GtkChromeButtons of their new rendering mode:
|
| @@ -661,12 +661,12 @@ void ThemeServiceGtk::NotifyThemeChanged() {
|
| }
|
| }
|
|
|
| -void ThemeServiceGtk::FreePlatformCaches() {
|
| +void GtkThemeService::FreePlatformCaches() {
|
| ThemeService::FreePlatformCaches();
|
| STLDeleteValues(>k_images_);
|
| }
|
|
|
| -void ThemeServiceGtk::OnStyleSet(GtkWidget* widget,
|
| +void GtkThemeService::OnStyleSet(GtkWidget* widget,
|
| GtkStyle* previous_style) {
|
| gfx::Image* default_folder_icon = default_folder_icon_;
|
| gfx::Image* default_bookmark_icon = default_bookmark_icon_;
|
| @@ -689,7 +689,7 @@ void ThemeServiceGtk::OnStyleSet(GtkWidget* widget,
|
| delete default_bookmark_icon;
|
| }
|
|
|
| -void ThemeServiceGtk::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.)
|
| @@ -788,7 +788,7 @@ void ThemeServiceGtk::LoadGtkValues() {
|
| // Generate the colors that we pass to WebKit.
|
| focus_ring_color_ = gfx::GdkColorToSkColor(frame_color);
|
| GdkColor thumb_active_color, thumb_inactive_color, track_color;
|
| - ThemeServiceGtk::GetScrollbarColors(&thumb_active_color,
|
| + GtkThemeService::GetScrollbarColors(&thumb_active_color,
|
| &thumb_inactive_color,
|
| &track_color);
|
| thumb_active_color_ = gfx::GdkColorToSkColor(thumb_active_color);
|
| @@ -807,7 +807,7 @@ void ThemeServiceGtk::LoadGtkValues() {
|
| gfx::GdkColorToSkColor(entry_style->text[GTK_STATE_ACTIVE]);
|
| }
|
|
|
| -GdkColor ThemeServiceGtk::BuildFrameColors(GtkStyle* frame_style) {
|
| +GdkColor GtkThemeService::BuildFrameColors(GtkStyle* frame_style) {
|
| GdkColor* theme_frame = NULL;
|
| GdkColor* theme_inactive_frame = NULL;
|
| GdkColor* theme_incognito_frame = NULL;
|
| @@ -860,7 +860,7 @@ GdkColor ThemeServiceGtk::BuildFrameColors(GtkStyle* frame_style) {
|
| return frame_color;
|
| }
|
|
|
| -void ThemeServiceGtk::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);
|
| @@ -872,7 +872,7 @@ void ThemeServiceGtk::LoadDefaultValues() {
|
| inactive_selection_fg_color_ = SkColorSetRGB(50, 50, 50);
|
| }
|
|
|
| -void ThemeServiceGtk::RebuildMenuIconSets() {
|
| +void GtkThemeService::RebuildMenuIconSets() {
|
| FreeIconSets();
|
|
|
| GtkStyle* style = gtk_rc_get_style(fake_menu_item_.get());
|
| @@ -888,11 +888,11 @@ void ThemeServiceGtk::RebuildMenuIconSets() {
|
| fullscreen_icon_set_);
|
| }
|
|
|
| -void ThemeServiceGtk::SetThemeColorFromGtk(int id, const GdkColor* color) {
|
| +void GtkThemeService::SetThemeColorFromGtk(int id, const GdkColor* color) {
|
| colors_[id] = gfx::GdkColorToSkColor(*color);
|
| }
|
|
|
| -void ThemeServiceGtk::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(gfx::GdkColorToSkColor(*color), &hsl);
|
| @@ -906,7 +906,7 @@ void ThemeServiceGtk::SetThemeTintFromGtk(int id, const GdkColor* color) {
|
| tints_[id] = hsl;
|
| }
|
|
|
| -GdkColor ThemeServiceGtk::BuildAndSetFrameColor(const GdkColor* base,
|
| +GdkColor GtkThemeService::BuildAndSetFrameColor(const GdkColor* base,
|
| const GdkColor* gtk_base,
|
| const color_utils::HSL& tint,
|
| int color_id,
|
| @@ -926,14 +926,14 @@ GdkColor ThemeServiceGtk::BuildAndSetFrameColor(const GdkColor* base,
|
| return out_color;
|
| }
|
|
|
| -void ThemeServiceGtk::FreeIconSets() {
|
| +void GtkThemeService::FreeIconSets() {
|
| if (fullscreen_icon_set_) {
|
| gtk_icon_set_unref(fullscreen_icon_set_);
|
| fullscreen_icon_set_ = NULL;
|
| }
|
| }
|
|
|
| -SkBitmap* ThemeServiceGtk::GenerateGtkThemeBitmap(int id) const {
|
| +SkBitmap* GtkThemeService::GenerateGtkThemeBitmap(int id) const {
|
| switch (id) {
|
| case IDR_THEME_TOOLBAR: {
|
| GtkStyle* style = gtk_rc_get_style(fake_window_);
|
| @@ -995,7 +995,7 @@ SkBitmap* ThemeServiceGtk::GenerateGtkThemeBitmap(int id) const {
|
| }
|
| }
|
|
|
| -SkBitmap* ThemeServiceGtk::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
|
| @@ -1035,7 +1035,7 @@ SkBitmap* ThemeServiceGtk::GenerateFrameImage(
|
| return new SkBitmap(canvas.ExtractBitmap());
|
| }
|
|
|
| -SkBitmap* ThemeServiceGtk::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(ThemeService::TINT_BACKGROUND_TAB));
|
| @@ -1043,7 +1043,7 @@ SkBitmap* ThemeServiceGtk::GenerateTabImage(int base_id) const {
|
| bg_tint, 0, 0, bg_tint.width(), bg_tint.height()));
|
| }
|
|
|
| -SkBitmap* ThemeServiceGtk::GenerateTintedIcon(
|
| +SkBitmap* GtkThemeService::GenerateTintedIcon(
|
| int base_id,
|
| const color_utils::HSL& tint) const {
|
| ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
|
| @@ -1051,7 +1051,7 @@ SkBitmap* ThemeServiceGtk::GenerateTintedIcon(
|
| *rb.GetBitmapNamed(base_id), tint));
|
| }
|
|
|
| -void ThemeServiceGtk::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];
|
| @@ -1063,7 +1063,7 @@ void ThemeServiceGtk::GetNormalButtonTintHSL(
|
| PickButtonTintFromColors(accent_gdk_color, text_color, base_color, tint);
|
| }
|
|
|
| -void ThemeServiceGtk::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];
|
| @@ -1075,7 +1075,7 @@ void ThemeServiceGtk::GetNormalEntryForegroundHSL(
|
| PickButtonTintFromColors(accent_gdk_color, text_color, base_color, tint);
|
| }
|
|
|
| -void ThemeServiceGtk::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
|
| @@ -1085,29 +1085,29 @@ void ThemeServiceGtk::GetSelectedEntryForegroundHSL(
|
| color_utils::SkColorToHSL(gfx::GdkColorToSkColor(color), tint);
|
| }
|
|
|
| -void ThemeServiceGtk::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);
|
| }
|
|
|
| -void ThemeServiceGtk::OnDestroyChromeLinkButton(GtkWidget* button) {
|
| +void GtkThemeService::OnDestroyChromeLinkButton(GtkWidget* button) {
|
| std::vector<GtkWidget*>::iterator it =
|
| find(link_buttons_.begin(), link_buttons_.end(), button);
|
| if (it != link_buttons_.end())
|
| link_buttons_.erase(it);
|
| }
|
|
|
| -void ThemeServiceGtk::OnDestroyLabel(GtkWidget* button) {
|
| +void GtkThemeService::OnDestroyLabel(GtkWidget* button) {
|
| std::map<GtkWidget*, GdkColor>::iterator it = labels_.find(button);
|
| if (it != labels_.end())
|
| labels_.erase(it);
|
| }
|
|
|
| -gboolean ThemeServiceGtk::OnSeparatorExpose(GtkWidget* widget,
|
| +gboolean GtkThemeService::OnSeparatorExpose(GtkWidget* widget,
|
| GdkEventExpose* event) {
|
| - UNSHIPPED_TRACE_EVENT0("ui::gtk", "ThemeServiceGtk::OnSeparatorExpose");
|
| + UNSHIPPED_TRACE_EVENT0("ui::gtk", "GtkThemeService::OnSeparatorExpose");
|
| if (UsingNativeTheme())
|
| return FALSE;
|
|
|
|
|