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_RELOAD_BUTTON_H__ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_RELOAD_BUTTON_H__ |
6 #define CHROME_BROWSER_UI_VIEWS_RELOAD_BUTTON_H__ | 6 #define CHROME_BROWSER_UI_VIEWS_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.h" | 10 #include "base/timer.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 virtual bool IsCommandIdVisible(int command_id) const OVERRIDE; | 67 virtual bool IsCommandIdVisible(int command_id) const OVERRIDE; |
68 virtual bool GetAcceleratorForCommandId( | 68 virtual bool GetAcceleratorForCommandId( |
69 int command_id, | 69 int command_id, |
70 ui::Accelerator* accelerator) OVERRIDE; | 70 ui::Accelerator* accelerator) OVERRIDE; |
71 virtual void ExecuteCommand(int command_id) OVERRIDE; | 71 virtual void ExecuteCommand(int command_id) OVERRIDE; |
72 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE; | 72 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE; |
73 | 73 |
74 private: | 74 private: |
75 friend class ReloadButtonTest; | 75 friend class ReloadButtonTest; |
76 | 76 |
77 ui::SimpleMenuModel* CreateMenuModel(); | |
78 | |
79 void ExecuteBrowserCommand(int command, int event_flags); | 77 void ExecuteBrowserCommand(int command, int event_flags); |
80 void ChangeModeInternal(Mode mode); | 78 void ChangeModeInternal(Mode mode); |
81 | 79 |
82 void OnDoubleClickTimer(); | 80 void OnDoubleClickTimer(); |
83 void OnStopToReloadTimer(); | 81 void OnStopToReloadTimer(); |
84 | 82 |
85 base::OneShotTimer<ReloadButton> double_click_timer_; | 83 base::OneShotTimer<ReloadButton> double_click_timer_; |
86 base::OneShotTimer<ReloadButton> stop_to_reload_timer_; | 84 base::OneShotTimer<ReloadButton> stop_to_reload_timer_; |
87 | 85 |
88 // These may be NULL when testing. | 86 // These may be NULL when testing. |
89 LocationBarView* location_bar_; | 87 LocationBarView* location_bar_; |
90 CommandUpdater* command_updater_; | 88 CommandUpdater* command_updater_; |
91 | 89 |
92 // The mode we should be in assuming no timers are running. | 90 // The mode we should be in assuming no timers are running. |
93 Mode intended_mode_; | 91 Mode intended_mode_; |
94 | 92 |
95 // The currently-visible mode - this may differ from the intended mode. | 93 // The currently-visible mode - this may differ from the intended mode. |
96 Mode visible_mode_; | 94 Mode visible_mode_; |
97 | 95 |
98 // The delay times for the timers. These are members so that tests can modify | 96 // The delay times for the timers. These are members so that tests can modify |
99 // them. | 97 // them. |
100 base::TimeDelta double_click_timer_delay_; | 98 base::TimeDelta double_click_timer_delay_; |
101 base::TimeDelta stop_to_reload_timer_delay_; | 99 base::TimeDelta stop_to_reload_timer_delay_; |
102 | 100 |
103 // Indicates if reload menu is enabled. | 101 // Indicates if reload menu is enabled. |
104 bool menu_enabled_; | 102 bool menu_enabled_; |
105 | 103 |
| 104 // The model that populates the attached menu. |
| 105 scoped_ptr<ui::SimpleMenuModel> menu_model_; |
| 106 |
106 // The parent class's images_ member is used for the current images, | 107 // The parent class's images_ member is used for the current images, |
107 // and this array is used to hold the alternative images. | 108 // and this 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_[BS_COUNT]; | 110 gfx::ImageSkia alternate_images_[BS_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_RELOAD_BUTTON_H__ | 122 #endif // CHROME_BROWSER_UI_VIEWS_RELOAD_BUTTON_H__ |
OLD | NEW |