summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/views')
-rw-r--r--chrome/browser/views/bookmark_bar_view.cc48
-rw-r--r--chrome/browser/views/constrained_window_impl.cc92
-rw-r--r--chrome/browser/views/frame/browser_frame.cc15
-rw-r--r--chrome/browser/views/frame/browser_frame.h9
-rw-r--r--chrome/browser/views/frame/browser_view.cc7
-rw-r--r--chrome/browser/views/frame/browser_view.h1
-rw-r--r--chrome/browser/views/frame/glass_browser_frame_view.cc101
-rw-r--r--chrome/browser/views/frame/glass_browser_frame_view.h2
-rw-r--r--chrome/browser/views/frame/opaque_browser_frame_view.cc412
-rw-r--r--chrome/browser/views/frame/opaque_browser_frame_view.h15
-rw-r--r--chrome/browser/views/infobars/infobars.cc3
-rw-r--r--chrome/browser/views/location_bar_view.cc2
-rw-r--r--chrome/browser/views/options/content_page_view.cc75
-rw-r--r--chrome/browser/views/options/content_page_view.h17
-rw-r--r--chrome/browser/views/options/cookies_view.cc1
-rw-r--r--chrome/browser/views/tabs/tab_renderer.cc196
-rw-r--r--chrome/browser/views/tabs/tab_renderer.h20
-rw-r--r--chrome/browser/views/toolbar_view.cc199
-rw-r--r--chrome/browser/views/toolbar_view.h4
19 files changed, 578 insertions, 641 deletions
diff --git a/chrome/browser/views/bookmark_bar_view.cc b/chrome/browser/views/bookmark_bar_view.cc
index 51beca0a..88264f2 100644
--- a/chrome/browser/views/bookmark_bar_view.cc
+++ b/chrome/browser/views/bookmark_bar_view.cc
@@ -87,7 +87,6 @@ static const SkColor kBackgroundColor = SkColorSetRGB(237, 244, 252);
// Border colors for the BookmarBarView.
static const SkColor kTopBorderColor = SkColorSetRGB(222, 234, 248);
-static const SkColor kBottomBorderColor = SkColorSetRGB(178, 178, 178);
// Background color for when the bookmarks bar is only being displayed on the
// new tab page - this color should match the background color of the new tab
@@ -222,30 +221,6 @@ class BookmarkButton : public views::TextButton {
return event_utils::IsPossibleDispositionEvent(e);
}
- virtual void Paint(ChromeCanvas *canvas) {
- views::TextButton::Paint(canvas);
-
- PaintAnimation(this, canvas, show_animation_->GetCurrentValue());
- }
-
- static void PaintAnimation(views::View* view,
- ChromeCanvas* canvas,
- double animation_value) {
- // Since we can't change the alpha of the button (it contains un-alphable
- // text), we paint the bar background over the front of the button. As the
- // bar background is a gradient, we have to paint the gradient at the
- // size of the parent (hence all the margin math below). We can't use
- // the parent's actual bounds because they differ from what is painted.
- SkPaint paint;
- paint.setAlpha(static_cast<int>((1.0 - animation_value) * 255));
- paint.setShader(skia::CreateGradientShader(0,
- view->height() + kTopMargin + kBottomMargin,
- kTopBorderColor,
- kBackgroundColor))->safeUnref();
- canvas->FillRectInt(0, -kTopMargin, view->width(),
- view->height() + kTopMargin + kBottomMargin, paint);
- }
-
private:
const GURL& url_;
Profile* profile_;
@@ -283,9 +258,6 @@ class BookmarkFolderButton : public views::MenuButton {
virtual void Paint(ChromeCanvas *canvas) {
views::MenuButton::Paint(canvas, false);
-
- BookmarkButton::PaintAnimation(this, canvas,
- show_animation_->GetCurrentValue());
}
private:
@@ -588,7 +560,8 @@ void BookmarkBarView::Paint(ChromeCanvas* canvas) {
canvas->FillRectInt(kNewtabBackgroundColor, 0, 0, width(), height());
// Draw the 'bottom' of the toolbar above our bubble.
- canvas->FillRectInt(kBottomBorderColor, 0, 0, width(), 1);
+ canvas->FillRectInt(ResourceBundle::toolbar_separator_color,
+ 0, 0, width(), 1);
SkRect rect;
@@ -632,15 +605,14 @@ void BookmarkBarView::Paint(ChromeCanvas* canvas) {
SkDoubleToScalar(roundness),
SkDoubleToScalar(roundness), border_paint);
} else {
- SkPaint paint;
- paint.setShader(skia::CreateGradientShader(0,
- height(),
- kTopBorderColor,
- kBackgroundColor))->safeUnref();
- canvas->FillRectInt(0, 0, width(), height(), paint);
-
- canvas->FillRectInt(kTopBorderColor, 0, 0, width(), 1);
- canvas->FillRectInt(kBottomBorderColor, 0, height() - 1, width(), 1);
+ gfx::Rect bounds = GetBounds(views::View::APPLY_MIRRORING_TRANSFORMATION);
+
+ // +1 is for toolbar outdent.
+ canvas->TileImageInt(*GetThemeProvider()->
+ GetBitmapNamed(IDR_THEME_TOOLBAR),
+ bounds.x() + 1, bounds.y(), 0, 0, width(), height());
+ canvas->FillRectInt(ResourceBundle::toolbar_separator_color,
+ 0, height() - 1, width(), 1);
}
}
diff --git a/chrome/browser/views/constrained_window_impl.cc b/chrome/browser/views/constrained_window_impl.cc
index cde0327..9b4ee70 100644
--- a/chrome/browser/views/constrained_window_impl.cc
+++ b/chrome/browser/views/constrained_window_impl.cc
@@ -61,16 +61,23 @@ enum {
FRAME_TOP_LEFT_CORNER,
FRAME_TOP_RIGHT_CORNER,
+ FRAME_WINDOW,
+ FRAME_WINDOW_INACTIVE,
+ FRAME_WINDOW_INCOGNITO,
+ FRAME_WINDOW_INCOGNITO_INACTIVE,
+
FRAME_PART_BITMAP_COUNT // Must be last.
};
static const int kXPFramePartIDs[] = {
0,
IDR_CLOSE_SA, IDR_CLOSE_SA_H, IDR_CLOSE_SA_P,
- IDR_CONSTRAINED_BOTTOM_CENTER, IDR_CONSTRAINED_BOTTOM_LEFT_CORNER,
- IDR_CONSTRAINED_BOTTOM_RIGHT_CORNER, IDR_CONSTRAINED_LEFT_SIDE,
- IDR_CONSTRAINED_RIGHT_SIDE, IDR_CONSTRAINED_TOP_CENTER,
- IDR_CONSTRAINED_TOP_LEFT_CORNER, IDR_CONSTRAINED_TOP_RIGHT_CORNER,
+ IDR_WINDOW_BOTTOM_CENTER, IDR_WINDOW_BOTTOM_LEFT_CORNER,
+ IDR_WINDOW_BOTTOM_RIGHT_CORNER, IDR_WINDOW_LEFT_SIDE,
+ IDR_WINDOW_RIGHT_SIDE, IDR_WINDOW_TOP_CENTER,
+ IDR_WINDOW_TOP_LEFT_CORNER, IDR_WINDOW_TOP_RIGHT_CORNER,
+ IDR_THEME_FRAME, IDR_THEME_FRAME_INACTIVE, IDR_THEME_FRAME_INCOGNITO,
+ IDR_THEME_FRAME_INCOGNITO_INACTIVE,
0 };
static const int kVistaFramePartIDs[] = {
0,
@@ -79,14 +86,8 @@ static const int kVistaFramePartIDs[] = {
IDR_CONSTRAINED_BOTTOM_RIGHT_CORNER_V, IDR_CONSTRAINED_LEFT_SIDE_V,
IDR_CONSTRAINED_RIGHT_SIDE_V, IDR_CONSTRAINED_TOP_CENTER_V,
IDR_CONSTRAINED_TOP_LEFT_CORNER_V, IDR_CONSTRAINED_TOP_RIGHT_CORNER_V,
- 0 };
-static const int kOTRFramePartIDs[] = {
- 0,
- IDR_CLOSE_SA, IDR_CLOSE_SA_H, IDR_CLOSE_SA_P,
- IDR_WINDOW_BOTTOM_CENTER_OTR, IDR_WINDOW_BOTTOM_LEFT_CORNER_OTR,
- IDR_WINDOW_BOTTOM_RIGHT_CORNER_OTR, IDR_WINDOW_LEFT_SIDE_OTR,
- IDR_WINDOW_RIGHT_SIDE_OTR, IDR_WINDOW_TOP_CENTER_OTR,
- IDR_WINDOW_TOP_LEFT_CORNER_OTR, IDR_WINDOW_TOP_RIGHT_CORNER_OTR,
+ IDR_THEME_FRAME, IDR_THEME_FRAME_INACTIVE, IDR_THEME_FRAME_INCOGNITO,
+ IDR_THEME_FRAME_INCOGNITO_INACTIVE,
0 };
class XPWindowResources : public views::WindowResources {
@@ -149,39 +150,8 @@ class VistaWindowResources : public views::WindowResources {
DISALLOW_EVIL_CONSTRUCTORS(VistaWindowResources);
};
-class OTRWindowResources : public views::WindowResources {
- public:
- OTRWindowResources() {
- InitClass();
- }
- virtual ~OTRWindowResources() {}
-
- virtual SkBitmap* GetPartBitmap(views::FramePartBitmap part_id) const {
- return bitmaps_[part_id];
- }
-
- private:
- static void InitClass() {
- static bool initialized = false;
- if (!initialized) {
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- for (int i = 0; i < FRAME_PART_BITMAP_COUNT; ++i) {
- int id = kOTRFramePartIDs[i];
- if (id != 0)
- bitmaps_[i] = rb.GetBitmapNamed(id);
- }
- initialized = true;
- }
- }
-
- static SkBitmap* bitmaps_[FRAME_PART_BITMAP_COUNT];
-
- DISALLOW_EVIL_CONSTRUCTORS(OTRWindowResources);
-};
-
SkBitmap* XPWindowResources::bitmaps_[];
SkBitmap* VistaWindowResources::bitmaps_[];
-SkBitmap* OTRWindowResources::bitmaps_[];
////////////////////////////////////////////////////////////////////////////////
// ConstrainedWindowFrameView
@@ -299,7 +269,6 @@ const int kTitleCaptionSpacing = 5;
const int kCaptionTopSpacing = 1;
const SkColor kContentsBorderShadow = SkColorSetARGB(51, 0, 0, 0);
-const SkColor kContentsBorderColor = SkColorSetRGB(219, 235, 255);
}
////////////////////////////////////////////////////////////////////////////////
@@ -479,6 +448,29 @@ void ConstrainedWindowFrameView::PaintFrameBorder(ChromeCanvas* canvas) {
resources_->GetPartBitmap(FRAME_BOTTOM_RIGHT_CORNER);
SkBitmap* bottom_edge = resources_->GetPartBitmap(FRAME_BOTTOM_EDGE);
+ ResourceBundle& rb = ResourceBundle::GetSharedInstance();
+ SkBitmap* theme_frame = rb.GetBitmapNamed(IDR_THEME_FRAME);
+ SkColor frame_color = ResourceBundle::frame_color;
+
+ // Fill with the frame color first so we have a constant background for
+ // areas not covered by the theme image.
+ canvas->FillRectInt(frame_color, 0, 0, width(), theme_frame->height());
+ // Now fill down the sides
+ canvas->FillRectInt(frame_color,
+ 0, theme_frame->height(),
+ left_edge->width(), height() - theme_frame->height());
+ canvas->FillRectInt(frame_color,
+ width() - right_edge->width(), theme_frame->height(),
+ right_edge->width(), height() - theme_frame->height());
+ // Now fill the bottom area.
+ canvas->FillRectInt(frame_color,
+ left_edge->width(), height() - bottom_edge->height(),
+ width() - left_edge->width() - right_edge->width(),
+ bottom_edge->height());
+
+ // Draw the theme frame.
+ canvas->TileImageInt(*theme_frame, 0, 0, width(), theme_frame->height());
+
// Top.
canvas->DrawBitmapInt(*top_left_corner, 0, 0);
canvas->TileImageInt(*top_edge, top_left_corner->width(), 0,
@@ -526,7 +518,7 @@ void ConstrainedWindowFrameView::PaintClientEdge(ChromeCanvas* canvas) {
frame_shadow_bounds.y(), frame_shadow_bounds.width(),
frame_shadow_bounds.height());
- canvas->FillRectInt(kContentsBorderColor, client_edge_bounds.x(),
+ canvas->FillRectInt(ResourceBundle::toolbar_color, client_edge_bounds.x(),
client_edge_bounds.y(), client_edge_bounds.width(),
client_edge_bounds.height());
}
@@ -565,14 +557,10 @@ gfx::Rect ConstrainedWindowFrameView::CalculateClientAreaBounds(
}
void ConstrainedWindowFrameView::InitWindowResources() {
- if (container_->owner()->profile()->IsOffTheRecord()) {
- resources_.reset(new OTRWindowResources);
+ if (win_util::ShouldUseVistaFrame()) {
+ resources_.reset(new VistaWindowResources);
} else {
- if (win_util::ShouldUseVistaFrame()) {
- resources_.reset(new VistaWindowResources);
- } else {
- resources_.reset(new XPWindowResources);
- }
+ resources_.reset(new XPWindowResources);
}
}
diff --git a/chrome/browser/views/frame/browser_frame.cc b/chrome/browser/views/frame/browser_frame.cc
index c022b6a..0d39521 100644
--- a/chrome/browser/views/frame/browser_frame.cc
+++ b/chrome/browser/views/frame/browser_frame.cc
@@ -9,6 +9,7 @@
#include "app/resource_bundle.h"
#include "app/win_util.h"
+#include "chrome/browser/profile.h"
#include "chrome/browser/browser_list.h"
#include "chrome/browser/views/frame/browser_root_view.h"
#include "chrome/browser/views/frame/browser_view.h"
@@ -23,10 +24,11 @@ static const int kClientEdgeThickness = 3;
///////////////////////////////////////////////////////////////////////////////
// BrowserFrame, public:
-BrowserFrame::BrowserFrame(BrowserView* browser_view)
+BrowserFrame::BrowserFrame(BrowserView* browser_view, Profile* profile)
: WindowWin(browser_view),
browser_view_(browser_view),
- frame_initialized_(false) {
+ frame_initialized_(false),
+ profile_(profile) {
browser_view_->set_frame(this);
GetNonClientView()->SetFrameView(CreateFrameViewForWindow());
// Don't focus anything on creation, selecting a tab will set the focus.
@@ -60,6 +62,14 @@ void BrowserFrame::UpdateThrobber(bool running) {
browser_frame_view_->UpdateThrobber(running);
}
+ThemeProvider* BrowserFrame::GetThemeProvider() const {
+ return profile_->GetThemeProvider();
+}
+
+ThemeProvider* BrowserFrame::GetDialogThemeProvider() const {
+ return profile_->GetThemeProvider();
+}
+
#if defined(FRAME_WINDOW)
void BrowserFrame::SetBrowserNonClientFrameView(
BrowserNonClientFrameView* view) {
@@ -221,7 +231,6 @@ void BrowserFrame::UpdateFrameAfterFrameChange() {
UpdateDWMFrame();
}
-
views::RootView* BrowserFrame::CreateRootView() {
return new BrowserRootView(this);
}
diff --git a/chrome/browser/views/frame/browser_frame.h b/chrome/browser/views/frame/browser_frame.h
index 140f25e..792e90e 100644
--- a/chrome/browser/views/frame/browser_frame.h
+++ b/chrome/browser/views/frame/browser_frame.h
@@ -10,6 +10,7 @@
class AeroGlassNonClientView;
class BrowserView;
class NonClientFrameView;
+class Profile;
class TabStrip;
// A specialization of the NonClientFrameView object that provides additional
@@ -34,7 +35,7 @@ class BrowserNonClientFrameView : public views::NonClientFrameView {
//
class BrowserFrame : public views::WindowWin {
public:
- explicit BrowserFrame(BrowserView* browser_view);
+ explicit BrowserFrame(BrowserView* browser_view, Profile* profile);
virtual ~BrowserFrame();
// Initialize the frame. Creates the Window.
@@ -51,6 +52,10 @@ class BrowserFrame : public views::WindowWin {
// Tells the frame to update the throbber.
void UpdateThrobber(bool running);
+ // Overridden from views::Widget.
+ virtual ThemeProvider* GetThemeProvider() const;
+ virtual ThemeProvider* GetDialogThemeProvider() const;
+
BrowserView* browser_view() const { return browser_view_; }
#if defined(FRAME_WINDOW)
@@ -92,6 +97,8 @@ class BrowserFrame : public views::WindowWin {
bool frame_initialized_;
+ Profile* profile_;
+
DISALLOW_EVIL_CONSTRUCTORS(BrowserFrame);
};
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc
index a3acb80..f2f24b5 100644
--- a/chrome/browser/views/frame/browser_view.cc
+++ b/chrome/browser/views/frame/browser_view.cc
@@ -855,6 +855,11 @@ void BrowserView::ShowHTMLDialog(HtmlDialogUIDelegate* delegate,
html_view->window()->Show();
}
+void BrowserView::UserChangedTheme() {
+ frame_->GetRootView()->ThemeChanged();
+ frame_->GetRootView()->SchedulePaint();
+}
+
///////////////////////////////////////////////////////////////////////////////
// BrowserView, BrowserWindowTesting implementation:
@@ -1662,7 +1667,7 @@ void BrowserView::InitClass() {
// static
BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) {
BrowserView* browser_view = new BrowserView(browser);
- (new BrowserFrame(browser_view))->Init();
+ (new BrowserFrame(browser_view, browser->profile()))->Init();
return browser_view;
}
diff --git a/chrome/browser/views/frame/browser_view.h b/chrome/browser/views/frame/browser_view.h
index 7357333..40afbc5 100644
--- a/chrome/browser/views/frame/browser_view.h
+++ b/chrome/browser/views/frame/browser_view.h
@@ -201,6 +201,7 @@ class BrowserView : public BrowserWindow,
virtual void ConfirmBrowserCloseWithPendingDownloads();
virtual void ShowHTMLDialog(HtmlDialogUIDelegate* delegate,
void* parent_window);
+ virtual void UserChangedTheme();
// Overridden from BrowserWindowTesting:
virtual BookmarkBarView* GetBookmarkBarView() const;
diff --git a/chrome/browser/views/frame/glass_browser_frame_view.cc b/chrome/browser/views/frame/glass_browser_frame_view.cc
index bbebd3a..6eaf547 100644
--- a/chrome/browser/views/frame/glass_browser_frame_view.cc
+++ b/chrome/browser/views/frame/glass_browser_frame_view.cc
@@ -6,66 +6,15 @@
#include "app/gfx/chrome_canvas.h"
#include "app/resource_bundle.h"
+#include "app/theme_provider.h"
+#include "chrome/browser/browser_theme_provider.h"
#include "chrome/browser/views/frame/browser_view.h"
#include "chrome/browser/views/tabs/tab_strip.h"
#include "grit/theme_resources.h"
#include "views/window/client_view.h"
#include "views/window/window_resources.h"
-// An enumeration of bitmap resources used by this window.
-enum {
- // Client Edge Border.
- FRAME_CLIENT_EDGE_TOP_LEFT,
- FRAME_CLIENT_EDGE_TOP,
- FRAME_CLIENT_EDGE_TOP_RIGHT,
- FRAME_CLIENT_EDGE_RIGHT,
- FRAME_CLIENT_EDGE_BOTTOM_RIGHT,
- FRAME_CLIENT_EDGE_BOTTOM,
- FRAME_CLIENT_EDGE_BOTTOM_LEFT,
- FRAME_CLIENT_EDGE_LEFT,
-
- FRAME_PART_BITMAP_COUNT // Must be last.
-};
-
-class GlassBrowserWindowResources {
- public:
- GlassBrowserWindowResources() {
- InitClass();
- }
- virtual ~GlassBrowserWindowResources() { }
-
- virtual SkBitmap* GetPartBitmap(views::FramePartBitmap part) const {
- return standard_frame_bitmaps_[part];
- }
-
- private:
- static void InitClass() {
- static bool initialized = false;
- if (!initialized) {
- static const int kFramePartBitmapIds[] = {
- IDR_CONTENT_TOP_LEFT_CORNER, IDR_CONTENT_TOP_CENTER,
- IDR_CONTENT_TOP_RIGHT_CORNER, IDR_CONTENT_RIGHT_SIDE,
- IDR_CONTENT_BOTTOM_RIGHT_CORNER, IDR_CONTENT_BOTTOM_CENTER,
- IDR_CONTENT_BOTTOM_LEFT_CORNER, IDR_CONTENT_LEFT_SIDE,
- };
-
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- for (int i = 0; i < FRAME_PART_BITMAP_COUNT; ++i)
- standard_frame_bitmaps_[i] = rb.GetBitmapNamed(kFramePartBitmapIds[i]);
-
- initialized = true;
- }
- }
-
- static SkBitmap* standard_frame_bitmaps_[FRAME_PART_BITMAP_COUNT];
-
- DISALLOW_EVIL_CONSTRUCTORS(GlassBrowserWindowResources);
-};
-
// static
-SkBitmap* GlassBrowserWindowResources::standard_frame_bitmaps_[];
-
-GlassBrowserWindowResources* GlassBrowserFrameView::resources_ = NULL;
SkBitmap* GlassBrowserFrameView::distributor_logo_ = NULL;
HICON GlassBrowserFrameView::throbber_icons_[
GlassBrowserFrameView::kThrobberIconCount];
@@ -281,23 +230,34 @@ void GlassBrowserFrameView::PaintDistributorLogo(ChromeCanvas* canvas) {
}
void GlassBrowserFrameView::PaintToolbarBackground(ChromeCanvas* canvas) {
+ ThemeProvider* tp = GetThemeProvider();
+
gfx::Rect toolbar_bounds(browser_view_->GetToolbarBounds());
gfx::Point toolbar_origin(toolbar_bounds.origin());
View::ConvertPointToView(frame_->GetClientView(), this, &toolbar_origin);
toolbar_bounds.set_origin(toolbar_origin);
+ SkBitmap* theme_toolbar = tp->GetBitmapNamed(IDR_THEME_TOOLBAR);
+
+ // Draw the toolbar background, setting src_y of the paint to the tab
+ // strip height as the toolbar background begins at the top of the tabs.
+ canvas->TileImageInt(*theme_toolbar,
+ 0, browser_view_->GetTabStripHeight() - 1,
+ toolbar_bounds.x() - 1, toolbar_bounds.y() + 2,
+ toolbar_bounds.width() + 2, theme_toolbar->height());
+
SkBitmap* toolbar_left =
- resources_->GetPartBitmap(FRAME_CLIENT_EDGE_TOP_LEFT);
+ tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER);
canvas->DrawBitmapInt(*toolbar_left,
toolbar_bounds.x() - toolbar_left->width(),
toolbar_bounds.y());
SkBitmap* toolbar_center =
- resources_->GetPartBitmap(FRAME_CLIENT_EDGE_TOP);
+ tp->GetBitmapNamed(IDR_CONTENT_TOP_CENTER);
canvas->TileImageInt(*toolbar_center, toolbar_bounds.x(), toolbar_bounds.y(),
toolbar_bounds.width(), toolbar_center->height());
- canvas->DrawBitmapInt(*resources_->GetPartBitmap(FRAME_CLIENT_EDGE_TOP_RIGHT),
+ canvas->DrawBitmapInt(*tp->GetBitmapNamed(IDR_CONTENT_TOP_RIGHT_CORNER),
toolbar_bounds.right(), toolbar_bounds.y());
}
@@ -314,35 +274,50 @@ void GlassBrowserFrameView::PaintOTRAvatar(ChromeCanvas* canvas) {
}
void GlassBrowserFrameView::PaintRestoredClientEdge(ChromeCanvas* canvas) {
+ ResourceBundle& rb = ResourceBundle::GetSharedInstance();
+
// The client edges start below the toolbar upper corner images regardless
// of how tall the toolbar itself is.
int client_area_top =
frame_->GetClientView()->y() + browser_view_->GetToolbarBounds().y() +
- resources_->GetPartBitmap(FRAME_CLIENT_EDGE_TOP_LEFT)->height();
+ rb.GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER)->height();
gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height());
int client_area_bottom =
std::max(client_area_top, height() - NonClientBorderThickness());
int client_area_height = client_area_bottom - client_area_top;
- SkBitmap* right = resources_->GetPartBitmap(FRAME_CLIENT_EDGE_RIGHT);
+ SkBitmap* right = rb.GetBitmapNamed(IDR_CONTENT_RIGHT_SIDE);
canvas->TileImageInt(*right, client_area_bounds.right(), client_area_top,
right->width(), client_area_height);
+ // Draw the toolbar color so that the one pixel areas down the sides
+ // show the right color even if not covered by the toolbar image.
+ canvas->DrawRectInt(GetThemeProvider()->
+ GetColor(BrowserThemeProvider::COLOR_TOOLBAR),
+ client_area_bounds.x() - 1, client_area_top,
+ client_area_bounds.width() + 1, client_area_bottom - client_area_top);
+
+ // Draw the content/toolbar separator.
+ canvas->DrawLineInt(ResourceBundle::toolbar_separator_color,
+ client_area_bounds.x(), client_area_top,
+ client_area_bounds.x() + client_area_bounds.width(),
+ client_area_top);
+
canvas->DrawBitmapInt(
- *resources_->GetPartBitmap(FRAME_CLIENT_EDGE_BOTTOM_RIGHT),
+ *rb.GetBitmapNamed(IDR_CONTENT_BOTTOM_RIGHT_CORNER),
client_area_bounds.right(), client_area_bottom);
- SkBitmap* bottom = resources_->GetPartBitmap(FRAME_CLIENT_EDGE_BOTTOM);
+ SkBitmap* bottom = rb.GetBitmapNamed(IDR_CONTENT_BOTTOM_CENTER);
canvas->TileImageInt(*bottom, client_area_bounds.x(),
client_area_bottom, client_area_bounds.width(),
bottom->height());
SkBitmap* bottom_left =
- resources_->GetPartBitmap(FRAME_CLIENT_EDGE_BOTTOM_LEFT);
+ rb.GetBitmapNamed(IDR_CONTENT_BOTTOM_LEFT_CORNER);
canvas->DrawBitmapInt(*bottom_left,
client_area_bounds.x() - bottom_left->width(), client_area_bottom);
- SkBitmap* left = resources_->GetPartBitmap(FRAME_CLIENT_EDGE_LEFT);
+ SkBitmap* left = rb.GetBitmapNamed(IDR_CONTENT_LEFT_SIDE);
canvas->TileImageInt(*left, client_area_bounds.x() - left->width(),
client_area_top, left->width(), client_area_height);
}
@@ -437,8 +412,6 @@ void GlassBrowserFrameView::InitThrobberIcons() {
void GlassBrowserFrameView::InitClass() {
static bool initialized = false;
if (!initialized) {
- resources_ = new GlassBrowserWindowResources;
-
#if defined(GOOGLE_CHROME_BUILD)
distributor_logo_ = ResourceBundle::GetSharedInstance().
GetBitmapNamed(IDR_DISTRIBUTOR_LOGO);
diff --git a/chrome/browser/views/frame/glass_browser_frame_view.h b/chrome/browser/views/frame/glass_browser_frame_view.h
index d110fe9..3a00db3 100644
--- a/chrome/browser/views/frame/glass_browser_frame_view.h
+++ b/chrome/browser/views/frame/glass_browser_frame_view.h
@@ -10,7 +10,6 @@
#include "views/window/non_client_view.h"
class BrowserView;
-class GlassBrowserWindowResources;
class SkBitmap;
class GlassBrowserFrameView : public BrowserNonClientFrameView {
@@ -95,7 +94,6 @@ class GlassBrowserFrameView : public BrowserNonClientFrameView {
static void InitClass();
static SkBitmap* distributor_logo_;
- static GlassBrowserWindowResources* resources_;
static const int kThrobberIconCount = 24;
static HICON throbber_icons_[kThrobberIconCount];
diff --git a/chrome/browser/views/frame/opaque_browser_frame_view.cc b/chrome/browser/views/frame/opaque_browser_frame_view.cc
index 10c604c..317e307 100644
--- a/chrome/browser/views/frame/opaque_browser_frame_view.cc
+++ b/chrome/browser/views/frame/opaque_browser_frame_view.cc
@@ -9,7 +9,9 @@
#include "app/gfx/path.h"
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
+#include "app/theme_provider.h"
#include "app/win_util.h"
+#include "chrome/browser/browser_theme_provider.h"
#include "chrome/browser/views/frame/browser_frame.h"
#include "chrome/browser/views/frame/browser_view.h"
#include "chrome/browser/views/tabs/tab_strip.h"
@@ -20,244 +22,7 @@
#include "views/widget/root_view.h"
#include "views/window/window_resources.h"
-// An enumeration of bitmap resources used by this window.
-enum {
- // Window Controls.
- FRAME_CLOSE_BUTTON_ICON,
- FRAME_CLOSE_BUTTON_ICON_H,
- FRAME_CLOSE_BUTTON_ICON_P,
- FRAME_CLOSE_BUTTON_ICON_SA,
- FRAME_CLOSE_BUTTON_ICON_SA_H,
- FRAME_CLOSE_BUTTON_ICON_SA_P,
- FRAME_RESTORE_BUTTON_ICON,
- FRAME_RESTORE_BUTTON_ICON_H,
- FRAME_RESTORE_BUTTON_ICON_P,
- FRAME_MAXIMIZE_BUTTON_ICON,
- FRAME_MAXIMIZE_BUTTON_ICON_H,
- FRAME_MAXIMIZE_BUTTON_ICON_P,
- FRAME_MINIMIZE_BUTTON_ICON,
- FRAME_MINIMIZE_BUTTON_ICON_H,
- FRAME_MINIMIZE_BUTTON_ICON_P,
-
- // Window Frame Border.
- FRAME_BOTTOM_EDGE,
- FRAME_BOTTOM_LEFT_CORNER,
- FRAME_BOTTOM_RIGHT_CORNER,
- FRAME_LEFT_EDGE,
- FRAME_RIGHT_EDGE,
- FRAME_TOP_EDGE,
- FRAME_TOP_LEFT_CORNER,
- FRAME_TOP_RIGHT_CORNER,
-
- // Client Edge Border.
- FRAME_CLIENT_EDGE_TOP_LEFT,
- FRAME_CLIENT_EDGE_TOP,
- FRAME_CLIENT_EDGE_TOP_RIGHT,
- FRAME_CLIENT_EDGE_RIGHT,
- FRAME_CLIENT_EDGE_BOTTOM_RIGHT,
- FRAME_CLIENT_EDGE_BOTTOM,
- FRAME_CLIENT_EDGE_BOTTOM_LEFT,
- FRAME_CLIENT_EDGE_LEFT,
-
- // No-toolbar client edge.
- FRAME_NO_TOOLBAR_TOP_LEFT,
- FRAME_NO_TOOLBAR_TOP_CENTER,
- FRAME_NO_TOOLBAR_TOP_RIGHT,
-
- FRAME_PART_BITMAP_COUNT // Must be last.
-};
-
-class ActiveWindowResources : public views::WindowResources {
- public:
- ActiveWindowResources() {
- InitClass();
- }
- virtual ~ActiveWindowResources() { }
-
- // WindowResources implementation:
- virtual SkBitmap* GetPartBitmap(views::FramePartBitmap part) const {
- return standard_frame_bitmaps_[part];
- }
-
- private:
- static void InitClass() {
- static bool initialized = false;
- if (!initialized) {
- static const int kFramePartBitmapIds[] = {
- IDR_CLOSE, IDR_CLOSE_H, IDR_CLOSE_P,
- IDR_CLOSE_SA, IDR_CLOSE_SA_H, IDR_CLOSE_SA_P,
- IDR_RESTORE, IDR_RESTORE_H, IDR_RESTORE_P,
- IDR_MAXIMIZE, IDR_MAXIMIZE_H, IDR_MAXIMIZE_P,
- IDR_MINIMIZE, IDR_MINIMIZE_H, IDR_MINIMIZE_P,
- IDR_WINDOW_BOTTOM_CENTER, IDR_WINDOW_BOTTOM_LEFT_CORNER,
- IDR_WINDOW_BOTTOM_RIGHT_CORNER, IDR_WINDOW_LEFT_SIDE,
- IDR_WINDOW_RIGHT_SIDE, IDR_WINDOW_TOP_CENTER,
- IDR_WINDOW_TOP_LEFT_CORNER, IDR_WINDOW_TOP_RIGHT_CORNER,
- IDR_CONTENT_TOP_LEFT_CORNER, IDR_CONTENT_TOP_CENTER,
- IDR_CONTENT_TOP_RIGHT_CORNER, IDR_CONTENT_RIGHT_SIDE,
- IDR_CONTENT_BOTTOM_RIGHT_CORNER, IDR_CONTENT_BOTTOM_CENTER,
- IDR_CONTENT_BOTTOM_LEFT_CORNER, IDR_CONTENT_LEFT_SIDE,
- IDR_APP_TOP_LEFT, IDR_APP_TOP_CENTER, IDR_APP_TOP_RIGHT,
- };
-
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- for (int i = 0; i < FRAME_PART_BITMAP_COUNT; ++i)
- standard_frame_bitmaps_[i] = rb.GetBitmapNamed(kFramePartBitmapIds[i]);
- initialized = true;
- }
- }
-
- static SkBitmap* standard_frame_bitmaps_[FRAME_PART_BITMAP_COUNT];
-
- DISALLOW_EVIL_CONSTRUCTORS(ActiveWindowResources);
-};
-
-class InactiveWindowResources : public views::WindowResources {
- public:
- InactiveWindowResources() {
- InitClass();
- }
- virtual ~InactiveWindowResources() { }
-
- // WindowResources implementation:
- virtual SkBitmap* GetPartBitmap(views::FramePartBitmap part) const {
- return standard_frame_bitmaps_[part];
- }
-
- private:
- static void InitClass() {
- static bool initialized = false;
- if (!initialized) {
- static const int kFramePartBitmapIds[] = {
- IDR_CLOSE, IDR_CLOSE_H, IDR_CLOSE_P,
- IDR_CLOSE_SA, IDR_CLOSE_SA_H, IDR_CLOSE_SA_P,
- IDR_RESTORE, IDR_RESTORE_H, IDR_RESTORE_P,
- IDR_MAXIMIZE, IDR_MAXIMIZE_H, IDR_MAXIMIZE_P,
- IDR_MINIMIZE, IDR_MINIMIZE_H, IDR_MINIMIZE_P,
- IDR_DEWINDOW_BOTTOM_CENTER, IDR_DEWINDOW_BOTTOM_LEFT_CORNER,
- IDR_DEWINDOW_BOTTOM_RIGHT_CORNER, IDR_DEWINDOW_LEFT_SIDE,
- IDR_DEWINDOW_RIGHT_SIDE, IDR_DEWINDOW_TOP_CENTER,
- IDR_DEWINDOW_TOP_LEFT_CORNER, IDR_DEWINDOW_TOP_RIGHT_CORNER,
- IDR_CONTENT_TOP_LEFT_CORNER, IDR_CONTENT_TOP_CENTER,
- IDR_CONTENT_TOP_RIGHT_CORNER, IDR_CONTENT_RIGHT_SIDE,
- IDR_CONTENT_BOTTOM_RIGHT_CORNER, IDR_CONTENT_BOTTOM_CENTER,
- IDR_CONTENT_BOTTOM_LEFT_CORNER, IDR_CONTENT_LEFT_SIDE,
- IDR_APP_TOP_LEFT, IDR_APP_TOP_CENTER, IDR_APP_TOP_RIGHT,
- };
-
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- for (int i = 0; i < FRAME_PART_BITMAP_COUNT; ++i)
- standard_frame_bitmaps_[i] = rb.GetBitmapNamed(kFramePartBitmapIds[i]);
- initialized = true;
- }
- }
-
- static SkBitmap* standard_frame_bitmaps_[FRAME_PART_BITMAP_COUNT];
-
- DISALLOW_EVIL_CONSTRUCTORS(InactiveWindowResources);
-};
-
-class OTRActiveWindowResources : public views::WindowResources {
- public:
- OTRActiveWindowResources() {
- InitClass();
- }
- virtual ~OTRActiveWindowResources() { }
-
- // WindowResources implementation:
- virtual SkBitmap* GetPartBitmap(views::FramePartBitmap part) const {
- return standard_frame_bitmaps_[part];
- }
-
- private:
- static void InitClass() {
- static bool initialized = false;
- if (!initialized) {
- static const int kFramePartBitmapIds[] = {
- IDR_CLOSE, IDR_CLOSE_H, IDR_CLOSE_P,
- IDR_CLOSE_SA, IDR_CLOSE_SA_H, IDR_CLOSE_SA_P,
- IDR_RESTORE, IDR_RESTORE_H, IDR_RESTORE_P,
- IDR_MAXIMIZE, IDR_MAXIMIZE_H, IDR_MAXIMIZE_P,
- IDR_MINIMIZE, IDR_MINIMIZE_H, IDR_MINIMIZE_P,
- IDR_WINDOW_BOTTOM_CENTER_OTR, IDR_WINDOW_BOTTOM_LEFT_CORNER_OTR,
- IDR_WINDOW_BOTTOM_RIGHT_CORNER_OTR, IDR_WINDOW_LEFT_SIDE_OTR,
- IDR_WINDOW_RIGHT_SIDE_OTR, IDR_WINDOW_TOP_CENTER_OTR,
- IDR_WINDOW_TOP_LEFT_CORNER_OTR, IDR_WINDOW_TOP_RIGHT_CORNER_OTR,
- IDR_CONTENT_TOP_LEFT_CORNER, IDR_CONTENT_TOP_CENTER,
- IDR_CONTENT_TOP_RIGHT_CORNER, IDR_CONTENT_RIGHT_SIDE,
- IDR_CONTENT_BOTTOM_RIGHT_CORNER, IDR_CONTENT_BOTTOM_CENTER,
- IDR_CONTENT_BOTTOM_LEFT_CORNER, IDR_CONTENT_LEFT_SIDE,
- IDR_APP_TOP_LEFT, IDR_APP_TOP_CENTER, IDR_APP_TOP_RIGHT,
- };
-
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- for (int i = 0; i < FRAME_PART_BITMAP_COUNT; ++i)
- standard_frame_bitmaps_[i] = rb.GetBitmapNamed(kFramePartBitmapIds[i]);
- initialized = true;
- }
- }
-
- static SkBitmap* standard_frame_bitmaps_[FRAME_PART_BITMAP_COUNT];
-
- DISALLOW_EVIL_CONSTRUCTORS(OTRActiveWindowResources);
-};
-
-class OTRInactiveWindowResources : public views::WindowResources {
- public:
- OTRInactiveWindowResources() {
- InitClass();
- }
- virtual ~OTRInactiveWindowResources() { }
-
- // WindowResources implementation:
- virtual SkBitmap* GetPartBitmap(views::FramePartBitmap part) const {
- return standard_frame_bitmaps_[part];
- }
-
- private:
- static void InitClass() {
- static bool initialized = false;
- if (!initialized) {
- static const int kFramePartBitmapIds[] = {
- IDR_CLOSE, IDR_CLOSE_H, IDR_CLOSE_P,
- IDR_CLOSE_SA, IDR_CLOSE_SA_H, IDR_CLOSE_SA_P,
- IDR_RESTORE, IDR_RESTORE_H, IDR_RESTORE_P,
- IDR_MAXIMIZE, IDR_MAXIMIZE_H, IDR_MAXIMIZE_P,
- IDR_MINIMIZE, IDR_MINIMIZE_H, IDR_MINIMIZE_P,
- IDR_DEWINDOW_BOTTOM_CENTER_OTR, IDR_DEWINDOW_BOTTOM_LEFT_CORNER_OTR,
- IDR_DEWINDOW_BOTTOM_RIGHT_CORNER_OTR, IDR_DEWINDOW_LEFT_SIDE_OTR,
- IDR_DEWINDOW_RIGHT_SIDE_OTR, IDR_DEWINDOW_TOP_CENTER_OTR,
- IDR_DEWINDOW_TOP_LEFT_CORNER_OTR,
- IDR_DEWINDOW_TOP_RIGHT_CORNER_OTR,
- IDR_CONTENT_TOP_LEFT_CORNER, IDR_CONTENT_TOP_CENTER,
- IDR_CONTENT_TOP_RIGHT_CORNER, IDR_CONTENT_RIGHT_SIDE,
- IDR_CONTENT_BOTTOM_RIGHT_CORNER, IDR_CONTENT_BOTTOM_CENTER,
- IDR_CONTENT_BOTTOM_LEFT_CORNER, IDR_CONTENT_LEFT_SIDE,
- IDR_APP_TOP_LEFT, IDR_APP_TOP_CENTER, IDR_APP_TOP_RIGHT,
- };
-
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- for (int i = 0; i < FRAME_PART_BITMAP_COUNT; ++i)
- standard_frame_bitmaps_[i] = rb.GetBitmapNamed(kFramePartBitmapIds[i]);
- initialized = true;
- }
- }
-
- static SkBitmap* standard_frame_bitmaps_[FRAME_PART_BITMAP_COUNT];
-
- DISALLOW_EVIL_CONSTRUCTORS(OTRInactiveWindowResources);
-};
-
// static
-SkBitmap* ActiveWindowResources::standard_frame_bitmaps_[];
-SkBitmap* InactiveWindowResources::standard_frame_bitmaps_[];
-SkBitmap* OTRActiveWindowResources::standard_frame_bitmaps_[];
-SkBitmap* OTRInactiveWindowResources::standard_frame_bitmaps_[];
-
-views::WindowResources* OpaqueBrowserFrameView::active_resources_ = NULL;
-views::WindowResources* OpaqueBrowserFrameView::inactive_resources_ = NULL;
-views::WindowResources* OpaqueBrowserFrameView::active_otr_resources_ = NULL;
-views::WindowResources* OpaqueBrowserFrameView::inactive_otr_resources_ = NULL;
SkBitmap* OpaqueBrowserFrameView::distributor_logo_ = NULL;
ChromeFont* OpaqueBrowserFrameView::title_font_ = NULL;
@@ -341,68 +106,57 @@ OpaqueBrowserFrameView::OpaqueBrowserFrameView(BrowserFrame* frame,
frame_(frame),
browser_view_(browser_view) {
InitClass();
- if (browser_view->IsOffTheRecord()) {
- if (!active_otr_resources_) {
- // Lazy load OTR resources only when we first show an OTR frame.
- active_otr_resources_ = new OTRActiveWindowResources;
- inactive_otr_resources_ = new OTRInactiveWindowResources;
- }
- current_active_resources_ = active_otr_resources_;
- current_inactive_resources_= inactive_otr_resources_;
- } else {
- current_active_resources_ = active_resources_;
- current_inactive_resources_ = inactive_resources_;
- }
- views::WindowResources* resources = current_active_resources_;
+ ThemeProvider* tp = frame_->GetThemeProvider();
+
minimize_button_->SetImage(
views::CustomButton::BS_NORMAL,
- resources->GetPartBitmap(FRAME_MINIMIZE_BUTTON_ICON));
+ tp->GetBitmapNamed(IDR_MINIMIZE));
minimize_button_->SetImage(
views::CustomButton::BS_HOT,
- resources->GetPartBitmap(FRAME_MINIMIZE_BUTTON_ICON_H));
+ tp->GetBitmapNamed(IDR_MINIMIZE_H));
minimize_button_->SetImage(
views::CustomButton::BS_PUSHED,
- resources->GetPartBitmap(FRAME_MINIMIZE_BUTTON_ICON_P));
+ tp->GetBitmapNamed(IDR_MINIMIZE_P));
minimize_button_->SetAccessibleName(
l10n_util::GetString(IDS_ACCNAME_MINIMIZE));
AddChildView(minimize_button_);
maximize_button_->SetImage(
views::CustomButton::BS_NORMAL,
- resources->GetPartBitmap(FRAME_MAXIMIZE_BUTTON_ICON));
+ tp->GetBitmapNamed(IDR_MAXIMIZE));
maximize_button_->SetImage(
views::CustomButton::BS_HOT,
- resources->GetPartBitmap(FRAME_MAXIMIZE_BUTTON_ICON_H));
+ tp->GetBitmapNamed(IDR_MAXIMIZE_H));
maximize_button_->SetImage(
views::CustomButton::BS_PUSHED,
- resources->GetPartBitmap(FRAME_MAXIMIZE_BUTTON_ICON_P));
+ tp->GetBitmapNamed(IDR_MAXIMIZE_P));
maximize_button_->SetAccessibleName(
l10n_util::GetString(IDS_ACCNAME_MAXIMIZE));
AddChildView(maximize_button_);
restore_button_->SetImage(
views::CustomButton::BS_NORMAL,
- resources->GetPartBitmap(FRAME_RESTORE_BUTTON_ICON));
+ tp->GetBitmapNamed(IDR_RESTORE));
restore_button_->SetImage(
views::CustomButton::BS_HOT,
- resources->GetPartBitmap(FRAME_RESTORE_BUTTON_ICON_H));
+ tp->GetBitmapNamed(IDR_RESTORE_H));
restore_button_->SetImage(
views::CustomButton::BS_PUSHED,
- resources->GetPartBitmap(FRAME_RESTORE_BUTTON_ICON_P));
+ tp->GetBitmapNamed(IDR_RESTORE_P));
restore_button_->SetAccessibleName(
l10n_util::GetString(IDS_ACCNAME_RESTORE));
AddChildView(restore_button_);
close_button_->SetImage(
views::CustomButton::BS_NORMAL,
- resources->GetPartBitmap(FRAME_CLOSE_BUTTON_ICON));
+ tp->GetBitmapNamed(IDR_CLOSE));
close_button_->SetImage(
views::CustomButton::BS_HOT,
- resources->GetPartBitmap(FRAME_CLOSE_BUTTON_ICON_H));
+ tp->GetBitmapNamed(IDR_CLOSE_H));
close_button_->SetImage(
views::CustomButton::BS_PUSHED,
- resources->GetPartBitmap(FRAME_CLOSE_BUTTON_ICON_P));
+ tp->GetBitmapNamed(IDR_CLOSE_P));
close_button_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_CLOSE));
AddChildView(close_button_);
@@ -753,17 +507,61 @@ int OpaqueBrowserFrameView::IconSize(int* title_top_spacing_ptr,
}
void OpaqueBrowserFrameView::PaintRestoredFrameBorder(ChromeCanvas* canvas) {
- SkBitmap* top_left_corner = resources()->GetPartBitmap(FRAME_TOP_LEFT_CORNER);
+ ThemeProvider* tp = GetThemeProvider();
+
+ SkBitmap* top_left_corner = tp->GetBitmapNamed(IDR_WINDOW_TOP_LEFT_CORNER);
SkBitmap* top_right_corner =
- resources()->GetPartBitmap(FRAME_TOP_RIGHT_CORNER);
- SkBitmap* top_edge = resources()->GetPartBitmap(FRAME_TOP_EDGE);
- SkBitmap* right_edge = resources()->GetPartBitmap(FRAME_RIGHT_EDGE);
- SkBitmap* left_edge = resources()->GetPartBitmap(FRAME_LEFT_EDGE);
+ tp->GetBitmapNamed(IDR_WINDOW_TOP_RIGHT_CORNER);
+ SkBitmap* top_edge = tp->GetBitmapNamed(IDR_WINDOW_TOP_CENTER);
+ SkBitmap* right_edge = tp->GetBitmapNamed(IDR_WINDOW_RIGHT_SIDE);
+ SkBitmap* left_edge = tp->GetBitmapNamed(IDR_WINDOW_LEFT_SIDE);
SkBitmap* bottom_left_corner =
- resources()->GetPartBitmap(FRAME_BOTTOM_LEFT_CORNER);
+ tp->GetBitmapNamed(IDR_WINDOW_BOTTOM_LEFT_CORNER);
SkBitmap* bottom_right_corner =
- resources()->GetPartBitmap(FRAME_BOTTOM_RIGHT_CORNER);
- SkBitmap* bottom_edge = resources()->GetPartBitmap(FRAME_BOTTOM_EDGE);
+ tp->GetBitmapNamed(IDR_WINDOW_BOTTOM_RIGHT_CORNER);
+ SkBitmap* bottom_edge = tp->GetBitmapNamed(IDR_WINDOW_BOTTOM_CENTER);
+
+
+ // Window frame mode and color
+ SkBitmap* theme_frame;
+ SkColor frame_color;
+ if (!browser_view_->IsOffTheRecord()) {
+ if (frame_->IsActive()) {
+ theme_frame = tp->GetBitmapNamed(IDR_THEME_FRAME);
+ frame_color = tp->GetColor(BrowserThemeProvider::COLOR_FRAME);
+ } else {
+ theme_frame = tp->GetBitmapNamed(IDR_THEME_FRAME_INACTIVE);
+ frame_color = tp->GetColor(BrowserThemeProvider::COLOR_FRAME_INACTIVE);
+ }
+ } else {
+ if (frame_->IsActive()) {
+ theme_frame = tp->GetBitmapNamed(IDR_THEME_FRAME_INCOGNITO);
+ frame_color = tp->GetColor(BrowserThemeProvider::COLOR_FRAME_INCOGNITO);
+ } else {
+ theme_frame = tp->GetBitmapNamed(IDR_THEME_FRAME_INCOGNITO_INACTIVE);
+ frame_color = tp->GetColor(
+ BrowserThemeProvider::COLOR_FRAME_INCOGNITO_INACTIVE);
+ }
+ }
+
+ // Fill with the frame color first so we have a constant background for
+ // areas not covered by the theme image.
+ canvas->FillRectInt(frame_color, 0, 0, width(), theme_frame->height());
+ // Now fill down the sides
+ canvas->FillRectInt(frame_color,
+ 0, theme_frame->height(),
+ left_edge->width(), height() - theme_frame->height());
+ canvas->FillRectInt(frame_color,
+ width() - right_edge->width(), theme_frame->height(),
+ right_edge->width(), height() - theme_frame->height());
+ // Now fill the bottom area.
+ canvas->FillRectInt(frame_color,
+ left_edge->width(), height() - bottom_edge->height(),
+ width() - left_edge->width() - right_edge->width(),
+ bottom_edge->height());
+
+ // Draw the theme frame.
+ canvas->TileImageInt(*theme_frame, 0, 0, width(), theme_frame->height());
// Top.
int top_left_height = std::min(top_left_corner->height(),
@@ -804,8 +602,11 @@ void OpaqueBrowserFrameView::PaintRestoredFrameBorder(ChromeCanvas* canvas) {
height() - top_left_height - bottom_left_corner->height());
}
+
void OpaqueBrowserFrameView::PaintMaximizedFrameBorder(ChromeCanvas* canvas) {
- SkBitmap* top_edge = resources()->GetPartBitmap(FRAME_TOP_EDGE);
+ ThemeProvider* tp = GetThemeProvider();
+
+ SkBitmap* top_edge = tp->GetBitmapNamed(IDR_WINDOW_TOP_CENTER);
canvas->TileImageInt(*top_edge, 0, FrameBorderThickness(), width(),
top_edge->height());
@@ -814,7 +615,7 @@ void OpaqueBrowserFrameView::PaintMaximizedFrameBorder(ChromeCanvas* canvas) {
// edge. The graphic we use for this has a built in client edge, so we clip
// it off the bottom.
SkBitmap* top_center =
- resources()->GetPartBitmap(FRAME_NO_TOOLBAR_TOP_CENTER);
+ tp->GetBitmapNamed(IDR_APP_TOP_CENTER);
int edge_height = top_center->height() - kClientEdgeThickness;
canvas->TileImageInt(*top_center, 0,
frame_->GetClientView()->y() - edge_height, width(), edge_height);
@@ -851,19 +652,32 @@ void OpaqueBrowserFrameView::PaintToolbarBackground(ChromeCanvas* canvas) {
if (!browser_view_->IsToolbarVisible())
return;
+ ThemeProvider* tp = GetThemeProvider();
gfx::Rect toolbar_bounds(browser_view_->GetToolbarBounds());
gfx::Point toolbar_origin(toolbar_bounds.origin());
View::ConvertPointToView(frame_->GetClientView(), this, &toolbar_origin);
toolbar_bounds.set_origin(toolbar_origin);
+ int strip_height = browser_view_->GetTabStripHeight();
+ SkBitmap* theme_toolbar = tp->GetBitmapNamed(IDR_THEME_TOOLBAR);
+
+ canvas->TileImageInt(*theme_toolbar,
+ 0, strip_height - 1, // crop src
+ toolbar_bounds.x() - 1, toolbar_bounds.y() + 2,
+ toolbar_bounds.width() + 2, theme_toolbar->height());
+
+ SkBitmap* toolbar_left =
+ tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER);
+ canvas->DrawBitmapInt(*toolbar_left,
+ toolbar_bounds.x() - toolbar_left->width(),
+ toolbar_bounds.y());
+
// Gross hack: We split the toolbar images into two pieces, since sometimes
// (popup mode) the toolbar isn't tall enough to show the whole image. The
// split happens between the top shadow section and the bottom gradient
// section so that we never break the gradient.
int split_point = kFrameShadowThickness * 2;
int bottom_y = toolbar_bounds.y() + split_point;
- SkBitmap* toolbar_left =
- resources()->GetPartBitmap(FRAME_CLIENT_EDGE_TOP_LEFT);
int bottom_edge_height =
std::min(toolbar_left->height(), toolbar_bounds.height()) - split_point;
@@ -876,7 +690,7 @@ void OpaqueBrowserFrameView::PaintToolbarBackground(ChromeCanvas* canvas) {
toolbar_left->width(), bottom_edge_height, false);
SkBitmap* toolbar_center =
- resources()->GetPartBitmap(FRAME_CLIENT_EDGE_TOP);
+ tp->GetBitmapNamed(IDR_CONTENT_TOP_CENTER);
canvas->TileImageInt(*toolbar_center, 0, 0, toolbar_bounds.x(),
toolbar_bounds.y(), toolbar_bounds.width(), split_point);
int bottom_center_height =
@@ -885,8 +699,7 @@ void OpaqueBrowserFrameView::PaintToolbarBackground(ChromeCanvas* canvas) {
toolbar_center->height() - bottom_center_height, toolbar_bounds.x(),
bottom_y, toolbar_bounds.width(), bottom_center_height);
- SkBitmap* toolbar_right =
- resources()->GetPartBitmap(FRAME_CLIENT_EDGE_TOP_RIGHT);
+ SkBitmap* toolbar_right = tp->GetBitmapNamed(IDR_CONTENT_TOP_RIGHT_CORNER);
canvas->DrawBitmapInt(*toolbar_right, 0, 0, toolbar_right->width(),
split_point, toolbar_bounds.right(), toolbar_bounds.y(),
toolbar_right->width(), split_point, false);
@@ -909,6 +722,7 @@ void OpaqueBrowserFrameView::PaintOTRAvatar(ChromeCanvas* canvas) {
}
void OpaqueBrowserFrameView::PaintRestoredClientEdge(ChromeCanvas* canvas) {
+ ThemeProvider* tp = GetThemeProvider();
int client_area_top = frame_->GetClientView()->y();
gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height());
@@ -916,9 +730,9 @@ void OpaqueBrowserFrameView::PaintRestoredClientEdge(ChromeCanvas* canvas) {
// The client edges start below the toolbar or its corner images, whichever
// is shorter.
gfx::Rect toolbar_bounds(browser_view_->GetToolbarBounds());
- client_area_top += toolbar_bounds.y() + std::min(
- resources()->GetPartBitmap(FRAME_CLIENT_EDGE_TOP_LEFT)->height(),
- toolbar_bounds.height());
+ client_area_top += browser_view_->GetToolbarBounds().y() +
+ std::min(tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER)->height(),
+ toolbar_bounds.height());
} else {
// The toolbar isn't going to draw a client edge for us, so draw one
// ourselves.
@@ -926,12 +740,11 @@ void OpaqueBrowserFrameView::PaintRestoredClientEdge(ChromeCanvas* canvas) {
// shorter than the top left and right bitmaps. We need their top edges to
// line up, and we need the left and right edges to start below the corners'
// bottoms.
- SkBitmap* top_left = resources()->GetPartBitmap(FRAME_NO_TOOLBAR_TOP_LEFT);
- SkBitmap* top_center =
- resources()->GetPartBitmap(FRAME_NO_TOOLBAR_TOP_CENTER);
- SkBitmap* top_right =
- resources()->GetPartBitmap(FRAME_NO_TOOLBAR_TOP_RIGHT);
+ SkBitmap* top_left = tp->GetBitmapNamed(IDR_APP_TOP_LEFT);
+ SkBitmap* top_center = tp->GetBitmapNamed(IDR_APP_TOP_CENTER);
+ SkBitmap* top_right = tp->GetBitmapNamed(IDR_APP_TOP_RIGHT);
int top_edge_y = client_area_top - top_center->height();
+
client_area_top = std::min(top_edge_y + top_left->height(),
height() - NonClientBorderThickness());
int height = client_area_top - top_edge_y;
@@ -945,28 +758,42 @@ void OpaqueBrowserFrameView::PaintRestoredClientEdge(ChromeCanvas* canvas) {
top_right->width(), height, false);
}
+
int client_area_bottom =
std::max(client_area_top, height() - NonClientBorderThickness());
int client_area_height = client_area_bottom - client_area_top;
- SkBitmap* right = resources()->GetPartBitmap(FRAME_CLIENT_EDGE_RIGHT);
+
+ // Draw the toolbar color so that the one pixel areas down the sides
+ // show the right color even if not covered by the toolbar image.
+ canvas->DrawRectInt(ResourceBundle::toolbar_color,
+ client_area_bounds.x() - kClientEdgeThickness, client_area_top,
+ client_area_bounds.width() + kClientEdgeThickness,
+ client_area_bottom - client_area_top);
+
+ // Draw the content/toolbar separator.
+ canvas->DrawLineInt(ResourceBundle::toolbar_separator_color,
+ client_area_bounds.x(), client_area_top,
+ client_area_bounds.x() + client_area_bounds.width(),
+ client_area_top);
+
+ SkBitmap* right = tp->GetBitmapNamed(IDR_CONTENT_RIGHT_SIDE);
canvas->TileImageInt(*right, client_area_bounds.right(), client_area_top,
right->width(), client_area_height);
-
canvas->DrawBitmapInt(
- *resources()->GetPartBitmap(FRAME_CLIENT_EDGE_BOTTOM_RIGHT),
+ *tp->GetBitmapNamed(IDR_CONTENT_BOTTOM_RIGHT_CORNER),
client_area_bounds.right(), client_area_bottom);
- SkBitmap* bottom = resources()->GetPartBitmap(FRAME_CLIENT_EDGE_BOTTOM);
+ SkBitmap* bottom = tp->GetBitmapNamed(IDR_CONTENT_BOTTOM_CENTER);
canvas->TileImageInt(*bottom, client_area_bounds.x(),
client_area_bottom, client_area_bounds.width(),
bottom->height());
SkBitmap* bottom_left =
- resources()->GetPartBitmap(FRAME_CLIENT_EDGE_BOTTOM_LEFT);
+ tp->GetBitmapNamed(IDR_CONTENT_BOTTOM_LEFT_CORNER);
canvas->DrawBitmapInt(*bottom_left,
client_area_bounds.x() - bottom_left->width(), client_area_bottom);
- SkBitmap* left = resources()->GetPartBitmap(FRAME_CLIENT_EDGE_LEFT);
+ SkBitmap* left = tp->GetBitmapNamed(IDR_CONTENT_LEFT_SIDE);
canvas->TileImageInt(*left, client_area_bounds.x() - left->width(),
client_area_top, left->width(), client_area_height);
}
@@ -1102,9 +929,6 @@ gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width,
void OpaqueBrowserFrameView::InitClass() {
static bool initialized = false;
if (!initialized) {
- active_resources_ = new ActiveWindowResources;
- inactive_resources_ = new InactiveWindowResources;
-
#if defined(GOOGLE_CHROME_BUILD)
distributor_logo_ = ResourceBundle::GetSharedInstance().
GetBitmapNamed(IDR_DISTRIBUTOR_LOGO_LIGHT);
diff --git a/chrome/browser/views/frame/opaque_browser_frame_view.h b/chrome/browser/views/frame/opaque_browser_frame_view.h
index 1e917e9..08aee7e 100644
--- a/chrome/browser/views/frame/opaque_browser_frame_view.h
+++ b/chrome/browser/views/frame/opaque_browser_frame_view.h
@@ -16,7 +16,6 @@ class TabContents;
class TabStrip;
namespace views {
class ImageButton;
-class WindowResources;
}
class OpaqueBrowserFrameView : public BrowserNonClientFrameView,
@@ -118,12 +117,6 @@ class OpaqueBrowserFrameView : public BrowserNonClientFrameView,
// Returns the bounds of the client area for the specified view size.
gfx::Rect CalculateClientAreaBounds(int width, int height) const;
- // Returns the set of resources to use to paint this view.
- views::WindowResources* resources() const {
- return frame_->IsActive() || paint_as_active() ?
- current_active_resources_ : current_inactive_resources_;
- }
-
// The layout rect of the title, if visible.
gfx::Rect title_bounds_;
@@ -151,20 +144,12 @@ class OpaqueBrowserFrameView : public BrowserNonClientFrameView,
// The bounds of the ClientView.
gfx::Rect client_view_bounds_;
- // The resources currently used to paint this view.
- views::WindowResources* current_active_resources_;
- views::WindowResources* current_inactive_resources_;
-
// The accessible name of this view.
std::wstring accessible_name_;
static void InitClass();
static void InitAppWindowResources();
static SkBitmap* distributor_logo_;
- static views::WindowResources* active_resources_;
- static views::WindowResources* inactive_resources_;
- static views::WindowResources* active_otr_resources_;
- static views::WindowResources* inactive_otr_resources_;
static ChromeFont* title_font_;
DISALLOW_EVIL_CONSTRUCTORS(OpaqueBrowserFrameView);
diff --git a/chrome/browser/views/infobars/infobars.cc b/chrome/browser/views/infobars/infobars.cc
index 4a04040..6749dec 100644
--- a/chrome/browser/views/infobars/infobars.cc
+++ b/chrome/browser/views/infobars/infobars.cc
@@ -34,7 +34,6 @@ static const SkColor kBackgroundColorTop = SkColorSetRGB(255, 242, 183);
static const SkColor kBackgroundColorBottom = SkColorSetRGB(250, 230, 145);
static const int kSeparatorLineHeight = 1;
-static const SkColor kSeparatorColor = SkColorSetRGB(165, 165, 165);
namespace {
// Returns a centered y-position of a control of height specified in |prefsize|
@@ -70,7 +69,7 @@ class InfoBarBackground : public views::Background {
gradient_background_->Paint(canvas, view);
// Now paint the separator line.
- canvas->FillRectInt(kSeparatorColor, 0,
+ canvas->FillRectInt(ResourceBundle::toolbar_separator_color, 0,
view->height() - kSeparatorLineHeight, view->width(),
kSeparatorLineHeight);
}
diff --git a/chrome/browser/views/location_bar_view.cc b/chrome/browser/views/location_bar_view.cc
index c1354f1..8490c58 100644
--- a/chrome/browser/views/location_bar_view.cc
+++ b/chrome/browser/views/location_bar_view.cc
@@ -16,6 +16,7 @@
#include "chrome/browser/browser_list.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/command_updater.h"
+#include "chrome/browser/extensions/extension.h"
#include "chrome/browser/extensions/extension_browser_event_router.h"
#include "chrome/browser/extensions/extension_tabs_module.h"
#include "chrome/browser/extensions/extensions_service.h"
@@ -27,6 +28,7 @@
#include "chrome/browser/views/info_bubble.h"
#include "chrome/browser/views/first_run_bubble.h"
#include "chrome/browser/views/page_info_window.h"
+#include "chrome/common/page_action.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
#include "views/background.h"
diff --git a/chrome/browser/views/options/content_page_view.cc b/chrome/browser/views/options/content_page_view.cc
index 6e3aff2..badd2f6 100644
--- a/chrome/browser/views/options/content_page_view.cc
+++ b/chrome/browser/views/options/content_page_view.cc
@@ -12,6 +12,7 @@
#include "app/gfx/chrome_canvas.h"
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
+#include "base/command_line.h"
#include "base/file_util.h"
#include "base/gfx/native_theme.h"
#include "chrome/browser/browser_process.h"
@@ -19,6 +20,7 @@
#include "chrome/browser/views/options/fonts_languages_window_view.h"
#include "chrome/browser/views/options/options_group_view.h"
#include "chrome/browser/views/options/passwords_exceptions_window_view.h"
+#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/pref_service.h"
#include "grit/generated_resources.h"
@@ -181,6 +183,8 @@ ContentPageView::ContentPageView(Profile* profile)
passwords_neversave_radio_(NULL),
fonts_lang_group_(NULL),
fonts_and_languages_label_(NULL),
+ themes_group_(NULL),
+ themes_reset_button_(NULL),
change_content_fonts_button_(NULL),
OptionsPageView(profile) {
}
@@ -257,6 +261,9 @@ void ContentPageView::ButtonPressed(views::Button* sender) {
GetRootWindow(),
gfx::Rect(),
new FontsLanguagesWindowView(profile()))->Show();
+ } else if (sender == themes_reset_button_) {
+ UserMetricsRecordAction(L"Options_ThemesReset", profile()->GetPrefs());
+ profile()->ClearTheme();
}
}
@@ -299,6 +306,14 @@ void ContentPageView::InitControlLayout() {
layout->AddView(form_autofill_group_);
layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
+ if (CommandLine::ForCurrentProcess()->
+ HasSwitch(switches::kEnableExtensions)) {
+ layout->StartRow(0, single_column_view_set_id);
+ InitThemesGroup();
+ layout->AddView(themes_group_);
+ layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
+ }
+
// Init member prefs so we can update the controls if prefs change.
default_download_location_.Init(prefs::kDownloadDefaultDirectory,
profile()->GetPrefs(), this);
@@ -445,6 +460,39 @@ void ContentPageView::InitPasswordSavingGroup() {
true);
}
+void ContentPageView::InitFontsLangGroup() {
+ fonts_and_languages_label_ = new views::Label(
+ l10n_util::GetString(IDS_OPTIONS_FONTSETTINGS_INFO));
+ fonts_and_languages_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
+ fonts_and_languages_label_->SetMultiLine(true);
+ change_content_fonts_button_ = new views::NativeButton(
+ this,
+ l10n_util::GetString(IDS_OPTIONS_FONTSETTINGS_CONFIGUREFONTS_BUTTON));
+
+ using views::GridLayout;
+ using views::ColumnSet;
+
+ views::View* contents = new views::View;
+ GridLayout* layout = new GridLayout(contents);
+ contents->SetLayoutManager(layout);
+
+ const int single_column_view_set_id = 1;
+ ColumnSet* column_set = layout->AddColumnSet(single_column_view_set_id);
+ column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 1,
+ GridLayout::USE_PREF, 0, 0);
+
+ layout->StartRow(0, single_column_view_set_id);
+ layout->AddView(fonts_and_languages_label_);
+ layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
+ layout->StartRow(0, single_column_view_set_id);
+ layout->AddView(change_content_fonts_button_);
+
+ fonts_lang_group_ = new OptionsGroupView(
+ contents,
+ l10n_util::GetString(IDS_OPTIONS_FONTSANDLANGUAGES_GROUP_NAME),
+ L"", true);
+}
+
void ContentPageView::InitFormAutofillGroup() {
form_autofill_checkbox_ = new views::Checkbox(
l10n_util::GetString(IDS_AUTOFILL_SAVEFORMS));
@@ -468,17 +516,12 @@ void ContentPageView::InitFormAutofillGroup() {
form_autofill_group_ = new OptionsGroupView(
contents, l10n_util::GetString(IDS_AUTOFILL_SETTING_WINDOWS_GROUP_NAME),
- L"", false);
+ L"", true);
}
-void ContentPageView::InitFontsLangGroup() {
- fonts_and_languages_label_ = new views::Label(
- l10n_util::GetString(IDS_OPTIONS_FONTSETTINGS_INFO));
- fonts_and_languages_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
- fonts_and_languages_label_->SetMultiLine(true);
- change_content_fonts_button_ = new views::NativeButton(
- this,
- l10n_util::GetString(IDS_OPTIONS_FONTSETTINGS_CONFIGUREFONTS_BUTTON));
+void ContentPageView::InitThemesGroup() {
+ themes_reset_button_ = new views::NativeButton(this,
+ l10n_util::GetString(IDS_THEMES_RESET_BUTTON));
using views::GridLayout;
using views::ColumnSet;
@@ -490,18 +533,14 @@ void ContentPageView::InitFontsLangGroup() {
const int single_column_view_set_id = 1;
ColumnSet* column_set = layout->AddColumnSet(single_column_view_set_id);
column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 1,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::USE_PREF, 0, 0);
layout->StartRow(0, single_column_view_set_id);
- layout->AddView(fonts_and_languages_label_);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
- layout->StartRow(0, single_column_view_set_id);
- layout->AddView(change_content_fonts_button_);
+ layout->AddView(themes_reset_button_);
- fonts_lang_group_ = new OptionsGroupView(
- contents,
- l10n_util::GetString(IDS_OPTIONS_FONTSANDLANGUAGES_GROUP_NAME),
- L"", true);
+ themes_group_ = new OptionsGroupView(
+ contents, l10n_util::GetString(IDS_THEMES_GROUP_NAME),
+ L"", false);
}
void ContentPageView::UpdateDownloadDirectoryDisplay() {
diff --git a/chrome/browser/views/options/content_page_view.h b/chrome/browser/views/options/content_page_view.h
index 7d96e00..ff133e3 100644
--- a/chrome/browser/views/options/content_page_view.h
+++ b/chrome/browser/views/options/content_page_view.h
@@ -51,8 +51,9 @@ class ContentPageView : public OptionsPageView,
// Init all the dialog controls.
void InitDownloadLocation();
void InitPasswordSavingGroup();
- void InitFormAutofillGroup();
void InitFontsLangGroup();
+ void InitFormAutofillGroup();
+ void InitThemesGroup();
// Updates the directory displayed in the default download location view with
// the current value of the pref.
@@ -71,20 +72,24 @@ class ContentPageView : public OptionsPageView,
views::RadioButton* passwords_asktosave_radio_;
views::RadioButton* passwords_neversave_radio_;
+ // Controls for the Fonts and Languages group.
+ OptionsGroupView* fonts_lang_group_;
+ views::Label* fonts_and_languages_label_;
+ views::NativeButton* change_content_fonts_button_;
+
// Controls for the Form Autofill group
OptionsGroupView* form_autofill_group_;
views::Checkbox* form_autofill_checkbox_;
+ // Controls for the Themes group
+ OptionsGroupView* themes_group_;
+ views::NativeButton* themes_reset_button_;
+
// Controls for the Popup Blocking group.
OptionsGroupView* popups_group_;
views::RadioButton* popups_show_minimized_radio_;
views::RadioButton* popups_block_all_radio_;
- // Controls for the Fonts and Languages group.
- OptionsGroupView* fonts_lang_group_;
- views::Label* fonts_and_languages_label_;
- views::NativeButton* change_content_fonts_button_;
-
StringPrefMember default_download_location_;
BooleanPrefMember ask_for_save_location_;
BooleanPrefMember ask_to_save_passwords_;
diff --git a/chrome/browser/views/options/cookies_view.cc b/chrome/browser/views/options/cookies_view.cc
index 593487b..cc8d65c 100644
--- a/chrome/browser/views/options/cookies_view.cc
+++ b/chrome/browser/views/options/cookies_view.cc
@@ -10,6 +10,7 @@
#include "app/gfx/color_utils.h"
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
+#include "base/message_loop.h"
#include "base/string_util.h"
#include "base/time_format.h"
#include "chrome/browser/profile.h"
diff --git a/chrome/browser/views/tabs/tab_renderer.cc b/chrome/browser/views/tabs/tab_renderer.cc
index 87d0d01..e7b664b 100644
--- a/chrome/browser/views/tabs/tab_renderer.cc
+++ b/chrome/browser/views/tabs/tab_renderer.cc
@@ -12,6 +12,7 @@
#include "app/resource_bundle.h"
#include "app/win_util.h"
#include "chrome/browser/browser.h"
+#include "chrome/browser/browser_theme_provider.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/tabs/tab_strip_model.h"
@@ -43,7 +44,6 @@ static const int kPulseDurationMs = 200;
// How opaque to make the hover state (out of 1).
static const double kHoverOpacity = 0.33;
-static const double kHoverOpacityVista = 0.7;
// TODO(beng): (Cleanup) This stuff should move onto the class.
static ChromeFont* title_font = NULL;
@@ -53,6 +53,7 @@ static SkBitmap* close_button_h = NULL;
static SkBitmap* close_button_p = NULL;
static int close_button_height = 0;
static int close_button_width = 0;
+
static SkBitmap* waiting_animation_frames = NULL;
static SkBitmap* loading_animation_frames = NULL;
static SkBitmap* crashed_fav_icon = NULL;
@@ -63,16 +64,16 @@ static SkBitmap* download_icon = NULL;
static int download_icon_width = 0;
static int download_icon_height = 0;
+TabRenderer::TabImage TabRenderer::tab_alpha = {0};
TabRenderer::TabImage TabRenderer::tab_active = {0};
TabRenderer::TabImage TabRenderer::tab_inactive = {0};
-TabRenderer::TabImage TabRenderer::tab_inactive_otr = {0};
-TabRenderer::TabImage TabRenderer::tab_hover = {0};
namespace {
void InitResources() {
static bool initialized = false;
if (!initialized) {
+ // TODO(glen): Allow theming of these.
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
title_font = new ChromeFont(rb.GetFont(ResourceBundle::BaseFont));
title_font_height = title_font->height();
@@ -83,7 +84,7 @@ void InitResources() {
close_button_width = close_button_n->width();
close_button_height = close_button_n->height();
- TabRenderer::LoadTabImages(win_util::ShouldUseVistaFrame());
+ TabRenderer::LoadTabImages();
// The loading animation image is a strip of states. Each state must be
// square, so the height must divide the width evenly.
@@ -215,7 +216,8 @@ TabRenderer::TabRenderer()
showing_close_button_(false),
crash_animation_(NULL),
fav_icon_hiding_offset_(0),
- should_display_crashed_favicon_(false) {
+ should_display_crashed_favicon_(false),
+ theme_provider_(NULL) {
InitResources();
// Add the Close Button.
@@ -236,6 +238,24 @@ TabRenderer::~TabRenderer() {
delete crash_animation_;
}
+void TabRenderer::ViewHierarchyChanged(bool is_add, View* parent, View* child) {
+ if (parent->GetThemeProvider())
+ SetThemeProvider(parent->GetThemeProvider());
+}
+
+ThemeProvider* TabRenderer::GetThemeProvider() {
+ ThemeProvider* tp = View::GetThemeProvider();
+ if (tp)
+ return tp;
+
+ if (theme_provider_)
+ return theme_provider_;
+
+ // return contents->profile()->GetThemeProvider();
+ NOTREACHED() << "Unable to find a theme provider";
+ return NULL;
+}
+
void TabRenderer::UpdateData(TabContents* contents, bool loading_only) {
DCHECK(contents);
if (!loading_only) {
@@ -246,6 +266,9 @@ void TabRenderer::UpdateData(TabContents* contents, bool loading_only) {
data_.favicon = contents->GetFavIcon();
}
+ // TODO(glen): Temporary hax.
+ theme_provider_ = contents->profile()->GetThemeProvider();
+
// Loading state also involves whether we show the favicon, since that's where
// we display the throbber.
data_.loading = contents->is_loading();
@@ -411,8 +434,11 @@ void TabRenderer::Paint(ChromeCanvas* canvas) {
Browser::FormatTitleForDisplay(&title);
}
- SkColor title_color = IsSelected() ? kSelectedTitleColor
- : kUnselectedTitleColor;
+ SkColor title_color = GetThemeProvider()->
+ GetColor(IsSelected() ?
+ BrowserThemeProvider::COLOR_TAB_TEXT :
+ BrowserThemeProvider::COLOR_BACKGROUND_TAB_TEXT);
+
canvas->DrawStringInt(title, *title_font, title_color, title_bounds_.x(),
title_bounds_.y(), title_bounds_.width(),
title_bounds_.height());
@@ -507,8 +533,7 @@ void TabRenderer::OnMouseExited(const views::MouseEvent& e) {
}
void TabRenderer::ThemeChanged() {
- if (GetWindow())
- LoadTabImages(GetWindow()->GetNonClientView()->UseNativeFrame());
+ LoadTabImages();
View::ThemeChanged();
}
@@ -541,33 +566,111 @@ void TabRenderer::PaintTabBackground(ChromeCanvas* canvas) {
Animation* animation = hover_animation_.get();
if (pulse_animation_->IsAnimating())
animation = pulse_animation_.get();
+
+ PaintInactiveTabBackground(canvas);
if (animation->GetCurrentValue() > 0) {
- PaintHoverTabBackground(canvas, animation->GetCurrentValue() *
- (GetWindow()->GetNonClientView()->UseNativeFrame() ?
- kHoverOpacityVista : kHoverOpacity));
- } else {
- PaintInactiveTabBackground(canvas);
+ SkRect bounds;
+ bounds.set(0, 0, SkIntToScalar(width()), SkIntToScalar(height()));
+ canvas->saveLayerAlpha(&bounds,
+ static_cast<int>(animation->GetCurrentValue() * kHoverOpacity * 0xff),
+ SkCanvas::kARGB_ClipLayer_SaveFlag);
+ canvas->drawARGB(0, 255, 255, 255, SkPorterDuff::kClear_Mode);
+ PaintActiveTabBackground(canvas);
+ canvas->restore();
}
}
}
void TabRenderer::PaintInactiveTabBackground(ChromeCanvas* canvas) {
bool is_otr = data_.off_the_record;
- canvas->DrawBitmapInt(is_otr ? *tab_inactive_otr.image_l :
- *tab_inactive.image_l, 0, 0);
- canvas->TileImageInt(is_otr ? *tab_inactive_otr.image_c :
- *tab_inactive.image_c, tab_inactive.l_width, 0,
- width() - tab_inactive.l_width -
- tab_inactive.r_width, height());
- canvas->DrawBitmapInt(is_otr ? *tab_inactive_otr.image_r :
- *tab_inactive.image_r,
+
+ // The tab image needs to be lined up with the background image
+ // so that it feels partially transparent.
+ int offset = GetX(views::View::APPLY_MIRRORING_TRANSFORMATION) + 1;
+ int offset_y = 20;
+
+ int tab_id;
+ if (GetWidget() &&
+ GetWidget()->GetWindow()->GetNonClientView()->UseNativeFrame()) {
+ tab_id = IDR_THEME_TAB_BACKGROUND_V;
+ } else {
+ tab_id = is_otr ? IDR_THEME_TAB_BACKGROUND_INCOGNITO :
+ IDR_THEME_TAB_BACKGROUND;
+ }
+
+ SkBitmap* tab_bg = GetThemeProvider()->GetBitmapNamed(tab_id);
+
+ // Draw left edge.
+ SkBitmap tab_l = skia::ImageOperations::CreateTiledBitmap(
+ *tab_bg, offset, offset_y,
+ tab_active.l_width, height());
+ SkBitmap theme_l = skia::ImageOperations::CreateMaskedBitmap(
+ tab_l, *tab_alpha.image_l);
+ canvas->DrawBitmapInt(theme_l,
+ 0, 0, theme_l.width(), theme_l.height() - 1,
+ 0, 0, theme_l.width(), theme_l.height() - 1,
+ false);
+
+ // Draw right edge.
+ SkBitmap tab_r = skia::ImageOperations::CreateTiledBitmap(
+ *tab_bg,
+ offset + width() - tab_active.r_width, offset_y,
+ tab_active.r_width, height());
+ SkBitmap theme_r = skia::ImageOperations::CreateMaskedBitmap(
+ tab_r, *tab_alpha.image_r);
+ canvas->DrawBitmapInt(theme_r,
+ 0, 0, theme_r.width(), theme_r.height() - 1,
+ width() - theme_r.width(), 0, theme_r.width(), theme_r.height() - 1,
+ false);
+
+ // Draw center.
+ canvas->TileImageInt(*tab_bg,
+ offset + tab_active.l_width, 2 + offset_y, // 2 is the drop shadow offset.
+ tab_active.l_width, 2,
+ width() - tab_active.l_width - tab_active.r_width, height() - 3);
+
+ canvas->DrawBitmapInt(*tab_inactive.image_l, 0, 0);
+ canvas->TileImageInt(*tab_inactive.image_c,
+ tab_inactive.l_width, 0,
+ width() - tab_inactive.l_width - tab_inactive.r_width,
+ height());
+ canvas->DrawBitmapInt(*tab_inactive.image_r,
width() - tab_inactive.r_width, 0);
}
void TabRenderer::PaintActiveTabBackground(ChromeCanvas* canvas) {
+ int offset = GetX(views::View::APPLY_MIRRORING_TRANSFORMATION) + 1;
+ ThemeProvider* tp = GetThemeProvider();
+ if (!tp)
+ NOTREACHED() << "Unable to get theme provider";
+
+ SkBitmap* tab_bg = GetThemeProvider()->GetBitmapNamed(IDR_THEME_TOOLBAR);
+
+ // Draw left edge.
+ SkBitmap tab_l = skia::ImageOperations::CreateTiledBitmap(
+ *tab_bg, offset, 0, tab_active.l_width, height());
+ SkBitmap theme_l = skia::ImageOperations::CreateMaskedBitmap(
+ tab_l, *tab_alpha.image_l);
+ canvas->DrawBitmapInt(theme_l, 0, 0);
+
+ // Draw right edge.
+ SkBitmap tab_r = skia::ImageOperations::CreateTiledBitmap(
+ *tab_bg,
+ offset + width() - tab_active.r_width, 0,
+ tab_active.r_width, height());
+ SkBitmap theme_r = skia::ImageOperations::CreateMaskedBitmap(
+ tab_r, *tab_alpha.image_r);
+ canvas->DrawBitmapInt(theme_r, width() - tab_active.r_width, 0);
+
+ // Draw center.
+ canvas->TileImageInt(*tab_bg,
+ offset + tab_active.l_width, 2,
+ tab_active.l_width, 2,
+ width() - tab_active.l_width - tab_active.r_width, height() - 2);
+
canvas->DrawBitmapInt(*tab_active.image_l, 0, 0);
canvas->TileImageInt(*tab_active.image_c, tab_active.l_width, 0,
- width() - tab_active.l_width - tab_active.r_width, height());
+ width() - tab_active.l_width - tab_active.r_width, height());
canvas->DrawBitmapInt(*tab_active.image_r, width() - tab_active.r_width, 0);
}
@@ -575,15 +678,11 @@ void TabRenderer::PaintHoverTabBackground(ChromeCanvas* canvas,
double opacity) {
bool is_otr = data_.off_the_record;
SkBitmap left = skia::ImageOperations::CreateBlendedBitmap(
- (is_otr ? *tab_inactive_otr.image_l :
- *tab_inactive.image_l), *tab_hover.image_l, opacity);
+ *tab_inactive.image_l, *tab_active.image_l, opacity);
SkBitmap center = skia::ImageOperations::CreateBlendedBitmap(
- (is_otr ? *tab_inactive_otr.image_c :
- *tab_inactive.image_c), *tab_hover.image_c, opacity);
+ *tab_inactive.image_c, *tab_active.image_c, opacity);
SkBitmap right = skia::ImageOperations::CreateBlendedBitmap(
- (is_otr ? *tab_inactive_otr.image_r :
- *tab_inactive.image_r),
- *tab_hover.image_r, opacity);
+ *tab_inactive.image_r, *tab_active.image_r, opacity);
canvas->DrawBitmapInt(left, 0, 0);
canvas->TileImageInt(center, tab_active.l_width, 0,
@@ -668,41 +767,26 @@ void TabRenderer::ResetCrashedFavIcon() {
}
// static
-void TabRenderer::LoadTabImages(bool use_vista_images) {
+void TabRenderer::LoadTabImages() {
+ // We're not letting people override tab images just yet.
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
+ tab_alpha.image_l = rb.GetBitmapNamed(IDR_TAB_ALPHA_LEFT);
+ tab_alpha.image_r = rb.GetBitmapNamed(IDR_TAB_ALPHA_RIGHT);
+
tab_active.image_l = rb.GetBitmapNamed(IDR_TAB_ACTIVE_LEFT);
tab_active.image_c = rb.GetBitmapNamed(IDR_TAB_ACTIVE_CENTER);
tab_active.image_r = rb.GetBitmapNamed(IDR_TAB_ACTIVE_RIGHT);
tab_active.l_width = tab_active.image_l->width();
tab_active.r_width = tab_active.image_r->width();
- tab_hover.image_l = rb.GetBitmapNamed(IDR_TAB_HOVER_LEFT);
- tab_hover.image_c = rb.GetBitmapNamed(IDR_TAB_HOVER_CENTER);
- tab_hover.image_r = rb.GetBitmapNamed(IDR_TAB_HOVER_RIGHT);
-
- if (use_vista_images) {
- tab_inactive.image_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT_V);
- tab_inactive.image_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER_V);
- tab_inactive.image_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT_V);
-
- // Our Vista frame doesn't change background color to show OTR,
- // so we continue to use the existing background tabs.
- tab_inactive_otr.image_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT_V);
- tab_inactive_otr.image_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER_V);
- tab_inactive_otr.image_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT_V);
- } else {
- tab_inactive.image_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT);
- tab_inactive.image_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER);
- tab_inactive.image_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT);
-
- tab_inactive_otr.image_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT_OTR);
- tab_inactive_otr.image_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER_OTR);
- tab_inactive_otr.image_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT_OTR);
- }
+ tab_inactive.image_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT);
+ tab_inactive.image_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER);
+ tab_inactive.image_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT);
tab_inactive.l_width = tab_inactive.image_l->width();
tab_inactive.r_width = tab_inactive.image_r->width();
- // tab_[hover,inactive_otr] width are not used and are initialized to 0
- // during static initialization.
+
+ loading_animation_frames = rb.GetBitmapNamed(IDR_THROBBER);
+ waiting_animation_frames = rb.GetBitmapNamed(IDR_THROBBER_WAITING);
}
diff --git a/chrome/browser/views/tabs/tab_renderer.h b/chrome/browser/views/tabs/tab_renderer.h
index f498c2a..d278fb5 100644
--- a/chrome/browser/views/tabs/tab_renderer.h
+++ b/chrome/browser/views/tabs/tab_renderer.h
@@ -36,6 +36,10 @@ class TabRenderer : public views::View,
TabRenderer();
virtual ~TabRenderer();
+ // Overridden from views:
+ void ViewHierarchyChanged(bool is_add, View* parent, View* child);
+ ThemeProvider* GetThemeProvider();
+
// Updates the data the Tab uses to render itself from the specified
// TabContents.
//
@@ -56,6 +60,13 @@ class TabRenderer : public views::View,
void StartPulse();
void StopPulse();
+ // Set the theme provider - because we get detached, we are frequently
+ // outside of a hierarchy with a theme provider at the top. This should be
+ // called whenever we're detached or attached to a hierarchy.
+ void SetThemeProvider(ThemeProvider* provider) {
+ theme_provider_ = provider;
+ }
+
// Returns the minimum possible size of a single unselected Tab.
static gfx::Size GetMinimumUnselectedSize();
// Returns the minimum possible size of a selected Tab. Selected tabs must
@@ -66,9 +77,8 @@ class TabRenderer : public views::View,
// available.
static gfx::Size GetStandardSize();
- // Loads the images to be used for the tab background. Uses the images for
- // Vista if |use_vista_images| is true.
- static void LoadTabImages(bool use_vista_images);
+ // Loads the images to be used for the tab background.
+ static void LoadTabImages();
protected:
views::ImageButton* close_button() const { return close_button_; }
@@ -166,7 +176,7 @@ class TabRenderer : public views::View,
};
static TabImage tab_active;
static TabImage tab_inactive;
- static TabImage tab_inactive_otr;
+ static TabImage tab_alpha;
static TabImage tab_hover;
// Whether we're showing the icon. It is cached so that we can detect when it
@@ -189,6 +199,8 @@ class TabRenderer : public views::View,
bool should_display_crashed_favicon_;
+ ThemeProvider* theme_provider_;
+
static void InitClass();
static bool initialized_;
diff --git a/chrome/browser/views/toolbar_view.cc b/chrome/browser/views/toolbar_view.cc
index c3c98d2..333dcf4 100644
--- a/chrome/browser/views/toolbar_view.cc
+++ b/chrome/browser/views/toolbar_view.cc
@@ -23,6 +23,7 @@
#include "chrome/browser/profile.h"
#include "chrome/browser/tab_contents/navigation_controller.h"
#include "chrome/browser/tab_contents/navigation_entry.h"
+#include "chrome/browser/browser_theme_provider.h"
#include "chrome/browser/user_data_manager.h"
#include "chrome/browser/views/bookmark_menu_button.h"
#include "chrome/browser/views/dom_view.h"
@@ -138,86 +139,49 @@ void BrowserToolbarView::SetProfile(Profile* profile) {
}
void BrowserToolbarView::CreateLeftSideControls() {
- ResourceBundle &rb = ResourceBundle::GetSharedInstance();
-
back_ = new views::ButtonDropDown(this, back_menu_model_.get());
back_->set_triggerable_event_flags(views::Event::EF_LEFT_BUTTON_DOWN |
views::Event::EF_MIDDLE_BUTTON_DOWN);
back_->set_tag(IDC_BACK);
back_->SetImageAlignment(views::ImageButton::ALIGN_RIGHT,
views::ImageButton::ALIGN_TOP);
- back_->SetImage(views::CustomButton::BS_NORMAL, rb.GetBitmapNamed(IDR_BACK));
- back_->SetImage(views::CustomButton::BS_HOT, rb.GetBitmapNamed(IDR_BACK_H));
- back_->SetImage(views::CustomButton::BS_PUSHED,
- rb.GetBitmapNamed(IDR_BACK_P));
- back_->SetImage(views::CustomButton::BS_DISABLED,
- rb.GetBitmapNamed(IDR_BACK_D));
back_->SetTooltipText(l10n_util::GetString(IDS_TOOLTIP_BACK));
back_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_BACK));
back_->SetID(VIEW_ID_BACK_BUTTON);
- AddChildView(back_);
forward_ = new views::ButtonDropDown(this, forward_menu_model_.get());
forward_->set_triggerable_event_flags(views::Event::EF_LEFT_BUTTON_DOWN |
- views::Event::EF_MIDDLE_BUTTON_DOWN);
+ views::Event::EF_MIDDLE_BUTTON_DOWN);
forward_->set_tag(IDC_FORWARD);
- forward_->SetImage(views::CustomButton::BS_NORMAL,
- rb.GetBitmapNamed(IDR_FORWARD));
- forward_->SetImage(views::CustomButton::BS_HOT,
- rb.GetBitmapNamed(IDR_FORWARD_H));
- forward_->SetImage(views::CustomButton::BS_PUSHED,
- rb.GetBitmapNamed(IDR_FORWARD_P));
- forward_->SetImage(views::CustomButton::BS_DISABLED,
- rb.GetBitmapNamed(IDR_FORWARD_D));
forward_->SetTooltipText(l10n_util::GetString(IDS_TOOLTIP_FORWARD));
forward_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_FORWARD));
forward_->SetID(VIEW_ID_FORWARD_BUTTON);
- AddChildView(forward_);
reload_ = new views::ImageButton(this);
reload_->set_tag(IDC_RELOAD);
- reload_->SetImage(views::CustomButton::BS_NORMAL,
- rb.GetBitmapNamed(IDR_RELOAD));
- reload_->SetImage(views::CustomButton::BS_HOT,
- rb.GetBitmapNamed(IDR_RELOAD_H));
- reload_->SetImage(views::CustomButton::BS_PUSHED,
- rb.GetBitmapNamed(IDR_RELOAD_P));
reload_->SetTooltipText(l10n_util::GetString(IDS_TOOLTIP_RELOAD));
reload_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_RELOAD));
reload_->SetID(VIEW_ID_RELOAD_BUTTON);
- AddChildView(reload_);
home_ = new views::ImageButton(this);
home_->set_triggerable_event_flags(views::Event::EF_LEFT_BUTTON_DOWN |
views::Event::EF_MIDDLE_BUTTON_DOWN);
home_->set_tag(IDC_HOME);
- home_->SetImage(views::CustomButton::BS_NORMAL, rb.GetBitmapNamed(IDR_HOME));
- home_->SetImage(views::CustomButton::BS_HOT, rb.GetBitmapNamed(IDR_HOME_H));
- home_->SetImage(views::CustomButton::BS_PUSHED,
- rb.GetBitmapNamed(IDR_HOME_P));
home_->SetTooltipText(l10n_util::GetString(IDS_TOOLTIP_HOME));
home_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_HOME));
home_->SetID(VIEW_ID_HOME_BUTTON);
+
+ LoadLeftSideControlsImages();
+
+ AddChildView(back_);
+ AddChildView(forward_);
+ AddChildView(reload_);
AddChildView(home_);
}
void BrowserToolbarView::CreateCenterStack(Profile *profile) {
- ResourceBundle &rb = ResourceBundle::GetSharedInstance();
-
star_ = new ToolbarStarToggle(this, this);
star_->set_tag(IDC_STAR);
- star_->SetImage(views::CustomButton::BS_NORMAL, rb.GetBitmapNamed(IDR_STAR));
- star_->SetImage(views::CustomButton::BS_HOT, rb.GetBitmapNamed(IDR_STAR_H));
- star_->SetImage(views::CustomButton::BS_PUSHED,
- rb.GetBitmapNamed(IDR_STAR_P));
- star_->SetImage(views::CustomButton::BS_DISABLED,
- rb.GetBitmapNamed(IDR_STAR_D));
- star_->SetToggledImage(views::CustomButton::BS_NORMAL,
- rb.GetBitmapNamed(IDR_STARRED));
- star_->SetToggledImage(views::CustomButton::BS_HOT,
- rb.GetBitmapNamed(IDR_STARRED_H));
- star_->SetToggledImage(views::CustomButton::BS_PUSHED,
- rb.GetBitmapNamed(IDR_STARRED_P));
star_->SetDragController(this);
star_->SetTooltipText(l10n_util::GetString(IDS_TOOLTIP_STAR));
star_->SetToggledTooltipText(l10n_util::GetString(IDS_TOOLTIP_STARRED));
@@ -229,68 +193,37 @@ void BrowserToolbarView::CreateCenterStack(Profile *profile) {
model_, this,
display_mode_ == DISPLAYMODE_LOCATION,
this);
- AddChildView(location_bar_);
- location_bar_->Init();
// The Go button.
go_ = new GoButton(location_bar_, browser_);
- go_->SetImage(views::CustomButton::BS_NORMAL, rb.GetBitmapNamed(IDR_GO));
- go_->SetImage(views::CustomButton::BS_HOT, rb.GetBitmapNamed(IDR_GO_H));
- go_->SetImage(views::CustomButton::BS_PUSHED, rb.GetBitmapNamed(IDR_GO_P));
- go_->SetToggledImage(views::CustomButton::BS_NORMAL,
- rb.GetBitmapNamed(IDR_STOP));
- go_->SetToggledImage(views::CustomButton::BS_HOT,
- rb.GetBitmapNamed(IDR_STOP_H));
- go_->SetToggledImage(views::CustomButton::BS_PUSHED,
- rb.GetBitmapNamed(IDR_STOP_P));
go_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_GO));
go_->SetID(VIEW_ID_GO_BUTTON);
- AddChildView(go_);
-}
-
-void BrowserToolbarView::Update(TabContents* tab, bool should_restore_state) {
- tab_ = tab;
- if (!location_bar_)
- return;
+ LoadCenterStackImages();
- location_bar_->Update(should_restore_state ? tab : NULL);
-}
-
-void BrowserToolbarView::OnInputInProgress(bool in_progress) {
- // The edit should make sure we're only notified when something changes.
- DCHECK(model_->input_in_progress() != in_progress);
-
- model_->set_input_in_progress(in_progress);
- location_bar_->Update(NULL);
+ AddChildView(location_bar_);
+ location_bar_->Init();
+ AddChildView(go_);
}
void BrowserToolbarView::CreateRightSideControls(Profile* profile) {
- ResourceBundle &rb = ResourceBundle::GetSharedInstance();
+ ThemeProvider* tp = GetThemeProvider();
page_menu_ = new views::MenuButton(NULL, std::wstring(), this, false);
-
- // We use different menu button images if the locale is right-to-left.
- if (UILayoutIsRightToLeft())
- page_menu_->SetIcon(*rb.GetBitmapNamed(IDR_MENU_PAGE_RTL));
- else
- page_menu_->SetIcon(*rb.GetBitmapNamed(IDR_MENU_PAGE));
-
page_menu_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_PAGE));
page_menu_->SetTooltipText(l10n_util::GetString(IDS_PAGEMENU_TOOLTIP));
page_menu_->SetID(VIEW_ID_PAGE_MENU);
- AddChildView(page_menu_);
- app_menu_ = new views::MenuButton(NULL, std::wstring(), this, false);
- if (UILayoutIsRightToLeft())
- app_menu_->SetIcon(*rb.GetBitmapNamed(IDR_MENU_CHROME_RTL));
- else
- app_menu_->SetIcon(*rb.GetBitmapNamed(IDR_MENU_CHROME));
+ app_menu_ = new views::MenuButton(NULL, std::wstring(), this, false);
app_menu_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_APP));
app_menu_->SetTooltipText(l10n_util::GetStringF(IDS_APPMENU_TOOLTIP,
l10n_util::GetString(IDS_PRODUCT_NAME)));
app_menu_->SetID(VIEW_ID_APP_MENU);
+
+ LoadRightSideControlsImages();
+
+ AddChildView(page_menu_);
AddChildView(app_menu_);
if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kBookmarkMenu)) {
@@ -301,6 +234,96 @@ void BrowserToolbarView::CreateRightSideControls(Profile* profile) {
}
}
+void BrowserToolbarView::LoadLeftSideControlsImages() {
+ ThemeProvider* tp = GetThemeProvider();
+
+ back_->SetImage(views::CustomButton::BS_NORMAL, tp->GetBitmapNamed(IDR_BACK));
+ back_->SetImage(views::CustomButton::BS_HOT, tp->GetBitmapNamed(IDR_BACK_H));
+ back_->SetImage(views::CustomButton::BS_PUSHED,
+ tp->GetBitmapNamed(IDR_BACK_P));
+ back_->SetImage(views::CustomButton::BS_DISABLED,
+ tp->GetBitmapNamed(IDR_BACK_D));
+
+ forward_->SetImage(views::CustomButton::BS_NORMAL,
+ tp->GetBitmapNamed(IDR_FORWARD));
+ forward_->SetImage(views::CustomButton::BS_HOT,
+ tp->GetBitmapNamed(IDR_FORWARD_H));
+ forward_->SetImage(views::CustomButton::BS_PUSHED,
+ tp->GetBitmapNamed(IDR_FORWARD_P));
+ forward_->SetImage(views::CustomButton::BS_DISABLED,
+ tp->GetBitmapNamed(IDR_FORWARD_D));
+
+ reload_->SetImage(views::CustomButton::BS_NORMAL,
+ tp->GetBitmapNamed(IDR_RELOAD));
+ reload_->SetImage(views::CustomButton::BS_HOT,
+ tp->GetBitmapNamed(IDR_RELOAD_H));
+ reload_->SetImage(views::CustomButton::BS_PUSHED,
+ tp->GetBitmapNamed(IDR_RELOAD_P));
+
+ home_->SetImage(views::CustomButton::BS_NORMAL, tp->GetBitmapNamed(IDR_HOME));
+ home_->SetImage(views::CustomButton::BS_HOT, tp->GetBitmapNamed(IDR_HOME_H));
+ home_->SetImage(views::CustomButton::BS_PUSHED,
+ tp->GetBitmapNamed(IDR_HOME_P));
+}
+
+void BrowserToolbarView::LoadCenterStackImages() {
+ ThemeProvider* tp = GetThemeProvider();
+
+ star_->SetImage(views::CustomButton::BS_NORMAL, tp->GetBitmapNamed(IDR_STAR));
+ star_->SetImage(views::CustomButton::BS_HOT, tp->GetBitmapNamed(IDR_STAR_H));
+ star_->SetImage(views::CustomButton::BS_PUSHED,
+ tp->GetBitmapNamed(IDR_STAR_P));
+ star_->SetImage(views::CustomButton::BS_DISABLED,
+ tp->GetBitmapNamed(IDR_STAR_D));
+ star_->SetToggledImage(views::CustomButton::BS_NORMAL,
+ tp->GetBitmapNamed(IDR_STARRED));
+ star_->SetToggledImage(views::CustomButton::BS_HOT,
+ tp->GetBitmapNamed(IDR_STARRED_H));
+ star_->SetToggledImage(views::CustomButton::BS_PUSHED,
+ tp->GetBitmapNamed(IDR_STARRED_P));
+
+ go_->SetImage(views::CustomButton::BS_NORMAL, tp->GetBitmapNamed(IDR_GO));
+ go_->SetImage(views::CustomButton::BS_HOT, tp->GetBitmapNamed(IDR_GO_H));
+ go_->SetImage(views::CustomButton::BS_PUSHED, tp->GetBitmapNamed(IDR_GO_P));
+ go_->SetToggledImage(views::CustomButton::BS_NORMAL,
+ tp->GetBitmapNamed(IDR_STOP));
+ go_->SetToggledImage(views::CustomButton::BS_HOT,
+ tp->GetBitmapNamed(IDR_STOP_H));
+ go_->SetToggledImage(views::CustomButton::BS_PUSHED,
+ tp->GetBitmapNamed(IDR_STOP_P));
+}
+
+void BrowserToolbarView::LoadRightSideControlsImages() {
+ ThemeProvider* tp = GetThemeProvider();
+
+ // We use different menu button images if the locale is right-to-left.
+ if (UILayoutIsRightToLeft())
+ page_menu_->SetIcon(*tp->GetBitmapNamed(IDR_MENU_PAGE_RTL));
+ else
+ page_menu_->SetIcon(*tp->GetBitmapNamed(IDR_MENU_PAGE));
+ if (UILayoutIsRightToLeft())
+ app_menu_->SetIcon(*tp->GetBitmapNamed(IDR_MENU_CHROME_RTL));
+ else
+ app_menu_->SetIcon(*tp->GetBitmapNamed(IDR_MENU_CHROME));
+}
+
+void BrowserToolbarView::Update(TabContents* tab, bool should_restore_state) {
+ tab_ = tab;
+
+ if (!location_bar_)
+ return;
+
+ location_bar_->Update(should_restore_state ? tab : NULL);
+}
+
+void BrowserToolbarView::OnInputInProgress(bool in_progress) {
+ // The edit should make sure we're only notified when something changes.
+ DCHECK(model_->input_in_progress() != in_progress);
+
+ model_->set_input_in_progress(in_progress);
+ location_bar_->Update(NULL);
+}
+
void BrowserToolbarView::Layout() {
// If we have not been initialized yet just do nothing.
if (back_ == NULL)
@@ -758,6 +781,12 @@ void BrowserToolbarView::SetAccessibleName(const std::wstring& name) {
accessible_name_.assign(name);
}
+void BrowserToolbarView::ThemeChanged() {
+ LoadLeftSideControlsImages();
+ LoadCenterStackImages();
+ LoadRightSideControlsImages();
+}
+
int BrowserToolbarView::GetNextAccessibleViewIndex(int view_index,
bool nav_left) {
int modifier = 1;
diff --git a/chrome/browser/views/toolbar_view.h b/chrome/browser/views/toolbar_view.h
index c5a9f83..b5f3861 100644
--- a/chrome/browser/views/toolbar_view.h
+++ b/chrome/browser/views/toolbar_view.h
@@ -63,6 +63,7 @@ class BrowserToolbarView : public views::View,
virtual bool GetAccessibleName(std::wstring* name);
virtual bool GetAccessibleRole(AccessibilityTypes::Role* role);
virtual void SetAccessibleName(const std::wstring& name);
+ virtual void ThemeChanged();
// Overridden from EncodingMenuControllerDelegate:
virtual bool IsItemChecked(int id) const;
@@ -147,6 +148,9 @@ class BrowserToolbarView : public views::View,
void CreateLeftSideControls();
void CreateCenterStack(Profile* profile);
void CreateRightSideControls(Profile* profile);
+ void LoadLeftSideControlsImages();
+ void LoadCenterStackImages();
+ void LoadRightSideControlsImages();
// Updates the controls to display the security appropriately (highlighted if
// secure).