| 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 Browser; | 11 class CommandUpdater; |
| 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 GoButton(LocationBarView* location_bar, Browser* Browser); | 29 // TODO(beng): get rid of the command updater param and instead have a |
| 30 // delegate. |
| 31 GoButton(LocationBarView* location_bar, CommandUpdater* command_updater); |
| 30 virtual ~GoButton(); | 32 virtual ~GoButton(); |
| 31 | 33 |
| 32 typedef enum Mode { MODE_GO = 0, MODE_STOP }; | 34 typedef enum Mode { MODE_GO = 0, MODE_STOP }; |
| 33 | 35 |
| 34 // Force the button state | 36 // Force the button state |
| 35 void ChangeMode(Mode mode); | 37 void ChangeMode(Mode mode); |
| 36 | 38 |
| 37 // Ask for a specified button state. This is commonly called by the Browser | 39 // Ask for a specified button state. This is commonly called by the Browser |
| 38 // when page load state changes. | 40 // when page load state changes. |
| 39 void ScheduleChangeMode(Mode mode); | 41 void ScheduleChangeMode(Mode mode); |
| 40 | 42 |
| 41 // Overridden from views::ButtonListener: | 43 // Overridden from views::ButtonListener: |
| 42 virtual void ButtonPressed(views::Button* button); | 44 virtual void ButtonPressed(views::Button* button); |
| 43 | 45 |
| 44 // Overridden from views::View: | 46 // Overridden from views::View: |
| 45 virtual void OnMouseExited(const views::MouseEvent& e); | 47 virtual void OnMouseExited(const views::MouseEvent& e); |
| 46 virtual bool GetTooltipText(int x, int y, std::wstring* tooltip); | 48 virtual bool GetTooltipText(int x, int y, std::wstring* tooltip); |
| 47 | 49 |
| 48 private: | 50 private: |
| 49 void OnButtonTimer(); | 51 void OnButtonTimer(); |
| 50 | 52 |
| 51 int button_delay_; | 53 int button_delay_; |
| 52 ScopedRunnableMethodFactory<GoButton> stop_timer_; | 54 ScopedRunnableMethodFactory<GoButton> stop_timer_; |
| 53 | 55 |
| 54 LocationBarView* location_bar_; | 56 LocationBarView* location_bar_; |
| 55 Browser* browser_; | 57 CommandUpdater* command_updater_; |
| 56 | 58 |
| 57 // The mode we should be in | 59 // The mode we should be in |
| 58 Mode intended_mode_; | 60 Mode intended_mode_; |
| 59 | 61 |
| 60 // The currently-visible mode - this may different from the intended mode | 62 // The currently-visible mode - this may different from the intended mode |
| 61 Mode visible_mode_; | 63 Mode visible_mode_; |
| 62 | 64 |
| 63 DISALLOW_EVIL_CONSTRUCTORS(GoButton); | 65 DISALLOW_EVIL_CONSTRUCTORS(GoButton); |
| 64 }; | 66 }; |
| 65 | 67 |
| 66 #endif // CHROME_BROWSER_VIEWS_GO_BUTTON_H__ | 68 #endif // CHROME_BROWSER_VIEWS_GO_BUTTON_H__ |
| OLD | NEW |