Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(251)

Unified Diff: chrome/browser/ui/views/tabs/tab_strip.cc

Issue 1424913008: Combine tab background image getter code into one place. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@combine_tab_drawing
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/views/tabs/tab_strip.h ('k') | chrome/browser/ui/views/tabs/tab_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/tabs/tab_strip.cc
diff --git a/chrome/browser/ui/views/tabs/tab_strip.cc b/chrome/browser/ui/views/tabs/tab_strip.cc
index da4e53b1304f7abbdabdb0ea84a35f3d9daaac67..5fe10f19ac6bb2a12ae82e7044e2b11bc1ccb845 100644
--- a/chrome/browser/ui/views/tabs/tab_strip.cc
+++ b/chrome/browser/ui/views/tabs/tab_strip.cc
@@ -398,11 +398,8 @@ void NewTabButton::PaintFill(bool pressed,
double hover_value,
float scale,
gfx::Canvas* canvas) const {
- int bg_id = IDR_THEME_TAB_BACKGROUND_V;
- if (!GetWidget()->ShouldWindowContentsBeTransparent()) {
- bg_id = tab_strip_->controller()->IsIncognito() ?
- IDR_THEME_TAB_BACKGROUND_INCOGNITO : IDR_THEME_TAB_BACKGROUND;
- }
+ bool custom_image;
+ const int bg_id = tab_strip_->GetBackgroundResourceId(&custom_image);
// Draw the fill background image.
const gfx::Size size(GetNewTabButtonSize());
@@ -1208,6 +1205,28 @@ bool TabStrip::IsImmersiveStyle() const {
return immersive_style_;
}
+int TabStrip::GetBackgroundResourceId(bool* custom_image) const {
+ ui::ThemeProvider* theme_provider = GetThemeProvider();
+
+ if (GetWidget()->ShouldWindowContentsBeTransparent()) {
+ const int kBackgroundIdGlass = IDR_THEME_TAB_BACKGROUND_V;
+ *custom_image = theme_provider->HasCustomImage(kBackgroundIdGlass);
+ return kBackgroundIdGlass;
+ }
+
+ // If a custom theme does not provide a replacement tab background, but does
+ // provide a replacement frame image, HasCustomImage() on the tab background
+ // ID will return false, but the theme provider will make a custom image from
+ // the frame image.
+ const bool incognito = controller()->IsIncognito();
+ const int id = incognito ?
+ IDR_THEME_TAB_BACKGROUND_INCOGNITO : IDR_THEME_TAB_BACKGROUND;
+ *custom_image = theme_provider->HasCustomImage(id) ||
+ theme_provider->HasCustomImage(
+ incognito ? IDR_THEME_FRAME_INCOGNITO : IDR_THEME_FRAME);
+ return id;
+}
+
void TabStrip::UpdateTabAccessibilityState(const Tab* tab,
ui::AXViewState* state) {
state->count = tab_count();
« no previous file with comments | « chrome/browser/ui/views/tabs/tab_strip.h ('k') | chrome/browser/ui/views/tabs/tab_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698