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 #ifndef CHROME_BROWSER_UI_VIEWS_TOOLBAR_RELOAD_BUTTON_H__ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_TOOLBAR_RELOAD_BUTTON_H__ |
6 #define CHROME_BROWSER_UI_VIEWS_TOOLBAR_RELOAD_BUTTON_H__ | 6 #define CHROME_BROWSER_UI_VIEWS_TOOLBAR_RELOAD_BUTTON_H__ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/gtest_prod_util.h" | 9 #include "base/gtest_prod_util.h" |
10 #include "base/timer/timer.h" | 10 #include "base/timer/timer.h" |
| 11 #include "chrome/browser/ui/views/toolbar/toolbar_button.h" |
11 #include "ui/base/models/simple_menu_model.h" | 12 #include "ui/base/models/simple_menu_model.h" |
12 #include "ui/views/controls/button/button_dropdown.h" | 13 #include "ui/views/controls/button/button_dropdown.h" |
13 | 14 |
14 class CommandUpdater; | 15 class CommandUpdater; |
15 class LocationBarView; | 16 class LocationBarView; |
16 | 17 |
17 //////////////////////////////////////////////////////////////////////////////// | 18 //////////////////////////////////////////////////////////////////////////////// |
18 // | 19 // |
19 // ReloadButton | 20 // ReloadButton |
20 // | 21 // |
21 // The reload button in the toolbar, which changes to a stop button when a page | 22 // The reload button in the toolbar, which changes to a stop button when a page |
22 // load is in progress. Trickiness comes from the desire to have the 'stop' | 23 // load is in progress. Trickiness comes from the desire to have the 'stop' |
23 // button not change back to 'reload' if the user's mouse is hovering over it | 24 // button not change back to 'reload' if the user's mouse is hovering over it |
24 // (to prevent mis-clicks). | 25 // (to prevent mis-clicks). |
25 // | 26 // |
26 //////////////////////////////////////////////////////////////////////////////// | 27 //////////////////////////////////////////////////////////////////////////////// |
27 | 28 |
28 class ReloadButton : public views::ButtonDropDown, | 29 class ReloadButton : public ToolbarButton, |
29 public views::ButtonListener, | |
30 public ui::SimpleMenuModel::Delegate { | 30 public ui::SimpleMenuModel::Delegate { |
31 public: | 31 public: |
32 enum Mode { MODE_RELOAD = 0, MODE_STOP }; | 32 enum Mode { MODE_RELOAD = 0, MODE_STOP }; |
33 | 33 |
34 // The button's class name. | 34 // The button's class name. |
35 static const char kViewClassName[]; | 35 static const char kViewClassName[]; |
36 | 36 |
37 ReloadButton(LocationBarView* location_bar, | 37 ReloadButton(LocationBarView* location_bar, |
38 CommandUpdater* command_updater); | 38 CommandUpdater* command_updater); |
39 virtual ~ReloadButton(); | 39 virtual ~ReloadButton(); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 Mode visible_mode_; | 96 Mode visible_mode_; |
97 | 97 |
98 // The delay times for the timers. These are members so that tests can modify | 98 // The delay times for the timers. These are members so that tests can modify |
99 // them. | 99 // them. |
100 base::TimeDelta double_click_timer_delay_; | 100 base::TimeDelta double_click_timer_delay_; |
101 base::TimeDelta stop_to_reload_timer_delay_; | 101 base::TimeDelta stop_to_reload_timer_delay_; |
102 | 102 |
103 // Indicates if reload menu is enabled. | 103 // Indicates if reload menu is enabled. |
104 bool menu_enabled_; | 104 bool menu_enabled_; |
105 | 105 |
106 // The parent class's images_ member is used for the current images, | 106 // The images used to render the different states of this button. |
107 // and this array is used to hold the alternative images. | 107 gfx::ImageSkia images_[STATE_COUNT]; |
| 108 |
| 109 // Array is used to hold the alternative images. |
108 // We swap between the two when changing mode. | 110 // We swap between the two when changing mode. |
109 gfx::ImageSkia alternate_images_[STATE_COUNT]; | 111 gfx::ImageSkia alternate_images_[STATE_COUNT]; |
110 | 112 |
111 // TESTING ONLY | 113 // TESTING ONLY |
112 // True if we should pretend the button is hovered. | 114 // True if we should pretend the button is hovered. |
113 bool testing_mouse_hovered_; | 115 bool testing_mouse_hovered_; |
114 // Increments when we would tell the browser to "reload", so | 116 // Increments when we would tell the browser to "reload", so |
115 // test code can tell whether we did so (as there may be no |browser_|). | 117 // test code can tell whether we did so (as there may be no |browser_|). |
116 int testing_reload_count_; | 118 int testing_reload_count_; |
117 | 119 |
118 DISALLOW_IMPLICIT_CONSTRUCTORS(ReloadButton); | 120 DISALLOW_IMPLICIT_CONSTRUCTORS(ReloadButton); |
119 }; | 121 }; |
120 | 122 |
121 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_RELOAD_BUTTON_H__ | 123 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_RELOAD_BUTTON_H__ |
OLD | NEW |