OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/views/tabs/tab_strip.h" | 5 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <iterator> | 8 #include <iterator> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 mask->close(); | 391 mask->close(); |
392 } | 392 } |
393 | 393 |
394 return true; | 394 return true; |
395 } | 395 } |
396 | 396 |
397 void NewTabButton::PaintFill(bool pressed, | 397 void NewTabButton::PaintFill(bool pressed, |
398 double hover_value, | 398 double hover_value, |
399 float scale, | 399 float scale, |
400 gfx::Canvas* canvas) const { | 400 gfx::Canvas* canvas) const { |
401 int bg_id = IDR_THEME_TAB_BACKGROUND_V; | 401 bool custom_image; |
402 if (!GetWidget()->ShouldWindowContentsBeTransparent()) { | 402 const int bg_id = tab_strip_->GetBackgroundResourceId(&custom_image); |
403 bg_id = tab_strip_->controller()->IsIncognito() ? | |
404 IDR_THEME_TAB_BACKGROUND_INCOGNITO : IDR_THEME_TAB_BACKGROUND; | |
405 } | |
406 | 403 |
407 // Draw the fill background image. | 404 // Draw the fill background image. |
408 const gfx::Size size(GetNewTabButtonSize()); | 405 const gfx::Size size(GetNewTabButtonSize()); |
409 ui::ThemeProvider* theme_provider = GetThemeProvider(); | 406 ui::ThemeProvider* theme_provider = GetThemeProvider(); |
410 gfx::ImageSkia* background = theme_provider->GetImageSkiaNamed(bg_id); | 407 gfx::ImageSkia* background = theme_provider->GetImageSkiaNamed(bg_id); |
411 // For custom tab backgrounds the background starts at the top of the tab | 408 // For custom tab backgrounds the background starts at the top of the tab |
412 // strip. Otherwise the background starts at the top of the frame. | 409 // strip. Otherwise the background starts at the top of the frame. |
413 const int offset_y = theme_provider->HasCustomImage(bg_id) ? | 410 const int offset_y = theme_provider->HasCustomImage(bg_id) ? |
414 0 : background_offset_.y(); | 411 0 : background_offset_.y(); |
415 | 412 |
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1201 clip->SetRect(x, 0, tab_bounds.width() - x, tab_bounds.height()); | 1198 clip->SetRect(x, 0, tab_bounds.width() - x, tab_bounds.height()); |
1202 } | 1199 } |
1203 } | 1200 } |
1204 return true; | 1201 return true; |
1205 } | 1202 } |
1206 | 1203 |
1207 bool TabStrip::IsImmersiveStyle() const { | 1204 bool TabStrip::IsImmersiveStyle() const { |
1208 return immersive_style_; | 1205 return immersive_style_; |
1209 } | 1206 } |
1210 | 1207 |
| 1208 int TabStrip::GetBackgroundResourceId(bool* custom_image) const { |
| 1209 ui::ThemeProvider* theme_provider = GetThemeProvider(); |
| 1210 |
| 1211 if (GetWidget()->ShouldWindowContentsBeTransparent()) { |
| 1212 const int kBackgroundIdGlass = IDR_THEME_TAB_BACKGROUND_V; |
| 1213 *custom_image = theme_provider->HasCustomImage(kBackgroundIdGlass); |
| 1214 return kBackgroundIdGlass; |
| 1215 } |
| 1216 |
| 1217 // If a custom theme does not provide a replacement tab background, but does |
| 1218 // provide a replacement frame image, HasCustomImage() on the tab background |
| 1219 // ID will return false, but the theme provider will make a custom image from |
| 1220 // the frame image. |
| 1221 const bool incognito = controller()->IsIncognito(); |
| 1222 const int id = incognito ? |
| 1223 IDR_THEME_TAB_BACKGROUND_INCOGNITO : IDR_THEME_TAB_BACKGROUND; |
| 1224 *custom_image = theme_provider->HasCustomImage(id) || |
| 1225 theme_provider->HasCustomImage( |
| 1226 incognito ? IDR_THEME_FRAME_INCOGNITO : IDR_THEME_FRAME); |
| 1227 return id; |
| 1228 } |
| 1229 |
1211 void TabStrip::UpdateTabAccessibilityState(const Tab* tab, | 1230 void TabStrip::UpdateTabAccessibilityState(const Tab* tab, |
1212 ui::AXViewState* state) { | 1231 ui::AXViewState* state) { |
1213 state->count = tab_count(); | 1232 state->count = tab_count(); |
1214 state->index = GetModelIndexOfTab(tab); | 1233 state->index = GetModelIndexOfTab(tab); |
1215 } | 1234 } |
1216 | 1235 |
1217 void TabStrip::MouseMovedOutOfHost() { | 1236 void TabStrip::MouseMovedOutOfHost() { |
1218 ResizeLayoutTabs(); | 1237 ResizeLayoutTabs(); |
1219 if (reset_to_shrink_on_exit_) { | 1238 if (reset_to_shrink_on_exit_) { |
1220 reset_to_shrink_on_exit_ = false; | 1239 reset_to_shrink_on_exit_ = false; |
(...skipping 1441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2662 ConvertPointToViewAndGetEventHandler(this, newtab_button_, point); | 2681 ConvertPointToViewAndGetEventHandler(this, newtab_button_, point); |
2663 if (view) | 2682 if (view) |
2664 return view; | 2683 return view; |
2665 } | 2684 } |
2666 Tab* tab = FindTabForEvent(point); | 2685 Tab* tab = FindTabForEvent(point); |
2667 if (tab) | 2686 if (tab) |
2668 return ConvertPointToViewAndGetEventHandler(this, tab, point); | 2687 return ConvertPointToViewAndGetEventHandler(this, tab, point); |
2669 } | 2688 } |
2670 return this; | 2689 return this; |
2671 } | 2690 } |
OLD | NEW |