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" |
(...skipping 17 matching lines...) Expand all Loading... |
28 class ReloadButton : public ToolbarButton, | 28 class ReloadButton : public ToolbarButton, |
29 public views::ButtonListener, | 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 explicit ReloadButton(CommandUpdater* command_updater); | 37 explicit ReloadButton(CommandUpdater* command_updater); |
38 virtual ~ReloadButton(); | 38 ~ReloadButton() override; |
39 | 39 |
40 // Ask for a specified button state. If |force| is true this will be applied | 40 // Ask for a specified button state. If |force| is true this will be applied |
41 // immediately. | 41 // immediately. |
42 void ChangeMode(Mode mode, bool force); | 42 void ChangeMode(Mode mode, bool force); |
43 | 43 |
44 // Enable reload drop-down menu. | 44 // Enable reload drop-down menu. |
45 void set_menu_enabled(bool enable) { menu_enabled_ = enable; } | 45 void set_menu_enabled(bool enable) { menu_enabled_ = enable; } |
46 | 46 |
47 void LoadImages(); | 47 void LoadImages(); |
48 | 48 |
49 // ToolbarButton: | 49 // ToolbarButton: |
50 virtual void OnMouseExited(const ui::MouseEvent& event) override; | 50 void OnMouseExited(const ui::MouseEvent& event) override; |
51 virtual bool GetTooltipText(const gfx::Point& p, | 51 bool GetTooltipText(const gfx::Point& p, |
52 base::string16* tooltip) const override; | 52 base::string16* tooltip) const override; |
53 virtual const char* GetClassName() const override; | 53 const char* GetClassName() const override; |
54 virtual void GetAccessibleState(ui::AXViewState* state) override; | 54 void GetAccessibleState(ui::AXViewState* state) override; |
55 virtual bool ShouldShowMenu() override; | 55 bool ShouldShowMenu() override; |
56 virtual void ShowDropDownMenu(ui::MenuSourceType source_type) override; | 56 void ShowDropDownMenu(ui::MenuSourceType source_type) override; |
57 | 57 |
58 // views::ButtonListener: | 58 // views::ButtonListener: |
59 virtual void ButtonPressed(views::Button* /* button */, | 59 void ButtonPressed(views::Button* /* button */, |
60 const ui::Event& event) override; | 60 const ui::Event& event) override; |
61 | 61 |
62 // ui::SimpleMenuModel::Delegate: | 62 // ui::SimpleMenuModel::Delegate: |
63 virtual bool IsCommandIdChecked(int command_id) const override; | 63 bool IsCommandIdChecked(int command_id) const override; |
64 virtual bool IsCommandIdEnabled(int command_id) const override; | 64 bool IsCommandIdEnabled(int command_id) const override; |
65 virtual bool IsCommandIdVisible(int command_id) const override; | 65 bool IsCommandIdVisible(int command_id) const override; |
66 virtual bool GetAcceleratorForCommandId( | 66 bool GetAcceleratorForCommandId(int command_id, |
67 int command_id, | 67 ui::Accelerator* accelerator) override; |
68 ui::Accelerator* accelerator) override; | 68 void ExecuteCommand(int command_id, int event_flags) override; |
69 virtual void ExecuteCommand(int command_id, int event_flags) override; | |
70 | 69 |
71 private: | 70 private: |
72 friend class ReloadButtonTest; | 71 friend class ReloadButtonTest; |
73 | 72 |
74 ui::SimpleMenuModel* CreateMenuModel(); | 73 ui::SimpleMenuModel* CreateMenuModel(); |
75 | 74 |
76 void ExecuteBrowserCommand(int command, int event_flags); | 75 void ExecuteBrowserCommand(int command, int event_flags); |
77 void ChangeModeInternal(Mode mode); | 76 void ChangeModeInternal(Mode mode); |
78 | 77 |
79 void OnDoubleClickTimer(); | 78 void OnDoubleClickTimer(); |
(...skipping 23 matching lines...) Expand all Loading... |
103 // True if we should pretend the button is hovered. | 102 // True if we should pretend the button is hovered. |
104 bool testing_mouse_hovered_; | 103 bool testing_mouse_hovered_; |
105 // Increments when we would tell the browser to "reload", so | 104 // Increments when we would tell the browser to "reload", so |
106 // test code can tell whether we did so (as there may be no |browser_|). | 105 // test code can tell whether we did so (as there may be no |browser_|). |
107 int testing_reload_count_; | 106 int testing_reload_count_; |
108 | 107 |
109 DISALLOW_IMPLICIT_CONSTRUCTORS(ReloadButton); | 108 DISALLOW_IMPLICIT_CONSTRUCTORS(ReloadButton); |
110 }; | 109 }; |
111 | 110 |
112 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_RELOAD_BUTTON_H__ | 111 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_RELOAD_BUTTON_H__ |
OLD | NEW |