summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views/tabs/tab_strip.cc
diff options
context:
space:
mode:
authormirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-07 15:58:41 +0000
committermirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-07 15:58:41 +0000
commite8424704f5c8fb969a8c3429347a373347e5982c (patch)
treea9cfa2315f0e2e228336fdcb668824d6b686fb61 /chrome/browser/views/tabs/tab_strip.cc
parentbe715074bbee02e0f82f8f747daee860c1988c5d (diff)
downloadchromium_src-e8424704f5c8fb969a8c3429347a373347e5982c.zip
chromium_src-e8424704f5c8fb969a8c3429347a373347e5982c.tar.gz
chromium_src-e8424704f5c8fb969a8c3429347a373347e5982c.tar.bz2
Theme window control buttons.
BUG= http://crbug.com/14579 TEST= Install a theme with themed window control buttons. Observe that WCB's are themed. Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=19758 Review URL: http://codereview.chromium.org/150041 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20028 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/tabs/tab_strip.cc')
-rw-r--r--chrome/browser/views/tabs/tab_strip.cc53
1 files changed, 36 insertions, 17 deletions
diff --git a/chrome/browser/views/tabs/tab_strip.cc b/chrome/browser/views/tabs/tab_strip.cc
index d9e7952..514e305 100644
--- a/chrome/browser/views/tabs/tab_strip.cc
+++ b/chrome/browser/views/tabs/tab_strip.cc
@@ -16,6 +16,7 @@
#endif
#include "base/gfx/size.h"
#include "base/stl_util-inl.h"
+#include "chrome/browser/browser_theme_provider.h"
#include "chrome/browser/metrics/user_metrics.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/tab_contents/tab_contents.h"
@@ -29,6 +30,7 @@
#include "grit/theme_resources.h"
#include "views/controls/image_view.h"
#include "views/painter.h"
+#include "views/widget/default_theme_provider.h"
#include "views/window/non_client_view.h"
#include "views/window/window.h"
@@ -595,6 +597,13 @@ void TabStrip::SetBackgroundOffset(gfx::Point offset) {
GetTabAt(i)->SetBackgroundOffset(offset);
}
+void TabStrip::InitTabStripButtons() {
+ newtab_button_ = new NewTabButton(this);
+ LoadNewTabButtonImage();
+ newtab_button_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_NEWTAB));
+ AddChildView(newtab_button_);
+}
+
///////////////////////////////////////////////////////////////////////////////
// TabStrip, views::View overrides:
@@ -768,6 +777,10 @@ views::View* TabStrip::GetViewForPoint(const gfx::Point& point) {
return this;
}
+void TabStrip::ThemeChanged() {
+ LoadNewTabButtonImage();
+}
+
///////////////////////////////////////////////////////////////////////////////
// TabStrip, TabStripModelObserver implementation:
@@ -1075,23 +1088,7 @@ void TabStrip::DidProcessEvent(GdkEvent* event) {
void TabStrip::Init() {
model_->AddObserver(this);
- newtab_button_ = new NewTabButton(this);
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- SkBitmap* bitmap;
-
- bitmap = rb.GetBitmapNamed(IDR_NEWTAB_BUTTON);
- newtab_button_->SetImage(views::CustomButton::BS_NORMAL, bitmap);
- newtab_button_->SetImage(views::CustomButton::BS_PUSHED,
- rb.GetBitmapNamed(IDR_NEWTAB_BUTTON_P));
- newtab_button_->SetImage(views::CustomButton::BS_HOT,
- rb.GetBitmapNamed(IDR_NEWTAB_BUTTON_H));
-
- newtab_button_size_.SetSize(bitmap->width(), bitmap->height());
- actual_newtab_button_size_ = newtab_button_size_;
-
- newtab_button_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_NEWTAB));
- AddChildView(newtab_button_);
-
+ newtab_button_size_.SetSize(kNewTabButtonWidth, kNewTabButtonHeight);
if (drop_indicator_width == 0) {
// Direction doesn't matter, both images are the same size.
SkBitmap* drop_image = GetDropArrowImage(true);
@@ -1100,6 +1097,28 @@ void TabStrip::Init() {
}
}
+void TabStrip::LoadNewTabButtonImage() {
+ ThemeProvider* tp = GetThemeProvider();
+
+ // If we don't have a theme provider yet, it means we do not have a
+ // root view, and are therefore in a test.
+ if (tp == NULL)
+ tp = new views::DefaultThemeProvider();
+
+ SkBitmap* bitmap = tp->GetBitmapNamed(IDR_NEWTAB_BUTTON);
+ SkColor color = tp->GetColor(BrowserThemeProvider::COLOR_BUTTON_BACKGROUND);
+ SkBitmap* background = tp->GetBitmapNamed(
+ IDR_THEME_WINDOW_CONTROL_BACKGROUND);
+
+ newtab_button_->SetImage(views::CustomButton::BS_NORMAL, bitmap);
+ newtab_button_->SetImage(views::CustomButton::BS_PUSHED,
+ tp->GetBitmapNamed(IDR_NEWTAB_BUTTON_P));
+ newtab_button_->SetImage(views::CustomButton::BS_HOT,
+ tp->GetBitmapNamed(IDR_NEWTAB_BUTTON_H));
+ newtab_button_->SetBackground(color, background,
+ tp->GetBitmapNamed(IDR_NEWTAB_BUTTON_MASK));
+}
+
Tab* TabStrip::GetTabAt(int index) const {
DCHECK(index >= 0 && index < GetTabCount());
return tab_data_.at(index).tab;