summaryrefslogtreecommitdiffstats
path: root/chrome/browser/browser_theme_provider.cc
diff options
context:
space:
mode:
authorglen@chromium.org <glen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-15 22:40:57 +0000
committerglen@chromium.org <glen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-15 22:40:57 +0000
commitdff6d13ca6ddb778867ce2d731d5f8093aef28ea (patch)
tree4758c346a2af607ec2a842c24f222e8fc401b6a8 /chrome/browser/browser_theme_provider.cc
parent05062e288e4b8f174a79cc698c3c97d7d12975be (diff)
downloadchromium_src-dff6d13ca6ddb778867ce2d731d5f8093aef28ea.zip
chromium_src-dff6d13ca6ddb778867ce2d731d5f8093aef28ea.tar.gz
chromium_src-dff6d13ca6ddb778867ce2d731d5f8093aef28ea.tar.bz2
Re-land of earlier NTP theme patch; now with mac and linux compatibility.
Review URL: http://codereview.chromium.org/115413 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16205 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browser_theme_provider.cc')
-rw-r--r--chrome/browser/browser_theme_provider.cc81
1 files changed, 54 insertions, 27 deletions
diff --git a/chrome/browser/browser_theme_provider.cc b/chrome/browser/browser_theme_provider.cc
index 5774f36..64124bc 100644
--- a/chrome/browser/browser_theme_provider.cc
+++ b/chrome/browser/browser_theme_provider.cc
@@ -22,29 +22,29 @@
#include "SkBitmap.h"
// Strings used by themes to identify colors for different parts of our UI.
-static const std::string kColorFrame = "frame";
-static const std::string kColorFrameInactive = "frame_inactive";
-static const std::string kColorFrameIncognito = "frame_incognito";
-static const std::string kColorFrameIncognitoInactive =
+static const char* kColorFrame = "frame";
+static const char* kColorFrameInactive = "frame_inactive";
+static const char* kColorFrameIncognito = "frame_incognito";
+static const char* kColorFrameIncognitoInactive =
"frame_incognito_inactive";
-static const std::string kColorToolbar = "toolbar";
-static const std::string kColorTabText = "tab_text";
-static const std::string kColorBackgroundTabText = "background_tab_text";
-static const std::string kColorBookmarkText = "bookmark_text";
-static const std::string kColorNTPText = "ntp_text";
-static const std::string kColorNTPLink = "ntp_link";
-static const std::string kColorNTPSection = "ntp_section";
+static const char* kColorToolbar = "toolbar";
+static const char* kColorTabText = "tab_text";
+static const char* kColorBackgroundTabText = "background_tab_text";
+static const char* kColorBookmarkText = "bookmark_text";
+static const char* kColorNTPText = "ntp_text";
+static const char* kColorNTPLink = "ntp_link";
+static const char* kColorNTPSection = "ntp_section";
// 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.
-static const std::string kTintButtons = "buttons";
-static const std::string kTintFrame = "frame";
-static const std::string kTintFrameInactive = "frame_inactive";
-static const std::string kTintFrameIncognito = "frame_incognito";
-static const std::string kTintFrameIncognitoInactive =
+static const char* kTintButtons = "buttons";
+static const char* kTintFrame = "frame";
+static const char* kTintFrameInactive = "frame_inactive";
+static const char* kTintFrameIncognito = "frame_incognito";
+static const char* kTintFrameIncognitoInactive =
"frame_incognito_inactive";
-static const std::string kTintBackgroundTab = "background_tab";
+static const char* kTintBackgroundTab = "background_tab";
// Default colors.
static const SkColor kDefaultColorFrame = SkColorSetRGB(77, 139, 217);
@@ -55,6 +55,10 @@ static const SkColor kDefaultColorFrameIncognitoInactive =
static const SkColor kDefaultColorToolbar = SkColorSetRGB(210, 225, 246);
static const SkColor kDefaultColorTabText = SkColorSetRGB(0, 0, 0);
static const SkColor kDefaultColorBackgroundTabText = SkColorSetRGB(64, 64, 64);
+static const SkColor kDefaultColorBookmarkText = SkColorSetRGB(64, 64, 64);
+static const SkColor kDefaultColorNTPText = SkColorSetRGB(0, 0, 0);
+static const SkColor kDefaultColorNTPLink = SkColorSetRGB(0, 0, 204);
+static const SkColor kDefaultColorNTPSection = SkColorSetRGB(225, 236, 254);
// Default tints.
static const skia::HSL kDefaultTintButtons = { -1, -1, -1 };
@@ -104,11 +108,14 @@ BrowserThemeProvider::BrowserThemeProvider()
BrowserThemeProvider::~BrowserThemeProvider() { }
void BrowserThemeProvider::Init(Profile* profile) {
+ DCHECK(CalledOnValidThread());
profile_ = profile;
LoadThemePrefs();
}
SkBitmap* BrowserThemeProvider::GetBitmapNamed(int id) {
+ DCHECK(CalledOnValidThread());
+
// Check to see if we already have the Skia image in the cache.
ImageCache::const_iterator found = image_cache_.find(id);
if (found != image_cache_.end())
@@ -128,15 +135,15 @@ SkBitmap* BrowserThemeProvider::GetBitmapNamed(int id) {
if (!result.get())
result.reset(rb_.GetBitmapNamed(id));
- // If the requested image is part of the toolbar button set, and we have
- // a provided tint for that set, tint it appropriately.
- if (button_images_.count(id) && tints_.count(kTintButtons)) {
- SkBitmap* tinted =
- new SkBitmap(TintBitmap(*result.release(), TINT_BUTTONS));
- result.reset(tinted);
- }
-
if (result.get()) {
+ // If the requested image is part of the toolbar button set, and we have
+ // a provided tint for that set, tint it appropriately.
+ if (button_images_.count(id) && tints_.count(kTintButtons)) {
+ SkBitmap* tinted =
+ new SkBitmap(TintBitmap(*result.release(), TINT_BUTTONS));
+ result.reset(tinted);
+ }
+
// We loaded successfully. Cache the bitmap.
image_cache_[id] = result.get();
return result.release();
@@ -147,6 +154,8 @@ 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
switch (id) {
case COLOR_FRAME:
@@ -172,6 +181,22 @@ SkColor BrowserThemeProvider::GetColor(int id) {
return (colors_.find(kColorBackgroundTabText) != colors_.end()) ?
colors_[kColorBackgroundTabText] :
kDefaultColorBackgroundTabText;
+ case COLOR_BOOKMARK_TEXT:
+ return (colors_.find(kColorBookmarkText) != colors_.end()) ?
+ colors_[kColorBookmarkText] :
+ kDefaultColorBookmarkText;
+ case COLOR_NTP_TEXT:
+ return (colors_.find(kColorNTPText) != colors_.end()) ?
+ colors_[kColorNTPText] :
+ kDefaultColorNTPText;
+ case COLOR_NTP_LINK:
+ return (colors_.find(kColorNTPLink) != colors_.end()) ?
+ colors_[kColorNTPLink] :
+ kDefaultColorNTPLink;
+ case COLOR_NTP_SECTION:
+ return (colors_.find(kColorNTPSection) != colors_.end()) ?
+ colors_[kColorNTPSection] :
+ kDefaultColorNTPSection;
default:
NOTREACHED() << "Unknown color requested";
}
@@ -217,6 +242,7 @@ void BrowserThemeProvider::UseDefaultTheme() {
}
SkBitmap* BrowserThemeProvider::LoadThemeBitmap(int id) {
+ DCHECK(CalledOnValidThread());
// Attempt to find the image in our theme bundle.
std::vector<unsigned char> raw_data, png_data;
if (images_.count(id)) {
@@ -266,6 +292,7 @@ SkBitmap* BrowserThemeProvider::LoadThemeBitmap(int id) {
}
skia::HSL BrowserThemeProvider::GetTint(int id) {
+ DCHECK(CalledOnValidThread());
switch (id) {
case TINT_FRAME:
return (tints_.find(kTintFrame) != tints_.end()) ?
@@ -447,8 +474,8 @@ void BrowserThemeProvider::NotifyThemeChanged() {
// Redraw!
for (BrowserList::const_iterator browser = BrowserList::begin();
- browser != BrowserList::end(); ++browser) {
- (*browser)->window()->UserChangedTheme();
+ browser != BrowserList::end(); ++browser) {
+ (*browser)->window()->UserChangedTheme();
}
}