| 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 "base/basictypes.h" |
| 9 #include "base/task.h" |
| 8 #include "chrome/views/controls/button/image_button.h" | 10 #include "chrome/views/controls/button/image_button.h" |
| 9 #include "base/task.h" | |
| 10 | 11 |
| 11 class Browser; | 12 class Browser; |
| 12 class LocationBarView; | 13 class LocationBarView; |
| 13 | 14 |
| 14 //////////////////////////////////////////////////////////////////////////////// | 15 //////////////////////////////////////////////////////////////////////////////// |
| 15 // | 16 // |
| 16 // GoButton | 17 // GoButton |
| 17 // | 18 // |
| 18 // The go button attached to the toolbar. It shows different tooltips | 19 // 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 | 20 // 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 | 21 // 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 | 22 // 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). | 23 // mouse is hovering over it (to prevent mis-clicks). |
| 23 // | 24 // |
| 24 //////////////////////////////////////////////////////////////////////////////// | 25 //////////////////////////////////////////////////////////////////////////////// |
| 25 | 26 |
| 26 class GoButton : public views::ToggleImageButton, | 27 class GoButton : public views::ToggleImageButton, |
| 27 public views::ButtonListener { | 28 public views::ButtonListener { |
| 28 public: | 29 public: |
| 30 typedef enum Mode { MODE_GO = 0, MODE_STOP }; |
| 31 |
| 29 GoButton(LocationBarView* location_bar, Browser* Browser); | 32 GoButton(LocationBarView* location_bar, Browser* Browser); |
| 30 virtual ~GoButton(); | 33 virtual ~GoButton(); |
| 31 | 34 |
| 32 typedef enum Mode { MODE_GO = 0, MODE_STOP }; | |
| 33 | |
| 34 // Force the button state | 35 // Force the button state |
| 35 void ChangeMode(Mode mode); | 36 void ChangeMode(Mode mode); |
| 36 | 37 |
| 37 // Ask for a specified button state. This is commonly called by the Browser | 38 // Ask for a specified button state. This is commonly called by the Browser |
| 38 // when page load state changes. | 39 // when page load state changes. |
| 39 void ScheduleChangeMode(Mode mode); | 40 void ScheduleChangeMode(Mode mode); |
| 40 | 41 |
| 41 // Overridden from views::ButtonListener: | 42 // Overridden from views::ButtonListener: |
| 42 virtual void ButtonPressed(views::Button* button); | 43 virtual void ButtonPressed(views::Button* button); |
| 43 | 44 |
| 44 // Overridden from views::View: | 45 // Overridden from views::View: |
| 45 virtual void OnMouseExited(const views::MouseEvent& e); | 46 virtual void OnMouseExited(const views::MouseEvent& e); |
| 46 virtual bool GetTooltipText(int x, int y, std::wstring* tooltip); | 47 virtual bool GetTooltipText(int x, int y, std::wstring* tooltip); |
| 47 | 48 |
| 48 private: | 49 private: |
| 49 void OnButtonTimer(); | 50 void OnButtonTimer(); |
| 50 | 51 |
| 51 int button_delay_; | 52 int button_delay_; |
| 52 ScopedRunnableMethodFactory<GoButton> stop_timer_; | 53 ScopedRunnableMethodFactory<GoButton> stop_timer_; |
| 53 | 54 |
| 54 LocationBarView* location_bar_; | 55 LocationBarView* location_bar_; |
| 55 Browser* browser_; | 56 Browser* browser_; |
| 56 | 57 |
| 57 // The mode we should be in | 58 // The mode we should be in |
| 58 Mode intended_mode_; | 59 Mode intended_mode_; |
| 59 | 60 |
| 60 // The currently-visible mode - this may different from the intended mode | 61 // The currently-visible mode - this may different from the intended mode |
| 61 Mode visible_mode_; | 62 Mode visible_mode_; |
| 62 | 63 |
| 63 DISALLOW_EVIL_CONSTRUCTORS(GoButton); | 64 DISALLOW_COPY_AND_ASSIGN(GoButton); |
| 64 }; | 65 }; |
| 65 | 66 |
| 66 #endif // CHROME_BROWSER_VIEWS_GO_BUTTON_H__ | 67 #endif // CHROME_BROWSER_VIEWS_GO_BUTTON_H__ |
| OLD | NEW |