summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views/tabs
diff options
context:
space:
mode:
authorglen@chromium.org <glen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-24 03:03:03 +0000
committerglen@chromium.org <glen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-24 03:03:03 +0000
commit80453d922e568f08133f0d8495b73446471d8f82 (patch)
treee6c2d4756331fc323604248afe88bd134131b614 /chrome/browser/views/tabs
parent452416eba4c506da06d38af10354986debe1e756 (diff)
downloadchromium_src-80453d922e568f08133f0d8495b73446471d8f82.zip
chromium_src-80453d922e568f08133f0d8495b73446471d8f82.tar.gz
chromium_src-80453d922e568f08133f0d8495b73446471d8f82.tar.bz2
Recommit of r21474. Original description:
""" Make the tab close button color match the tab text. BUG=17378 TEST=Install themes with different tab text colors and verify that the tab close button changes color appropriately. Review URL: http://codereview.chromium.org/155882 """ Changes since then include removing a NOTREACHED and changing that method so that a caller can detect whether a ThemeProvider is available. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21505 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/tabs')
-rw-r--r--chrome/browser/views/tabs/tab_renderer.cc19
-rw-r--r--chrome/browser/views/tabs/tab_renderer.h4
2 files changed, 20 insertions, 3 deletions
diff --git a/chrome/browser/views/tabs/tab_renderer.cc b/chrome/browser/views/tabs/tab_renderer.cc
index 2b29341..584cb18 100644
--- a/chrome/browser/views/tabs/tab_renderer.cc
+++ b/chrome/browser/views/tabs/tab_renderer.cc
@@ -54,6 +54,7 @@ static const double kHoverOpacity = 0.33;
static gfx::Font* title_font = NULL;
static int title_font_height = 0;
static SkBitmap* close_button_n = NULL;
+static SkBitmap* close_button_m = NULL;
static SkBitmap* close_button_h = NULL;
static SkBitmap* close_button_p = NULL;
static int close_button_height = 0;
@@ -81,6 +82,7 @@ void InitResources() {
title_font_height = title_font->height();
close_button_n = rb.GetBitmapNamed(IDR_TAB_CLOSE);
+ close_button_m = rb.GetBitmapNamed(IDR_TAB_CLOSE_MASK);
close_button_h = rb.GetBitmapNamed(IDR_TAB_CLOSE_H);
close_button_p = rb.GetBitmapNamed(IDR_TAB_CLOSE_P);
close_button_width = close_button_n->width();
@@ -232,6 +234,7 @@ TabRenderer::TabRenderer()
showing_icon_(false),
showing_close_button_(false),
fav_icon_hiding_offset_(0),
+ close_button_color_(NULL),
crash_animation_(NULL),
should_display_crashed_favicon_(false),
theme_provider_(NULL) {
@@ -268,8 +271,6 @@ ThemeProvider* TabRenderer::GetThemeProvider() {
if (theme_provider_)
return theme_provider_;
- // return contents->profile()->GetThemeProvider();
- NOTREACHED() << "Unable to find a theme provider";
return NULL;
}
@@ -481,6 +482,20 @@ void TabRenderer::Layout() {
close_button_->SetBounds(lb.width() + kCloseButtonHorzFuzz,
close_button_top, close_button_width,
close_button_height);
+
+ // If the close button color has changed, generate a new one.
+ if (GetThemeProvider()) {
+ SkColor tab_text_color =
+ GetThemeProvider()->GetColor(BrowserThemeProvider::COLOR_TAB_TEXT);
+ if (!close_button_color_ || tab_text_color != close_button_color_) {
+ close_button_color_ = tab_text_color;
+ ResourceBundle& rb = ResourceBundle::GetSharedInstance();
+ close_button_->SetBackground(close_button_color_,
+ rb.GetBitmapNamed(IDR_TAB_CLOSE),
+ rb.GetBitmapNamed(IDR_TAB_CLOSE_MASK));
+ }
+ }
+
close_button_->SetVisible(true);
} else {
close_button_->SetBounds(0, 0, 0, 0);
diff --git a/chrome/browser/views/tabs/tab_renderer.h b/chrome/browser/views/tabs/tab_renderer.h
index c618ba6..d157ceb 100644
--- a/chrome/browser/views/tabs/tab_renderer.h
+++ b/chrome/browser/views/tabs/tab_renderer.h
@@ -198,6 +198,9 @@ class TabRenderer : public views::View,
// The offset used to animate the favicon location.
int fav_icon_hiding_offset_;
+ // The current color of the close button.
+ SkColor close_button_color_;
+
// The animation object used to swap the favicon with the sad tab icon.
class FavIconCrashAnimation;
FavIconCrashAnimation* crash_animation_;
@@ -213,4 +216,3 @@ class TabRenderer : public views::View,
};
#endif // CHROME_BROWSER_VIEWS_TABS_TAB_RENDERER_H__
-