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