| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_VIEWS_GO_BUTTON_H__ | 5 #ifndef CHROME_BROWSER_VIEWS_GO_BUTTON_H__ |
| 6 #define CHROME_BROWSER_VIEWS_GO_BUTTON_H__ | 6 #define CHROME_BROWSER_VIEWS_GO_BUTTON_H__ |
| 7 | 7 |
| 8 #include "chrome/views/controls/button/image_button.h" | 8 #include "chrome/views/controls/button/image_button.h" |
| 9 #include "base/task.h" | 9 #include "base/task.h" |
| 10 | 10 |
| 11 class CommandUpdater; | 11 class Browser; |
| 12 class LocationBarView; | 12 class LocationBarView; |
| 13 | 13 |
| 14 //////////////////////////////////////////////////////////////////////////////// | 14 //////////////////////////////////////////////////////////////////////////////// |
| 15 // | 15 // |
| 16 // GoButton | 16 // GoButton |
| 17 // | 17 // |
| 18 // The go button attached to the toolbar. It shows different tooltips | 18 // The go button attached to the toolbar. It shows different tooltips |
| 19 // according to the content of the location bar and changes to a stop | 19 // according to the content of the location bar and changes to a stop |
| 20 // button when a page load is in progress. Trickiness comes from the | 20 // button when a page load is in progress. Trickiness comes from the |
| 21 // desire to have the 'stop' button not change back to 'go' if the user's | 21 // desire to have the 'stop' button not change back to 'go' if the user's |
| 22 // mouse is hovering over it (to prevent mis-clicks). | 22 // mouse is hovering over it (to prevent mis-clicks). |
| 23 // | 23 // |
| 24 //////////////////////////////////////////////////////////////////////////////// | 24 //////////////////////////////////////////////////////////////////////////////// |
| 25 | 25 |
| 26 class GoButton : public views::ToggleImageButton, | 26 class GoButton : public views::ToggleImageButton, |
| 27 public views::ButtonListener { | 27 public views::ButtonListener { |
| 28 public: | 28 public: |
| 29 // TODO(beng): get rid of the command updater param and instead have a | 29 GoButton(LocationBarView* location_bar, Browser* Browser); |
| 30 // delegate. | |
| 31 GoButton(LocationBarView* location_bar, CommandUpdater* command_updater); | |
| 32 virtual ~GoButton(); | 30 virtual ~GoButton(); |
| 33 | 31 |
| 34 typedef enum Mode { MODE_GO = 0, MODE_STOP }; | 32 typedef enum Mode { MODE_GO = 0, MODE_STOP }; |
| 35 | 33 |
| 36 // Force the button state | 34 // Force the button state |
| 37 void ChangeMode(Mode mode); | 35 void ChangeMode(Mode mode); |
| 38 | 36 |
| 39 // Ask for a specified button state. This is commonly called by the Browser | 37 // Ask for a specified button state. This is commonly called by the Browser |
| 40 // when page load state changes. | 38 // when page load state changes. |
| 41 void ScheduleChangeMode(Mode mode); | 39 void ScheduleChangeMode(Mode mode); |
| 42 | 40 |
| 43 // Overridden from views::ButtonListener: | 41 // Overridden from views::ButtonListener: |
| 44 virtual void ButtonPressed(views::Button* button); | 42 virtual void ButtonPressed(views::Button* button); |
| 45 | 43 |
| 46 // Overridden from views::View: | 44 // Overridden from views::View: |
| 47 virtual void OnMouseExited(const views::MouseEvent& e); | 45 virtual void OnMouseExited(const views::MouseEvent& e); |
| 48 virtual bool GetTooltipText(int x, int y, std::wstring* tooltip); | 46 virtual bool GetTooltipText(int x, int y, std::wstring* tooltip); |
| 49 | 47 |
| 50 private: | 48 private: |
| 51 void OnButtonTimer(); | 49 void OnButtonTimer(); |
| 52 | 50 |
| 53 int button_delay_; | 51 int button_delay_; |
| 54 ScopedRunnableMethodFactory<GoButton> stop_timer_; | 52 ScopedRunnableMethodFactory<GoButton> stop_timer_; |
| 55 | 53 |
| 56 LocationBarView* location_bar_; | 54 LocationBarView* location_bar_; |
| 57 CommandUpdater* command_updater_; | 55 Browser* browser_; |
| 58 | 56 |
| 59 // The mode we should be in | 57 // The mode we should be in |
| 60 Mode intended_mode_; | 58 Mode intended_mode_; |
| 61 | 59 |
| 62 // The currently-visible mode - this may different from the intended mode | 60 // The currently-visible mode - this may different from the intended mode |
| 63 Mode visible_mode_; | 61 Mode visible_mode_; |
| 64 | 62 |
| 65 DISALLOW_EVIL_CONSTRUCTORS(GoButton); | 63 DISALLOW_EVIL_CONSTRUCTORS(GoButton); |
| 66 }; | 64 }; |
| 67 | 65 |
| 68 #endif // CHROME_BROWSER_VIEWS_GO_BUTTON_H__ | 66 #endif // CHROME_BROWSER_VIEWS_GO_BUTTON_H__ |
| OLD | NEW |