OLD | NEW |
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 "chrome/browser/ui/views/frame/immersive_mode_controller.h" |
10 #include "content/public/browser/notification_observer.h" | 11 #include "content/public/browser/notification_observer.h" |
11 #include "content/public/browser/notification_registrar.h" | 12 #include "content/public/browser/notification_registrar.h" |
12 #include "ui/views/bubble/bubble_delegate.h" | 13 #include "ui/views/bubble/bubble_delegate.h" |
13 #include "ui/views/controls/button/button.h" | 14 #include "ui/views/controls/button/button.h" |
14 #include "ui/views/controls/label.h" | 15 #include "ui/views/controls/label.h" |
15 | 16 |
16 class FullscreenController; | 17 class BrowserView; |
17 | 18 |
18 namespace content { | 19 namespace content { |
19 class NotificationDetails; | 20 class NotificationDetails; |
20 class NotificationSource; | 21 class NotificationSource; |
21 class WebContents; | 22 class WebContents; |
22 } | 23 } |
23 | 24 |
24 // View used to display the zoom percentage when it has changed. | 25 // View used to display the zoom percentage when it has changed. |
25 class ZoomBubbleView : public views::BubbleDelegateView, | 26 class ZoomBubbleView : public views::BubbleDelegateView, |
26 public views::ButtonListener, | 27 public views::ButtonListener, |
27 public content::NotificationObserver { | 28 public content::NotificationObserver, |
| 29 public ImmersiveModeController::Observer { |
28 public: | 30 public: |
29 // Shows the bubble and automatically closes it after a short time period if | 31 // Shows the bubble and automatically closes it after a short time period if |
30 // |auto_close| is true. | 32 // |auto_close| is true. |
31 static void ShowBubble(content::WebContents* web_contents, | 33 static void ShowBubble(content::WebContents* web_contents, |
32 bool auto_close); | 34 bool auto_close); |
33 | 35 |
34 // Closes the showing bubble (if one exists). | 36 // Closes the showing bubble (if one exists). |
35 static void CloseBubble(); | 37 static void CloseBubble(); |
36 | 38 |
37 // Whether the zoom bubble is currently showing. | 39 // Whether the zoom bubble is currently showing. |
38 static bool IsShowing(); | 40 static bool IsShowing(); |
39 | 41 |
40 private: | 42 private: |
41 ZoomBubbleView(views::View* anchor_view, | 43 ZoomBubbleView(views::View* anchor_view, |
42 content::WebContents* web_contents, | 44 content::WebContents* web_contents, |
43 bool auto_close, | 45 bool auto_close, |
44 FullscreenController* fullscreen_controller); | 46 BrowserView* browser_view); |
45 virtual ~ZoomBubbleView(); | 47 virtual ~ZoomBubbleView(); |
46 | 48 |
47 // Place the bubble in the top right (left in RTL) of the |screen_bounds| that | 49 // If the bubble is not anchored to a view, places the bubble in the top |
48 // contain |web_contents_|'s browser window. Because the positioning is based | 50 // right (left in RTL) of the |screen_bounds| that contain |web_content_|'s |
49 // on the size of the bubble, this must be called after the bubble is created. | 51 // browser window. Because the positioning is based on the size of the |
| 52 // bubble, this must be called after the bubble is created. |
50 void AdjustForFullscreen(const gfx::Rect& screen_bounds); | 53 void AdjustForFullscreen(const gfx::Rect& screen_bounds); |
51 | 54 |
52 // Refreshes the bubble by changing the zoom percentage appropriately and | 55 // Refreshes the bubble by changing the zoom percentage appropriately and |
53 // resetting the timer if necessary. | 56 // resetting the timer if necessary. |
54 void Refresh(); | 57 void Refresh(); |
55 | 58 |
56 void Close(); | 59 void Close(); |
57 | 60 |
58 // Starts a timer which will close the bubble if |auto_close_| is true. | 61 // Starts a timer which will close the bubble if |auto_close_| is true. |
59 void StartTimerIfNecessary(); | 62 void StartTimerIfNecessary(); |
(...skipping 14 matching lines...) Expand all Loading... |
74 | 77 |
75 // views::BubbleDelegateView method. | 78 // views::BubbleDelegateView method. |
76 virtual void Init() OVERRIDE; | 79 virtual void Init() OVERRIDE; |
77 virtual void WindowClosing() OVERRIDE; | 80 virtual void WindowClosing() OVERRIDE; |
78 | 81 |
79 // content::NotificationObserver method. | 82 // content::NotificationObserver method. |
80 virtual void Observe(int type, | 83 virtual void Observe(int type, |
81 const content::NotificationSource& source, | 84 const content::NotificationSource& source, |
82 const content::NotificationDetails& details) OVERRIDE; | 85 const content::NotificationDetails& details) OVERRIDE; |
83 | 86 |
| 87 // ImmersiveModeController::Observer method. |
| 88 virtual void OnStartedImmersiveReveal() OVERRIDE; |
| 89 |
84 // Singleton instance of the zoom bubble. The zoom bubble can only be shown on | 90 // Singleton instance of the zoom bubble. The zoom bubble can only be shown on |
85 // the active browser window, so there is no case in which it will be shown | 91 // the active browser window, so there is no case in which it will be shown |
86 // twice at the same time. | 92 // twice at the same time. |
87 static ZoomBubbleView* zoom_bubble_; | 93 static ZoomBubbleView* zoom_bubble_; |
88 | 94 |
89 // Timer used to close the bubble when |auto_close_| is true. | 95 // Timer used to close the bubble when |auto_close_| is true. |
90 base::OneShotTimer<ZoomBubbleView> timer_; | 96 base::OneShotTimer<ZoomBubbleView> timer_; |
91 | 97 |
92 // Label displaying the zoom percentage. | 98 // Label displaying the zoom percentage. |
93 views::Label* label_; | 99 views::Label* label_; |
94 | 100 |
95 // The WebContents for the page whose zoom has changed. | 101 // The WebContents for the page whose zoom has changed. |
96 content::WebContents* web_contents_; | 102 content::WebContents* web_contents_; |
97 | 103 |
98 // Whether the currently displayed bubble will automatically close. | 104 // Whether the currently displayed bubble will automatically close. |
99 bool auto_close_; | 105 bool auto_close_; |
100 | 106 |
| 107 // Keeps the top-of-window views revealed (but does not initiate a reveal) |
| 108 // when the bubble is visible in immersive fullscreen. |
| 109 scoped_ptr<ImmersiveRevealedLock> immersive_reveal_lock_; |
| 110 |
101 // Used to register for fullscreen change notifications. | 111 // Used to register for fullscreen change notifications. |
102 content::NotificationRegistrar registrar_; | 112 content::NotificationRegistrar registrar_; |
103 | 113 |
104 DISALLOW_COPY_AND_ASSIGN(ZoomBubbleView); | 114 DISALLOW_COPY_AND_ASSIGN(ZoomBubbleView); |
105 }; | 115 }; |
106 | 116 |
107 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ZOOM_BUBBLE_VIEW_H_ | 117 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ZOOM_BUBBLE_VIEW_H_ |
OLD | NEW |