Chromium Code Reviews| Index: chrome/browser/ui/views/location_bar/zoom_bubble_view.h |
| diff --git a/chrome/browser/ui/views/location_bar/zoom_bubble_view.h b/chrome/browser/ui/views/location_bar/zoom_bubble_view.h |
| index 57eeda8fd639e69545a2bdd774d2e88c7eeaa3b8..62aaf89055d075b91de3a2450863750edc13a43b 100644 |
| --- a/chrome/browser/ui/views/location_bar/zoom_bubble_view.h |
| +++ b/chrome/browser/ui/views/location_bar/zoom_bubble_view.h |
| @@ -9,31 +9,55 @@ |
| #include "base/timer.h" |
| #include "ui/views/bubble/bubble_delegate.h" |
| #include "ui/views/controls/button/button.h" |
| +#include "ui/views/controls/button/text_button.h" |
| #include "ui/views/controls/label.h" |
| +#include "ui/views/events/event.h" |
| + |
| +class TabContents; |
| // View used to display the zoom percentage when it has changed. |
| -class ZoomBubbleView : public views::BubbleDelegateView { |
| +class ZoomBubbleView : public views::ButtonListener, |
|
Peter Kasting
2012/07/26 01:36:14
Nit: Maybe makes sense to put BubbleDelegateView f
Kyle Horimoto
2012/08/03 03:33:29
Done.
|
| + public views::BubbleDelegateView { |
| public: |
| // Shows the bubble and automatically closes it after a short time period if |
| // |auto_close| is true. |
| static void ShowBubble(views::View* anchor_view, |
| - int zoom_percent, |
| + TabContents* tab_contents, |
| bool auto_close); |
| static void CloseBubble(); |
| static bool IsShowing(); |
| private: |
| ZoomBubbleView(views::View* anchor_view, |
| - int zoom_percent, |
| + TabContents* tab_contents, |
| bool auto_close); |
| virtual ~ZoomBubbleView(); |
| + // Refreshes the bubble by changing the zoom percentage appropriately and |
| + // resetting the timer if necessary. |
| + void Refresh(); |
| + |
| void Close(); |
| + // Starts a timer which will close the bubble if |auto_close_| is true. |
| + void StartTimerIfNecessary(); |
| + |
| + // Stops the auto-close timer. |
| + void StopTimer(); |
| + |
| + // views::View method. |
| + virtual void OnMouseMoved(const views::MouseEvent& event) OVERRIDE; |
| + virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE; |
| + |
| + // views::ButtonListener method. |
| + virtual void ButtonPressed(views::Button* sender, |
| + const views::Event& event) OVERRIDE; |
| + |
| // views::BubbleDelegateView method. |
| virtual void Init() OVERRIDE; |
| + virtual gfx::Rect GetAnchorRect() OVERRIDE; |
| - // views::BubbleDelegateView: |
| + // views::BubbleDelegateView method. |
|
Peter Kasting
2012/07/26 01:36:14
Nit: Group all overrides from the same base class
Kyle Horimoto
2012/08/03 03:33:29
Done.
|
| virtual void WindowClosing() OVERRIDE; |
| // Singleton instance of the zoom bubble. The zoom bubble can only be shown on |
| @@ -47,12 +71,30 @@ class ZoomBubbleView : public views::BubbleDelegateView { |
| // Label displaying the zoom percentage. |
| views::Label* label_; |
| - // The zoom percentage to show in the bubble. |
| - int zoom_percent_; |
| + // The TabContents for the page whose zoom has changed. |
| + TabContents* tab_contents_; |
| // Whether the currently displayed bubble will automatically close. |
| bool auto_close_; |
| + // Private class used to display a text button to use custom mouse events. |
| + // Because TextButtons already override mouse event handler methods to draw |
| + // borders, this class is necessary to continue to provide that functionality |
| + // while correctly handling auto-closing behavior of the zoom bubble. |
| + class ZoomBubbleViewTextButton : public views::TextButton { |
| + public: |
| + ZoomBubbleViewTextButton(ZoomBubbleView* listener, const string16& text); |
| + virtual ~ZoomBubbleViewTextButton() {} |
| + virtual void OnMouseMoved(const views::MouseEvent& event) OVERRIDE; |
| + virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE; |
| + |
| + private: |
| + ZoomBubbleView* delegate_; |
| + }; |
| + |
| + // Give the button access to ZoomBubbleView's internals. |
|
Peter Kasting
2012/07/26 01:36:14
It seems better to me to make Start/StopTimer() be
Kyle Horimoto
2012/08/03 03:33:29
Ended up fixing the other part, so this is no long
|
| + friend class ZoomBubbleViewTextButton; |
| + |
| DISALLOW_COPY_AND_ASSIGN(ZoomBubbleView); |
| }; |