summaryrefslogtreecommitdiffstats
path: root/chrome/browser/browser_theme_provider.h
diff options
context:
space:
mode:
authorerg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-03 00:42:29 +0000
committererg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-03 00:42:29 +0000
commita5166af69628552e4bcf746a38f3710cc895eac3 (patch)
tree0d6e0ab20143724111855ac501aad3fd469e6b8d /chrome/browser/browser_theme_provider.h
parent08f91cc8431cc6dea19e3c3ff3a229c71a7fc71f (diff)
downloadchromium_src-a5166af69628552e4bcf746a38f3710cc895eac3.zip
chromium_src-a5166af69628552e4bcf746a38f3710cc895eac3.tar.gz
chromium_src-a5166af69628552e4bcf746a38f3710cc895eac3.tar.bz2
GTK: Initial implementation of using GTK themes, partially based on evan's CL 118358.
A lot of stuff works: - Colors are picked out of the GTK theme. - Buttons use the current GTK button theme. - We use the user's icon theme. A lot of stuff doesn't: - We could do a better job of picking colors for the skylines. - The omnibox hasn't been touched. - UI that's not part of the toolbar hasn't been touched. - We currently fail on themes like HighContrastInverse. TEST=Under Options>Personal Stuff, click GTK Theme. Colors and widgets should be rendered with the current GTK theme stuff. TEST=With chrome open and in GTK Theme mode, change your GTK theme or icon theme. chrome should pick up on the change immediately and reimport the colors and images. http://crbug.com/13967 Review URL: http://codereview.chromium.org/150176 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19868 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browser_theme_provider.h')
-rw-r--r--chrome/browser/browser_theme_provider.h119
1 files changed, 100 insertions, 19 deletions
diff --git a/chrome/browser/browser_theme_provider.h b/chrome/browser/browser_theme_provider.h
index b43a69c..b0c1b9c 100644
--- a/chrome/browser/browser_theme_provider.h
+++ b/chrome/browser/browser_theme_provider.h
@@ -20,6 +20,71 @@ class Extension;
class Profile;
class DictionaryValue;
+namespace themes {
+
+// Strings used by themes to identify colors for different parts of our UI.
+extern const char* kColorFrame;
+extern const char* kColorFrameInactive;
+extern const char* kColorFrameIncognito;
+extern const char* kColorFrameIncognitoInactive;
+extern const char* kColorToolbar;
+extern const char* kColorTabText;
+extern const char* kColorBackgroundTabText;
+extern const char* kColorBookmarkText;
+extern const char* kColorNTPBackground;
+extern const char* kColorNTPText;
+extern const char* kColorNTPLink;
+extern const char* kColorNTPSection;
+extern const char* kColorNTPSectionText;
+extern const char* kColorNTPSectionLink;
+extern const char* kColorControlBackground;
+extern const char* kColorButtonBackground;
+
+// Strings used by themes to identify tints to apply to different parts of
+// our UI. The frame tints apply to the frame color and produce the
+// COLOR_FRAME* colors.
+extern const char* kTintButtons;
+extern const char* kTintFrame;
+extern const char* kTintFrameInactive;
+extern const char* kTintFrameIncognito;
+extern const char* kTintFrameIncognitoInactive;
+extern const char* kTintBackgroundTab;
+
+// Strings used by themes to identify miscellaneous numerical properties.
+extern const char* kDisplayPropertyNTPAlignment;
+
+// Strings used in alignment properties.
+extern const char* kAlignmentTop;
+extern const char* kAlignmentBottom;
+extern const char* kAlignmentLeft;
+extern const char* kAlignmentRight;
+
+// Default colors.
+extern const SkColor kDefaultColorFrame;
+extern const SkColor kDefaultColorFrameInactive;
+extern const SkColor kDefaultColorFrameIncognito;
+extern const SkColor kDefaultColorFrameIncognitoInactive;
+extern const SkColor kDefaultColorToolbar;
+extern const SkColor kDefaultColorTabText;
+extern const SkColor kDefaultColorBackgroundTabText;
+extern const SkColor kDefaultColorBookmarkText;
+extern const SkColor kDefaultColorNTPBackground;
+extern const SkColor kDefaultColorNTPText;
+extern const SkColor kDefaultColorNTPLink;
+extern const SkColor kDefaultColorNTPSection;
+extern const SkColor kDefaultColorNTPSectionText;
+extern const SkColor kDefaultColorNTPSectionLink;
+extern const SkColor kDefaultColorControlBackground;
+extern const SkColor kDefaultColorButtonBackground;
+
+extern const skia::HSL kDefaultTintButtons;
+extern const skia::HSL kDefaultTintFrame;
+extern const skia::HSL kDefaultTintFrameInactive;
+extern const skia::HSL kDefaultTintFrameIncognito;
+extern const skia::HSL kDefaultTintFrameIncognitoInactive;
+extern const skia::HSL kDefaultTintBackgroundTab;
+} // namespace themes
+
class BrowserThemeProvider : public base::RefCounted<BrowserThemeProvider>,
public NonThreadSafe,
public ThemeProvider {
@@ -78,10 +143,14 @@ class BrowserThemeProvider : public base::RefCounted<BrowserThemeProvider>,
#endif
// Set the current theme to the theme defined in |extension|.
- void SetTheme(Extension* extension);
+ virtual void SetTheme(Extension* extension);
// Reset the theme to default.
- void UseDefaultTheme();
+ virtual void UseDefaultTheme();
+
+ // Set the current theme to the native theme. On some platforms, the native
+ // theme is the default theme.
+ virtual void SetNativeTheme() { UseDefaultTheme(); }
// 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.
@@ -91,6 +160,35 @@ class BrowserThemeProvider : public base::RefCounted<BrowserThemeProvider>,
// AlignmentMasks
static int StringToAlignment(const std::string &alignment);
+ protected:
+ // Sets an individual color value.
+ void SetColor(const char* id, const SkColor& color);
+
+ // Sets an individual tint value.
+ void SetTint(const char* id, const skia::HSL& tint);
+
+ // Generate any frame colors that weren't specified.
+ void GenerateFrameColors();
+
+ // Generate any frame images that weren't specified. The resulting images
+ // will be stored in our cache.
+ void GenerateFrameImages();
+
+ // Clears all the override fields and saves the dictionary.
+ void ClearAllThemeData();
+
+ // Load theme data from preferences.
+ virtual void LoadThemePrefs();
+
+ // Let all the browser views know that themes have changed.
+ void NotifyThemeChanged();
+
+ // Loads a bitmap from the theme, which may be tinted or
+ // otherwise modified, or an application default.
+ virtual SkBitmap* LoadThemeBitmap(int id);
+
+ Profile* profile() { return profile_; }
+
private:
typedef std::map<const int, std::string> ImageMap;
typedef std::map<const std::string, SkColor> ColorMap;
@@ -101,10 +199,6 @@ class BrowserThemeProvider : public base::RefCounted<BrowserThemeProvider>,
// true on success.
bool ReadThemeFileData(int id, std::vector<unsigned char>* raw_data);
- // Loads a bitmap from the theme, which may be tinted or
- // otherwise modified, or an application default.
- SkBitmap* LoadThemeBitmap(int id);
-
// Returns the string key for the given tint |id| TINT_* enum value.
const std::string GetTintKey(int id);
@@ -139,13 +233,6 @@ class BrowserThemeProvider : public base::RefCounted<BrowserThemeProvider>,
// strings, they are currently stored as integers.
void SetDisplayPropertyData(DictionaryValue* display_properties);
- // Generate any frame colors that weren't specified.
- void GenerateFrameColors();
-
- // Generate any frame images that weren't specified. The resulting images
- // will be stored in our cache.
- void GenerateFrameImages();
-
// Create any images that aren't pregenerated (e.g. background tab images).
SkBitmap* GenerateBitmap(int id);
@@ -156,12 +243,6 @@ class BrowserThemeProvider : public base::RefCounted<BrowserThemeProvider>,
void SaveTintData();
void SaveDisplayPropertyData();
- // Let all the browser views know that themes have changed.
- void NotifyThemeChanged();
-
- // Load theme data from preferences.
- void LoadThemePrefs();
-
SkColor FindColor(const char* id, SkColor default_color);
// Frees generated images and clears the image cache.