Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Side by Side Diff: chrome/browser/ui/views/location_bar/zoom_bubble_view.h

Issue 10792020: Implements the "Set to default" button on the zoom bubble. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebased Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_LOCATION_BAR_ZOOM_BUBBLE_VIEW_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ZOOM_BUBBLE_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ZOOM_BUBBLE_VIEW_H_ 6 #define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ZOOM_BUBBLE_VIEW_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/timer.h" 9 #include "base/timer.h"
10 #include "ui/views/bubble/bubble_delegate.h" 10 #include "ui/views/bubble/bubble_delegate.h"
11 #include "ui/views/controls/button/button.h" 11 #include "ui/views/controls/button/button.h"
12 #include "ui/views/controls/button/text_button.h"
12 #include "ui/views/controls/label.h" 13 #include "ui/views/controls/label.h"
14 #include "ui/views/events/event.h"
15
16 class TabContents;
13 17
14 // View used to display the zoom percentage when it has changed. 18 // View used to display the zoom percentage when it has changed.
15 class ZoomBubbleView : public views::BubbleDelegateView { 19 class ZoomBubbleView : public views::BubbleDelegateView,
20 public views::ButtonListener {
16 public: 21 public:
17 // Shows the bubble and automatically closes it after a short time period if 22 // Shows the bubble and automatically closes it after a short time period if
18 // |auto_close| is true. 23 // |auto_close| is true.
19 static void ShowBubble(views::View* anchor_view, 24 static void ShowBubble(views::View* anchor_view,
20 int zoom_percent, 25 TabContents* tab_contents,
21 bool auto_close); 26 bool auto_close);
22 static void CloseBubble(); 27 static void CloseBubble();
23 static bool IsShowing(); 28 static bool IsShowing();
24 29
25 private: 30 private:
26 ZoomBubbleView(views::View* anchor_view, 31 ZoomBubbleView(views::View* anchor_view,
27 int zoom_percent, 32 TabContents* tab_contents,
28 bool auto_close); 33 bool auto_close);
29 virtual ~ZoomBubbleView(); 34 virtual ~ZoomBubbleView();
30 35
36 // Refreshes the bubble by changing the zoom percentage appropriately and
37 // resetting the timer if necessary.
38 void Refresh();
39
31 void Close(); 40 void Close();
32 41
42 // Starts a timer which will close the bubble if |auto_close_| is true.
43 void StartTimerIfNecessary();
44
45 // Stops the auto-close timer.
46 void StopTimer();
47
48 // views::View method.
49 virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE;
50 virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE;
51
52 // views::ButtonListener method.
53 virtual void ButtonPressed(views::Button* sender,
54 const views::Event& event) OVERRIDE;
55
33 // views::BubbleDelegateView method. 56 // views::BubbleDelegateView method.
34 virtual void Init() OVERRIDE; 57 virtual void Init() OVERRIDE;
35 58 virtual gfx::Rect GetAnchorRect() OVERRIDE;
36 // views::BubbleDelegateView:
37 virtual void WindowClosing() OVERRIDE; 59 virtual void WindowClosing() OVERRIDE;
38 60
39 // Singleton instance of the zoom bubble. The zoom bubble can only be shown on 61 // Singleton instance of the zoom bubble. The zoom bubble can only be shown on
40 // the active browser window, so there is no case in which it will be shown 62 // the active browser window, so there is no case in which it will be shown
41 // twice at the same time. 63 // twice at the same time.
42 static ZoomBubbleView* zoom_bubble_; 64 static ZoomBubbleView* zoom_bubble_;
43 65
44 // Timer used to close the bubble when |auto_close_| is true. 66 // Timer used to close the bubble when |auto_close_| is true.
45 base::OneShotTimer<ZoomBubbleView> timer_; 67 base::OneShotTimer<ZoomBubbleView> timer_;
46 68
47 // Label displaying the zoom percentage. 69 // Label displaying the zoom percentage.
48 views::Label* label_; 70 views::Label* label_;
49 71
50 // The zoom percentage to show in the bubble. 72 // The TabContents for the page whose zoom has changed.
51 int zoom_percent_; 73 TabContents* tab_contents_;
52 74
53 // Whether the currently displayed bubble will automatically close. 75 // Whether the currently displayed bubble will automatically close.
54 bool auto_close_; 76 bool auto_close_;
55 77
56 DISALLOW_COPY_AND_ASSIGN(ZoomBubbleView); 78 DISALLOW_COPY_AND_ASSIGN(ZoomBubbleView);
57 }; 79 };
58 80
59 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ZOOM_BUBBLE_VIEW_H_ 81 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ZOOM_BUBBLE_VIEW_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/location_bar/location_bar_view.cc ('k') | chrome/browser/ui/views/location_bar/zoom_bubble_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698