| 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/macros.h" |
| 9 #include "base/timer/timer.h" | 10 #include "base/timer/timer.h" |
| 10 #include "chrome/browser/ui/views/toolbar/toolbar_button.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.h" | 13 #include "ui/views/controls/button/button.h" |
| 13 | 14 |
| 14 class CommandUpdater; | 15 class CommandUpdater; |
| 15 | 16 |
| 16 //////////////////////////////////////////////////////////////////////////////// | 17 //////////////////////////////////////////////////////////////////////////////// |
| 17 // | 18 // |
| 18 // ReloadButton | 19 // ReloadButton |
| 19 // | 20 // |
| 20 // 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 |
| 21 // 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' |
| 22 // 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 |
| 23 // (to prevent mis-clicks). | 24 // (to prevent mis-clicks). |
| 24 // | 25 // |
| 25 //////////////////////////////////////////////////////////////////////////////// | 26 //////////////////////////////////////////////////////////////////////////////// |
| 26 | 27 |
| 27 class ReloadButton : public ToolbarButton, | 28 class ReloadButton : public ToolbarButton, |
| 28 public views::ButtonListener, | 29 public views::ButtonListener, |
| 29 public ui::SimpleMenuModel::Delegate { | 30 public ui::SimpleMenuModel::Delegate { |
| 30 public: | 31 public: |
| 31 enum Mode { MODE_RELOAD = 0, MODE_STOP }; | 32 enum Mode { MODE_RELOAD = 0, MODE_STOP }; |
| 32 | 33 |
| 33 // The button's class name. | 34 // The button's class name. |
| 34 static const char kViewClassName[]; | 35 static const char kViewClassName[]; |
| 35 | 36 |
| 36 explicit ReloadButton(CommandUpdater* command_updater); | 37 ReloadButton(Profile* profile, CommandUpdater* command_updater); |
| 37 ~ReloadButton() override; | 38 ~ReloadButton() override; |
| 38 | 39 |
| 39 // 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 |
| 40 // immediately. | 41 // immediately. |
| 41 void ChangeMode(Mode mode, bool force); | 42 void ChangeMode(Mode mode, bool force); |
| 42 | 43 |
| 43 // Enable reload drop-down menu. | 44 // Enable reload drop-down menu. |
| 44 void set_menu_enabled(bool enable) { menu_enabled_ = enable; } | 45 void set_menu_enabled(bool enable) { menu_enabled_ = enable; } |
| 45 | 46 |
| 46 void LoadImages(); | 47 void LoadImages(); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 // Indicates if reload menu is enabled. | 98 // Indicates if reload menu is enabled. |
| 98 bool menu_enabled_; | 99 bool menu_enabled_; |
| 99 | 100 |
| 100 // TESTING ONLY | 101 // TESTING ONLY |
| 101 // True if we should pretend the button is hovered. | 102 // True if we should pretend the button is hovered. |
| 102 bool testing_mouse_hovered_; | 103 bool testing_mouse_hovered_; |
| 103 // Increments when we would tell the browser to "reload", so | 104 // Increments when we would tell the browser to "reload", so |
| 104 // 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_|). |
| 105 int testing_reload_count_; | 106 int testing_reload_count_; |
| 106 | 107 |
| 107 DISALLOW_IMPLICIT_CONSTRUCTORS(ReloadButton); | 108 DISALLOW_COPY_AND_ASSIGN(ReloadButton); |
| 108 }; | 109 }; |
| 109 | 110 |
| 110 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_RELOAD_BUTTON_H__ | 111 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_RELOAD_BUTTON_H_ |
| OLD | NEW |