OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/toolbar/reload_button.h" | 5 #include "chrome/browser/ui/views/toolbar/reload_button.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "chrome/app/chrome_command_ids.h" | 11 #include "chrome/app/chrome_command_ids.h" |
| 12 #include "chrome/app/vector_icons/vector_icons.h" |
12 #include "chrome/browser/command_updater.h" | 13 #include "chrome/browser/command_updater.h" |
13 #include "chrome/browser/search/search.h" | 14 #include "chrome/browser/search/search.h" |
14 #include "chrome/browser/themes/theme_properties.h" | 15 #include "chrome/browser/themes/theme_properties.h" |
15 #include "chrome/browser/ui/search/search_model.h" | 16 #include "chrome/browser/ui/search/search_model.h" |
16 #include "chrome/grit/generated_resources.h" | 17 #include "chrome/grit/generated_resources.h" |
17 #include "chrome/grit/theme_resources.h" | 18 #include "chrome/grit/theme_resources.h" |
18 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
19 #include "ui/base/models/simple_menu_model.h" | 20 #include "ui/base/models/simple_menu_model.h" |
20 #include "ui/base/theme_provider.h" | 21 #include "ui/base/theme_provider.h" |
21 #include "ui/base/window_open_disposition.h" | 22 #include "ui/base/window_open_disposition.h" |
22 #include "ui/gfx/paint_vector_icon.h" | 23 #include "ui/gfx/paint_vector_icon.h" |
23 #include "ui/gfx/vector_icons_public.h" | |
24 #include "ui/views/metrics.h" | 24 #include "ui/views/metrics.h" |
25 #include "ui/views/widget/widget.h" | 25 #include "ui/views/widget/widget.h" |
26 | 26 |
27 | 27 |
28 namespace { | 28 namespace { |
29 | 29 |
30 // Contents of the Reload drop-down menu. | 30 // Contents of the Reload drop-down menu. |
31 const int kReloadMenuItems[] = { | 31 const int kReloadMenuItems[] = { |
32 IDS_RELOAD_MENU_NORMAL_RELOAD_ITEM, | 32 IDS_RELOAD_MENU_NORMAL_RELOAD_ITEM, |
33 IDS_RELOAD_MENU_HARD_RELOAD_ITEM, | 33 IDS_RELOAD_MENU_HARD_RELOAD_ITEM, |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 if (!command_updater_) | 225 if (!command_updater_) |
226 return; | 226 return; |
227 command_updater_->ExecuteCommandWithDisposition( | 227 command_updater_->ExecuteCommandWithDisposition( |
228 command, ui::DispositionFromEventFlags(event_flags)); | 228 command, ui::DispositionFromEventFlags(event_flags)); |
229 } | 229 } |
230 | 230 |
231 void ReloadButton::ChangeModeInternal(Mode mode) { | 231 void ReloadButton::ChangeModeInternal(Mode mode) { |
232 const ui::ThemeProvider* tp = GetThemeProvider(); | 232 const ui::ThemeProvider* tp = GetThemeProvider(); |
233 // |tp| can be NULL in unit tests. | 233 // |tp| can be NULL in unit tests. |
234 if (tp) { | 234 if (tp) { |
235 const gfx::VectorIconId icon_id = (mode == MODE_RELOAD) | 235 const gfx::VectorIcon& icon = |
236 ? gfx::VectorIconId::NAVIGATE_RELOAD | 236 (mode == MODE_RELOAD) ? kNavigateReloadIcon : kNavigateStopIcon; |
237 : gfx::VectorIconId::NAVIGATE_STOP; | |
238 const SkColor normal_color = | 237 const SkColor normal_color = |
239 tp->GetColor(ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON); | 238 tp->GetColor(ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON); |
240 const SkColor disabled_color = | 239 const SkColor disabled_color = |
241 tp->GetColor(ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON_INACTIVE); | 240 tp->GetColor(ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON_INACTIVE); |
242 SetImage(views::Button::STATE_NORMAL, | 241 SetImage(views::Button::STATE_NORMAL, |
243 gfx::CreateVectorIcon(icon_id, normal_color)); | 242 gfx::CreateVectorIcon(icon, normal_color)); |
244 SetImage(views::Button::STATE_DISABLED, | 243 SetImage(views::Button::STATE_DISABLED, |
245 gfx::CreateVectorIcon(icon_id, disabled_color)); | 244 gfx::CreateVectorIcon(icon, disabled_color)); |
246 set_ink_drop_base_color(normal_color); | 245 set_ink_drop_base_color(normal_color); |
247 } | 246 } |
248 | 247 |
249 visible_mode_ = mode; | 248 visible_mode_ = mode; |
250 SchedulePaint(); | 249 SchedulePaint(); |
251 } | 250 } |
252 | 251 |
253 void ReloadButton::OnDoubleClickTimer() { | 252 void ReloadButton::OnDoubleClickTimer() { |
254 if (!IsMenuShowing()) | 253 if (!IsMenuShowing()) |
255 ChangeMode(intended_mode_, false); | 254 ChangeMode(intended_mode_, false); |
256 } | 255 } |
257 | 256 |
258 void ReloadButton::OnStopToReloadTimer() { | 257 void ReloadButton::OnStopToReloadTimer() { |
259 DCHECK(!IsMenuShowing()); | 258 DCHECK(!IsMenuShowing()); |
260 ChangeMode(intended_mode_, true); | 259 ChangeMode(intended_mode_, true); |
261 } | 260 } |
OLD | NEW |