summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views/tabs
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/views/tabs')
-rw-r--r--chrome/browser/views/tabs/tab_strip.cc46
-rw-r--r--chrome/browser/views/tabs/tab_strip.h8
2 files changed, 37 insertions, 17 deletions
diff --git a/chrome/browser/views/tabs/tab_strip.cc b/chrome/browser/views/tabs/tab_strip.cc
index d9e7952..57bfc1a 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"
@@ -595,6 +596,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 +776,10 @@ views::View* TabStrip::GetViewForPoint(const gfx::Point& point) {
return this;
}
+void TabStrip::ThemeChanged() {
+ LoadNewTabButtonImage();
+}
+
///////////////////////////////////////////////////////////////////////////////
// TabStrip, TabStripModelObserver implementation:
@@ -1075,22 +1087,6 @@ 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_);
if (drop_indicator_width == 0) {
// Direction doesn't matter, both images are the same size.
@@ -1100,6 +1096,24 @@ void TabStrip::Init() {
}
}
+void TabStrip::LoadNewTabButtonImage() {
+ ThemeProvider* tp = GetThemeProvider();
+
+ 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));
+ newtab_button_size_.SetSize(bitmap->width(), bitmap->height());
+}
+
Tab* TabStrip::GetTabAt(int index) const {
DCHECK(index >= 0 && index < GetTabCount());
return tab_data_.at(index).tab;
diff --git a/chrome/browser/views/tabs/tab_strip.h b/chrome/browser/views/tabs/tab_strip.h
index 71f0301..7ad8c4a 100644
--- a/chrome/browser/views/tabs/tab_strip.h
+++ b/chrome/browser/views/tabs/tab_strip.h
@@ -89,6 +89,9 @@ class TabStrip : public views::View,
// Set the background offset used by inactive tabs to match the frame image.
void SetBackgroundOffset(gfx::Point offset);
+ // Create the new tab button.
+ void InitTabStripButtons();
+
// views::View overrides:
virtual void PaintChildren(gfx::Canvas* canvas);
virtual views::View* GetViewByID(int id) const;
@@ -104,6 +107,7 @@ class TabStrip : public views::View,
virtual bool GetAccessibleName(std::wstring* name);
virtual void SetAccessibleName(const std::wstring& name);
virtual views::View* GetViewForPoint(const gfx::Point& point);
+ virtual void ThemeChanged();
protected:
// TabStripModelObserver implementation:
@@ -166,6 +170,9 @@ class TabStrip : public views::View,
TabStrip();
void Init();
+ // Set the images for the new tab button.
+ void LoadNewTabButtonImage();
+
// Retrieves the Tab at the specified index. Take care in using this, you may
// need to use GetTabAtAdjustForAnimation.
Tab* GetTabAt(int index) const;
@@ -303,7 +310,6 @@ class TabStrip : public views::View,
// The "New Tab" button.
views::ImageButton* newtab_button_;
gfx::Size newtab_button_size_;
- gfx::Size actual_newtab_button_size_;
// The current widths of various types of tabs. We save these so that, as
// users close tabs while we're holding them at the same size, we can lay out