summaryrefslogtreecommitdiffstats
path: root/chrome/browser/browser_theme_provider.cc
diff options
context:
space:
mode:
authoravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-11 14:36:52 +0000
committeravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-11 14:36:52 +0000
commit7cd83d1caff7fa1090d9fc8eadb7474cb3b811f2 (patch)
tree7150d07291e245bdbefe440675f3f7243e1d4e1a /chrome/browser/browser_theme_provider.cc
parent9b7d65f37d3392c5f69e44e053e9b3a3184b431d (diff)
downloadchromium_src-7cd83d1caff7fa1090d9fc8eadb7474cb3b811f2.zip
chromium_src-7cd83d1caff7fa1090d9fc8eadb7474cb3b811f2.tar.gz
chromium_src-7cd83d1caff7fa1090d9fc8eadb7474cb3b811f2.tar.bz2
Allow theming of colors for the Mac.
BUG=http://crbug.com/18438 TEST=none Review URL: http://codereview.chromium.org/162010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23023 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browser_theme_provider.cc')
-rw-r--r--chrome/browser/browser_theme_provider.cc98
1 files changed, 68 insertions, 30 deletions
diff --git a/chrome/browser/browser_theme_provider.cc b/chrome/browser/browser_theme_provider.cc
index c6da8b9..ff33e43 100644
--- a/chrome/browser/browser_theme_provider.cc
+++ b/chrome/browser/browser_theme_provider.cc
@@ -258,52 +258,95 @@ SkBitmap* BrowserThemeProvider::GetBitmapNamed(int id) {
}
}
-SkColor BrowserThemeProvider::GetColor(int id) {
- DCHECK(CalledOnValidThread());
-
- // TODO(glen): Figure out if we need to tint these. http://crbug.com/11578
+const std::string BrowserThemeProvider::GetColorKey(int id) {
switch (id) {
case COLOR_FRAME:
- return FindColor(kColorFrame, kDefaultColorFrame);
+ return kColorFrame;
case COLOR_FRAME_INACTIVE:
- return FindColor(kColorFrameInactive, kDefaultColorFrameInactive);
+ return kColorFrameInactive;
case COLOR_FRAME_INCOGNITO:
- return FindColor(kColorFrameIncognito, kDefaultColorFrameIncognito);
+ return kColorFrameIncognito;
case COLOR_FRAME_INCOGNITO_INACTIVE:
- return FindColor(kColorFrameIncognitoInactive,
- kDefaultColorFrameIncognitoInactive);
+ return kColorFrameIncognitoInactive;
case COLOR_TOOLBAR:
- return FindColor(kColorToolbar, kDefaultColorToolbar);
+ return kColorToolbar;
case COLOR_TAB_TEXT:
- return FindColor(kColorTabText, kDefaultColorTabText);
+ return kColorTabText;
case COLOR_BACKGROUND_TAB_TEXT:
- return FindColor(kColorBackgroundTabText, kDefaultColorBackgroundTabText);
+ return kColorBackgroundTabText;
case COLOR_BOOKMARK_TEXT:
- return FindColor(kColorBookmarkText, kDefaultColorBookmarkText);
+ return kColorBookmarkText;
case COLOR_NTP_BACKGROUND:
- return (colors_.find(kColorNTPBackground) != colors_.end()) ?
- colors_[kColorNTPBackground] :
- kDefaultColorNTPBackground;
+ return kColorNTPBackground;
case COLOR_NTP_TEXT:
- return FindColor(kColorNTPText, kDefaultColorNTPText);
+ return kColorNTPText;
case COLOR_NTP_LINK:
- return FindColor(kColorNTPLink, kDefaultColorNTPLink);
+ return kColorNTPLink;
case COLOR_NTP_SECTION:
- return FindColor(kColorNTPSection, kDefaultColorNTPSection);
+ return kColorNTPSection;
case COLOR_NTP_SECTION_TEXT:
- return FindColor(kColorNTPSectionText, kDefaultColorNTPSectionText);
+ return kColorNTPSectionText;
case COLOR_NTP_SECTION_LINK:
- return FindColor(kColorNTPSectionLink, kDefaultColorNTPSectionLink);
+ return kColorNTPSectionLink;
case COLOR_CONTROL_BACKGROUND:
- return FindColor(kColorControlBackground, kDefaultColorControlBackground);
+ return kColorControlBackground;
case COLOR_BUTTON_BACKGROUND:
- return FindColor(kColorButtonBackground, kDefaultColorButtonBackground);
+ return kColorButtonBackground;
default:
NOTREACHED() << "Unknown color requested";
+ return "";
+ }
+}
+
+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_SECTION:
+ return kDefaultColorNTPSection;
+ case COLOR_NTP_SECTION_TEXT:
+ return kDefaultColorNTPSectionText;
+ case COLOR_NTP_SECTION_LINK:
+ return kDefaultColorNTPSectionLink;
+ case COLOR_CONTROL_BACKGROUND:
+ return kDefaultColorControlBackground;
+ case COLOR_BUTTON_BACKGROUND:
+ return kDefaultColorButtonBackground;
+ default:
+ // Return a debugging red color.
+ return 0xffff0000;
}
+}
+
+SkColor BrowserThemeProvider::GetColor(int id) {
+ DCHECK(CalledOnValidThread());
- // Return a debugging red color.
- return 0xffff0000;
+ // TODO(glen): Figure out if we need to tint these. http://crbug.com/11578
+ ColorMap::iterator color_iter = colors_.find(GetColorKey(id));
+ if (color_iter != colors_.end())
+ return color_iter->second;
+ else
+ return GetDefaultColor(id);
}
bool BrowserThemeProvider::GetDisplayProperty(int id, int* result) {
@@ -970,11 +1013,6 @@ void BrowserThemeProvider::LoadThemePrefs() {
}
}
-SkColor BrowserThemeProvider::FindColor(const char* id,
- SkColor default_color) {
- return (colors_.find(id) != colors_.end()) ? colors_[id] : default_color;
-}
-
void BrowserThemeProvider::ClearCaches() {
FreePlatformCaches();
for (ImageCache::iterator i = image_cache_.begin();