summaryrefslogtreecommitdiffstats
path: root/chrome/browser/browser_theme_provider.h
diff options
context:
space:
mode:
authorglen@chromium.org <glen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-02 20:53:50 +0000
committerglen@chromium.org <glen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-02 20:53:50 +0000
commit7895ea23e75075fd6f9fe5a6c3dfb17d3456b208 (patch)
treed9f36ade5222fbdab94c0b40f66b456f9eba308e /chrome/browser/browser_theme_provider.h
parent77be37906a16c98612360a2e35c257aa5484cf2d (diff)
downloadchromium_src-7895ea23e75075fd6f9fe5a6c3dfb17d3456b208.zip
chromium_src-7895ea23e75075fd6f9fe5a6c3dfb17d3456b208.tar.gz
chromium_src-7895ea23e75075fd6f9fe5a6c3dfb17d3456b208.tar.bz2
Allow themes to change the background of the new tab page. Adds support for display properties to themes (stored internally as ints/enums, but parsed from text).
BUG=12768 TEST=Install a theme with an new tab page background and verify that the background appears on the new tab page. Review URL: http://codereview.chromium.org/115910 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17431 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browser_theme_provider.h')
-rw-r--r--chrome/browser/browser_theme_provider.h30
1 files changed, 29 insertions, 1 deletions
diff --git a/chrome/browser/browser_theme_provider.h b/chrome/browser/browser_theme_provider.h
index 9565ad4..3280e1c 100644
--- a/chrome/browser/browser_theme_provider.h
+++ b/chrome/browser/browser_theme_provider.h
@@ -40,6 +40,7 @@ class BrowserThemeProvider : public base::RefCounted<BrowserThemeProvider>,
COLOR_TAB_TEXT,
COLOR_BACKGROUND_TAB_TEXT,
COLOR_BOOKMARK_TEXT,
+ COLOR_NTP_BACKGROUND,
COLOR_NTP_TEXT,
COLOR_NTP_LINK,
COLOR_NTP_SECTION,
@@ -48,14 +49,25 @@ class BrowserThemeProvider : public base::RefCounted<BrowserThemeProvider>,
TINT_FRAME_INACTIVE,
TINT_FRAME_INCOGNITO,
TINT_FRAME_INCOGNITO_INACTIVE,
- TINT_BACKGROUND_TAB
+ TINT_BACKGROUND_TAB,
+ NTP_BACKGROUND_ALIGNMENT
};
+ // A bitfield mask for alignments.
+ typedef enum {
+ ALIGN_CENTER = 0x0,
+ ALIGN_LEFT = 0x1,
+ ALIGN_TOP = 0x2,
+ ALIGN_RIGHT = 0x4,
+ ALIGN_BOTTOM = 0x8,
+ } AlignmentMasks;
+
void Init(Profile* profile);
// ThemeProvider implementation.
virtual SkBitmap* GetBitmapNamed(int id);
virtual SkColor GetColor(int id);
+ virtual bool GetDisplayProperty(int id, int* result);
virtual bool ShouldUseNativeFrame();
#if defined(OS_LINUX)
virtual GdkPixbuf* GetPixbufNamed(int id);
@@ -67,10 +79,19 @@ class BrowserThemeProvider : public base::RefCounted<BrowserThemeProvider>,
// Reset the theme to default.
void 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.
+ 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);
+
private:
typedef std::map<const int, std::string> ImageMap;
typedef std::map<const std::string, SkColor> ColorMap;
typedef std::map<const std::string, skia::HSL> TintMap;
+ typedef std::map<const std::string, int> DisplayPropertyMap;
// Loads a bitmap from the theme, which may be tinted or
// otherwise modified, or an application default.
@@ -94,11 +115,16 @@ class BrowserThemeProvider : public base::RefCounted<BrowserThemeProvider>,
// constants, and the values are a three-item list containing 8-bit
// RGB values.
void SetColorData(DictionaryValue* colors);
+
// Set tint data for our images and colors. The keys of |tints| are
// any of the kTint* contstants, and the values are a three-item list
// containing real numbers in the range 0-1 (and -1 for 'null').
void SetTintData(DictionaryValue* tints);
+ // Set miscellaneous display properties. While these can be defined as
+ // strings, they are currently stored as integers.
+ void SetDisplayPropertyData(DictionaryValue* display_properties);
+
// Generate any frame colors that weren't specified.
void GenerateFrameColors();
@@ -114,6 +140,7 @@ class BrowserThemeProvider : public base::RefCounted<BrowserThemeProvider>,
void SaveImageData(DictionaryValue* images);
void SaveColorData();
void SaveTintData();
+ void SaveDisplayPropertyData();
// Let all the browser views know that themes have changed.
void NotifyThemeChanged();
@@ -143,6 +170,7 @@ class BrowserThemeProvider : public base::RefCounted<BrowserThemeProvider>,
ImageMap images_;
ColorMap colors_;
TintMap tints_;
+ DisplayPropertyMap display_properties_;
DISALLOW_COPY_AND_ASSIGN(BrowserThemeProvider);
};