| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_UI_GTK_GTK_THEME_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_UI_GTK_GTK_THEME_SERVICE_H_ |
| 6 #define CHROME_BROWSER_UI_GTK_GTK_THEME_SERVICE_H_ | 6 #define CHROME_BROWSER_UI_GTK_GTK_THEME_SERVICE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/compiler_specific.h" |
| 12 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 13 #include "chrome/browser/prefs/pref_change_registrar.h" | 14 #include "chrome/browser/prefs/pref_change_registrar.h" |
| 14 #include "chrome/browser/themes/theme_service.h" | 15 #include "chrome/browser/themes/theme_service.h" |
| 15 #include "content/public/browser/notification_observer.h" | 16 #include "content/public/browser/notification_observer.h" |
| 16 #include "ui/base/glib/glib_integers.h" | 17 #include "ui/base/glib/glib_integers.h" |
| 17 #include "ui/base/gtk/gtk_signal.h" | 18 #include "ui/base/gtk/gtk_signal.h" |
| 18 #include "ui/base/gtk/owned_widget_gtk.h" | 19 #include "ui/base/gtk/owned_widget_gtk.h" |
| 19 #include "ui/gfx/color_utils.h" | 20 #include "ui/gfx/color_utils.h" |
| 20 | 21 |
| 21 class CairoCachedSurface; | 22 class CairoCachedSurface; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 51 virtual ~GtkThemeService(); | 52 virtual ~GtkThemeService(); |
| 52 | 53 |
| 53 // Calls |observer|.Observe() for the browser theme with this provider as the | 54 // Calls |observer|.Observe() for the browser theme with this provider as the |
| 54 // source. | 55 // source. |
| 55 void InitThemesFor(content::NotificationObserver* observer); | 56 void InitThemesFor(content::NotificationObserver* observer); |
| 56 | 57 |
| 57 // Overridden from ThemeService: | 58 // Overridden from ThemeService: |
| 58 // | 59 // |
| 59 // Sets that we aren't using the system theme, then calls | 60 // Sets that we aren't using the system theme, then calls |
| 60 // ThemeService's implementation. | 61 // ThemeService's implementation. |
| 61 virtual void Init(Profile* profile); | 62 virtual void Init(Profile* profile) OVERRIDE; |
| 62 virtual SkBitmap* GetBitmapNamed(int id) const; | 63 virtual SkBitmap* GetBitmapNamed(int id) const OVERRIDE; |
| 63 virtual SkColor GetColor(int id) const; | 64 virtual SkColor GetColor(int id) const OVERRIDE; |
| 64 virtual bool HasCustomImage(int id) const; | 65 virtual bool HasCustomImage(int id) const OVERRIDE; |
| 65 virtual void SetTheme(const Extension* extension); | 66 virtual void SetTheme(const Extension* extension) OVERRIDE; |
| 66 virtual void UseDefaultTheme(); | 67 virtual void UseDefaultTheme() OVERRIDE; |
| 67 virtual void SetNativeTheme(); | 68 virtual void SetNativeTheme() OVERRIDE; |
| 68 virtual bool UsingDefaultTheme() const; | 69 virtual bool UsingDefaultTheme() const OVERRIDE; |
| 69 virtual bool UsingNativeTheme() const; | 70 virtual bool UsingNativeTheme() const OVERRIDE; |
| 70 | 71 |
| 71 // Overridden from ThemeService, content::NotificationObserver: | 72 // Overridden from ThemeService, content::NotificationObserver: |
| 72 virtual void Observe(int type, | 73 virtual void Observe(int type, |
| 73 const content::NotificationSource& source, | 74 const content::NotificationSource& source, |
| 74 const content::NotificationDetails& details); | 75 const content::NotificationDetails& details) OVERRIDE; |
| 75 | 76 |
| 76 // Creates a GtkChromeButton instance, registered with this theme provider, | 77 // Creates a GtkChromeButton instance, registered with this theme provider, |
| 77 // with a "destroy" signal to remove it from our internal list when it goes | 78 // with a "destroy" signal to remove it from our internal list when it goes |
| 78 // away. | 79 // away. |
| 79 GtkWidget* BuildChromeButton(); | 80 GtkWidget* BuildChromeButton(); |
| 80 | 81 |
| 81 // Creates a GtkChromeLinkButton instance. We update its state as theme | 82 // Creates a GtkChromeLinkButton instance. We update its state as theme |
| 82 // changes, and listen for its destruction. | 83 // changes, and listen for its destruction. |
| 83 GtkWidget* BuildChromeLinkButton(const std::string& text); | 84 GtkWidget* BuildChromeLinkButton(const std::string& text); |
| 84 | 85 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 private: | 166 private: |
| 166 typedef std::map<int, SkColor> ColorMap; | 167 typedef std::map<int, SkColor> ColorMap; |
| 167 typedef std::map<int, color_utils::HSL> TintMap; | 168 typedef std::map<int, color_utils::HSL> TintMap; |
| 168 typedef std::map<int, SkBitmap*> ImageCache; | 169 typedef std::map<int, SkBitmap*> ImageCache; |
| 169 typedef std::map<int, CairoCachedSurface*> CairoCachedSurfaceMap; | 170 typedef std::map<int, CairoCachedSurface*> CairoCachedSurfaceMap; |
| 170 typedef std::map<GdkDisplay*, CairoCachedSurfaceMap> PerDisplaySurfaceMap; | 171 typedef std::map<GdkDisplay*, CairoCachedSurfaceMap> PerDisplaySurfaceMap; |
| 171 | 172 |
| 172 typedef GdkPixbuf*(GtkThemeService::*PixbufProvidingMethod)(int id) const; | 173 typedef GdkPixbuf*(GtkThemeService::*PixbufProvidingMethod)(int id) const; |
| 173 | 174 |
| 174 // Clears all the GTK color overrides. | 175 // Clears all the GTK color overrides. |
| 175 virtual void ClearAllThemeData(); | 176 virtual void ClearAllThemeData() OVERRIDE; |
| 176 | 177 |
| 177 // Load theme data from preferences, possibly picking colors from GTK. | 178 // Load theme data from preferences, possibly picking colors from GTK. |
| 178 virtual void LoadThemePrefs(); | 179 virtual void LoadThemePrefs() OVERRIDE; |
| 179 | 180 |
| 180 // Let all the browser views know that themes have changed. | 181 // Let all the browser views know that themes have changed. |
| 181 virtual void NotifyThemeChanged(); | 182 virtual void NotifyThemeChanged() OVERRIDE; |
| 182 | 183 |
| 183 // Additionally frees the CairoCachedSurfaces. | 184 // Additionally frees the CairoCachedSurfaces. |
| 184 virtual void FreePlatformCaches(); | 185 virtual void FreePlatformCaches() OVERRIDE; |
| 185 | 186 |
| 186 // Extracts colors and tints from the GTK theme, both for the | 187 // Extracts colors and tints from the GTK theme, both for the |
| 187 // ThemeService interface and the colors we send to webkit. | 188 // ThemeService interface and the colors we send to webkit. |
| 188 void LoadGtkValues(); | 189 void LoadGtkValues(); |
| 189 | 190 |
| 190 // Reads in explicit theme frame colors from the ChromeGtkFrame style class | 191 // Reads in explicit theme frame colors from the ChromeGtkFrame style class |
| 191 // or generates them per our fallback algorithm. | 192 // or generates them per our fallback algorithm. |
| 192 GdkColor BuildFrameColors(GtkStyle* frame_style); | 193 GdkColor BuildFrameColors(GtkStyle* frame_style); |
| 193 | 194 |
| 194 // Sets the values that we send to webkit to safe defaults. | 195 // Sets the values that we send to webkit to safe defaults. |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 | 343 |
| 343 // The default folder icon and default bookmark icon for the GTK theme. | 344 // The default folder icon and default bookmark icon for the GTK theme. |
| 344 // These are static because the system can only have one theme at a time. | 345 // These are static because the system can only have one theme at a time. |
| 345 // They are cached when they are requested the first time, and cleared when | 346 // They are cached when they are requested the first time, and cleared when |
| 346 // the system theme changes. | 347 // the system theme changes. |
| 347 static GdkPixbuf* default_folder_icon_; | 348 static GdkPixbuf* default_folder_icon_; |
| 348 static GdkPixbuf* default_bookmark_icon_; | 349 static GdkPixbuf* default_bookmark_icon_; |
| 349 }; | 350 }; |
| 350 | 351 |
| 351 #endif // CHROME_BROWSER_UI_GTK_GTK_THEME_SERVICE_H_ | 352 #endif // CHROME_BROWSER_UI_GTK_GTK_THEME_SERVICE_H_ |
| OLD | NEW |