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 FullscreenController; |
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 |
| 42 // Returns the zoom bubble if the zoom bubble is showing. Returns NULL |
| 43 // otherwise. |
| 44 static const ZoomBubbleView* GetZoomBubbleForTest(); |
| 45 |
40 private: | 46 private: |
41 ZoomBubbleView(views::View* anchor_view, | 47 ZoomBubbleView(views::View* anchor_view, |
42 content::WebContents* web_contents, | 48 content::WebContents* web_contents, |
43 bool auto_close, | 49 bool auto_close, |
| 50 ImmersiveModeController* immersive_mode_controller, |
44 FullscreenController* fullscreen_controller); | 51 FullscreenController* fullscreen_controller); |
45 virtual ~ZoomBubbleView(); | 52 virtual ~ZoomBubbleView(); |
46 | 53 |
47 // Place the bubble in the top right (left in RTL) of the |screen_bounds| that | 54 // 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 | 55 // right (left in RTL) of the |screen_bounds| that contain |web_contents_|'s |
49 // on the size of the bubble, this must be called after the bubble is created. | 56 // browser window. Because the positioning is based on the size of the |
| 57 // bubble, this must be called after the bubble is created. |
50 void AdjustForFullscreen(const gfx::Rect& screen_bounds); | 58 void AdjustForFullscreen(const gfx::Rect& screen_bounds); |
51 | 59 |
52 // Refreshes the bubble by changing the zoom percentage appropriately and | 60 // Refreshes the bubble by changing the zoom percentage appropriately and |
53 // resetting the timer if necessary. | 61 // resetting the timer if necessary. |
54 void Refresh(); | 62 void Refresh(); |
55 | 63 |
56 void Close(); | 64 void Close(); |
57 | 65 |
58 // Starts a timer which will close the bubble if |auto_close_| is true. | 66 // Starts a timer which will close the bubble if |auto_close_| is true. |
59 void StartTimerIfNecessary(); | 67 void StartTimerIfNecessary(); |
(...skipping 14 matching lines...) Expand all Loading... |
74 | 82 |
75 // views::BubbleDelegateView method. | 83 // views::BubbleDelegateView method. |
76 virtual void Init() OVERRIDE; | 84 virtual void Init() OVERRIDE; |
77 virtual void WindowClosing() OVERRIDE; | 85 virtual void WindowClosing() OVERRIDE; |
78 | 86 |
79 // content::NotificationObserver method. | 87 // content::NotificationObserver method. |
80 virtual void Observe(int type, | 88 virtual void Observe(int type, |
81 const content::NotificationSource& source, | 89 const content::NotificationSource& source, |
82 const content::NotificationDetails& details) OVERRIDE; | 90 const content::NotificationDetails& details) OVERRIDE; |
83 | 91 |
| 92 // ImmersiveModeController::Observer methods. |
| 93 virtual void OnImmersiveRevealStarted() OVERRIDE; |
| 94 virtual void OnImmersiveModeControllerDestroyed() OVERRIDE; |
| 95 |
84 // Singleton instance of the zoom bubble. The zoom bubble can only be shown on | 96 // 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 | 97 // the active browser window, so there is no case in which it will be shown |
86 // twice at the same time. | 98 // twice at the same time. |
87 static ZoomBubbleView* zoom_bubble_; | 99 static ZoomBubbleView* zoom_bubble_; |
88 | 100 |
89 // Timer used to close the bubble when |auto_close_| is true. | 101 // Timer used to close the bubble when |auto_close_| is true. |
90 base::OneShotTimer<ZoomBubbleView> timer_; | 102 base::OneShotTimer<ZoomBubbleView> timer_; |
91 | 103 |
92 // Label displaying the zoom percentage. | 104 // Label displaying the zoom percentage. |
93 views::Label* label_; | 105 views::Label* label_; |
94 | 106 |
95 // The WebContents for the page whose zoom has changed. | 107 // The WebContents for the page whose zoom has changed. |
96 content::WebContents* web_contents_; | 108 content::WebContents* web_contents_; |
97 | 109 |
98 // Whether the currently displayed bubble will automatically close. | 110 // Whether the currently displayed bubble will automatically close. |
99 bool auto_close_; | 111 bool auto_close_; |
100 | 112 |
| 113 // The immersive mode controller for the BrowserView containing |
| 114 // |web_contents_|. |
| 115 // Not owned. |
| 116 ImmersiveModeController* immersive_mode_controller_; |
| 117 |
| 118 // Keeps the top-of-window views revealed (but does not initiate a reveal) |
| 119 // when the bubble is visible in immersive fullscreen. |
| 120 scoped_ptr<ImmersiveRevealedLock> immersive_reveal_lock_; |
| 121 |
101 // Used to register for fullscreen change notifications. | 122 // Used to register for fullscreen change notifications. |
102 content::NotificationRegistrar registrar_; | 123 content::NotificationRegistrar registrar_; |
103 | 124 |
104 DISALLOW_COPY_AND_ASSIGN(ZoomBubbleView); | 125 DISALLOW_COPY_AND_ASSIGN(ZoomBubbleView); |
105 }; | 126 }; |
106 | 127 |
107 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ZOOM_BUBBLE_VIEW_H_ | 128 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ZOOM_BUBBLE_VIEW_H_ |
OLD | NEW |