OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/views/tabs/tab_strip.h" | 5 #include "chrome/browser/views/tabs/tab_strip.h" |
6 | 6 |
7 #include "app/drag_drop_types.h" | 7 #include "app/drag_drop_types.h" |
8 #include "app/gfx/canvas.h" | 8 #include "app/gfx/canvas.h" |
9 #include "app/gfx/path.h" | 9 #include "app/gfx/path.h" |
10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
(...skipping 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1095 drop_indicator_width = drop_image->width(); | 1095 drop_indicator_width = drop_image->width(); |
1096 drop_indicator_height = drop_image->height(); | 1096 drop_indicator_height = drop_image->height(); |
1097 } | 1097 } |
1098 } | 1098 } |
1099 | 1099 |
1100 void TabStrip::LoadNewTabButtonImage() { | 1100 void TabStrip::LoadNewTabButtonImage() { |
1101 ThemeProvider* tp = GetThemeProvider(); | 1101 ThemeProvider* tp = GetThemeProvider(); |
1102 | 1102 |
1103 // If we don't have a theme provider yet, it means we do not have a | 1103 // If we don't have a theme provider yet, it means we do not have a |
1104 // root view, and are therefore in a test. | 1104 // root view, and are therefore in a test. |
1105 if (tp == NULL) | 1105 bool in_test = false; |
| 1106 if (tp == NULL) { |
1106 tp = new views::DefaultThemeProvider(); | 1107 tp = new views::DefaultThemeProvider(); |
| 1108 in_test = true; |
| 1109 } |
1107 | 1110 |
1108 SkBitmap* bitmap = tp->GetBitmapNamed(IDR_NEWTAB_BUTTON); | 1111 SkBitmap* bitmap = tp->GetBitmapNamed(IDR_NEWTAB_BUTTON); |
1109 SkColor color = tp->GetColor(BrowserThemeProvider::COLOR_BUTTON_BACKGROUND); | 1112 SkColor color = tp->GetColor(BrowserThemeProvider::COLOR_BUTTON_BACKGROUND); |
1110 SkBitmap* background = tp->GetBitmapNamed( | 1113 SkBitmap* background = tp->GetBitmapNamed( |
1111 IDR_THEME_WINDOW_CONTROL_BACKGROUND); | 1114 IDR_THEME_WINDOW_CONTROL_BACKGROUND); |
1112 | 1115 |
1113 newtab_button_->SetImage(views::CustomButton::BS_NORMAL, bitmap); | 1116 newtab_button_->SetImage(views::CustomButton::BS_NORMAL, bitmap); |
1114 newtab_button_->SetImage(views::CustomButton::BS_PUSHED, | 1117 newtab_button_->SetImage(views::CustomButton::BS_PUSHED, |
1115 tp->GetBitmapNamed(IDR_NEWTAB_BUTTON_P)); | 1118 tp->GetBitmapNamed(IDR_NEWTAB_BUTTON_P)); |
1116 newtab_button_->SetImage(views::CustomButton::BS_HOT, | 1119 newtab_button_->SetImage(views::CustomButton::BS_HOT, |
1117 tp->GetBitmapNamed(IDR_NEWTAB_BUTTON_H)); | 1120 tp->GetBitmapNamed(IDR_NEWTAB_BUTTON_H)); |
1118 newtab_button_->SetBackground(color, background, | 1121 newtab_button_->SetBackground(color, background, |
1119 tp->GetBitmapNamed(IDR_NEWTAB_BUTTON_MASK)); | 1122 tp->GetBitmapNamed(IDR_NEWTAB_BUTTON_MASK)); |
| 1123 if (in_test) |
| 1124 delete tp; |
1120 } | 1125 } |
1121 | 1126 |
1122 Tab* TabStrip::GetTabAt(int index) const { | 1127 Tab* TabStrip::GetTabAt(int index) const { |
1123 DCHECK(index >= 0 && index < GetTabCount()); | 1128 DCHECK(index >= 0 && index < GetTabCount()); |
1124 return tab_data_.at(index).tab; | 1129 return tab_data_.at(index).tab; |
1125 } | 1130 } |
1126 | 1131 |
1127 Tab* TabStrip::GetTabAtAdjustForAnimation(int index) const { | 1132 Tab* TabStrip::GetTabAtAdjustForAnimation(int index) const { |
1128 if (active_animation_.get() && | 1133 if (active_animation_.get() && |
1129 active_animation_->type() == TabAnimation::REMOVE && | 1134 active_animation_->type() == TabAnimation::REMOVE && |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1596 &TabStrip::ResizeLayoutTabs), | 1601 &TabStrip::ResizeLayoutTabs), |
1597 kResizeTabsTimeMs); | 1602 kResizeTabsTimeMs); |
1598 } | 1603 } |
1599 } else { | 1604 } else { |
1600 // Mouse moved quickly out of the tab strip and then into it again, so | 1605 // Mouse moved quickly out of the tab strip and then into it again, so |
1601 // cancel the timer so that the strip doesn't move when the mouse moves | 1606 // cancel the timer so that the strip doesn't move when the mouse moves |
1602 // back over it. | 1607 // back over it. |
1603 resize_layout_factory_.RevokeAll(); | 1608 resize_layout_factory_.RevokeAll(); |
1604 } | 1609 } |
1605 } | 1610 } |
OLD | NEW |