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/gtest_prod_util.h" | 9 #include "base/gtest_prod_util.h" |
10 #include "base/timer/timer.h" | 10 #include "base/timer/timer.h" |
11 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" | 11 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" |
| 12 #include "chrome/browser/ui/views/managed_full_screen_bubble_delegate_view.h" |
12 #include "content/public/browser/notification_observer.h" | 13 #include "content/public/browser/notification_observer.h" |
13 #include "content/public/browser/notification_registrar.h" | 14 #include "content/public/browser/notification_registrar.h" |
14 #include "extensions/browser/extension_icon_image.h" | 15 #include "extensions/browser/extension_icon_image.h" |
15 #include "ui/views/bubble/bubble_delegate.h" | 16 #include "ui/views/bubble/bubble_delegate.h" |
16 #include "ui/views/controls/button/button.h" | 17 #include "ui/views/controls/button/button.h" |
17 #include "ui/views/controls/label.h" | 18 #include "ui/views/controls/label.h" |
18 | 19 |
19 class FullscreenController; | 20 class FullscreenController; |
20 | 21 |
21 namespace content { | 22 namespace content { |
22 class NotificationDetails; | 23 class NotificationDetails; |
23 class NotificationSource; | 24 class NotificationSource; |
24 class WebContents; | 25 class WebContents; |
25 } | 26 } |
26 | 27 |
27 namespace views { | 28 namespace views { |
28 class ImageButton; | 29 class ImageButton; |
29 } // namespace views | 30 } // namespace views |
30 | 31 |
31 // View used to display the zoom percentage when it has changed. | 32 // View used to display the zoom percentage when it has changed. |
32 class ZoomBubbleView : public views::BubbleDelegateView, | 33 class ZoomBubbleView : public ManagedFullScreenBubbleDelegateView, |
33 public views::ButtonListener, | 34 public views::ButtonListener, |
34 public content::NotificationObserver, | |
35 public ImmersiveModeController::Observer, | 35 public ImmersiveModeController::Observer, |
36 public extensions::IconImage::Observer { | 36 public extensions::IconImage::Observer { |
37 public: | 37 public: |
38 // Shows the bubble and automatically closes it after a short time period if | 38 // Shows the bubble and automatically closes it after a short time period if |
39 // |auto_close| is true. | 39 // |auto_close| is true. |
40 static void ShowBubble(content::WebContents* web_contents, | 40 static void ShowBubble(content::WebContents* web_contents, |
41 bool auto_close); | 41 bool auto_close); |
42 | 42 |
43 // Closes the showing bubble (if one exists). | 43 // Closes the showing bubble (if one exists). |
44 static void CloseBubble(); | 44 static void CloseBubble(); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 // If the bubble is not anchored to a view, places the bubble in the top | 82 // If the bubble is not anchored to a view, places the bubble in the top |
83 // right (left in RTL) of the |screen_bounds| that contain |web_contents_|'s | 83 // right (left in RTL) of the |screen_bounds| that contain |web_contents_|'s |
84 // browser window. Because the positioning is based on the size of the | 84 // browser window. Because the positioning is based on the size of the |
85 // bubble, this must be called after the bubble is created. | 85 // bubble, this must be called after the bubble is created. |
86 void AdjustForFullscreen(const gfx::Rect& screen_bounds); | 86 void AdjustForFullscreen(const gfx::Rect& screen_bounds); |
87 | 87 |
88 // Refreshes the bubble by changing the zoom percentage appropriately and | 88 // Refreshes the bubble by changing the zoom percentage appropriately and |
89 // resetting the timer if necessary. | 89 // resetting the timer if necessary. |
90 void Refresh(); | 90 void Refresh(); |
91 | 91 |
92 void Close(); | 92 // ManagedFullScreenBubbleDelegateView: |
| 93 void Close() override; |
93 | 94 |
94 // Sets information about the extension that initiated the zoom change. | 95 // Sets information about the extension that initiated the zoom change. |
95 // Calling this method asserts that the extension |extension| did initiate | 96 // Calling this method asserts that the extension |extension| did initiate |
96 // the zoom change. | 97 // the zoom change. |
97 void SetExtensionInfo(const extensions::Extension* extension); | 98 void SetExtensionInfo(const extensions::Extension* extension); |
98 | 99 |
99 // Starts a timer which will close the bubble if |auto_close_| is true. | 100 // Starts a timer which will close the bubble if |auto_close_| is true. |
100 void StartTimerIfNecessary(); | 101 void StartTimerIfNecessary(); |
101 | 102 |
102 // Stops the auto-close timer. | 103 // Stops the auto-close timer. |
103 void StopTimer(); | 104 void StopTimer(); |
104 | 105 |
105 // extensions::IconImage::Observer overrides: | 106 // extensions::IconImage::Observer overrides: |
106 void OnExtensionIconImageChanged(extensions::IconImage* /* image */) override; | 107 void OnExtensionIconImageChanged(extensions::IconImage* /* image */) override; |
107 | 108 |
108 // views::View methods. | 109 // views::View methods. |
109 void OnMouseEntered(const ui::MouseEvent& event) override; | 110 void OnMouseEntered(const ui::MouseEvent& event) override; |
110 void OnMouseExited(const ui::MouseEvent& event) override; | 111 void OnMouseExited(const ui::MouseEvent& event) override; |
111 | 112 |
112 // ui::EventHandler method. | 113 // ui::EventHandler method. |
113 void OnGestureEvent(ui::GestureEvent* event) override; | 114 void OnGestureEvent(ui::GestureEvent* event) override; |
114 | 115 |
115 // views::ButtonListener method. | 116 // views::ButtonListener method. |
116 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | 117 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
117 | 118 |
118 // views::BubbleDelegateView method. | 119 // views::BubbleDelegateView method. |
119 void Init() override; | 120 void Init() override; |
120 void WindowClosing() override; | 121 void WindowClosing() override; |
121 | 122 |
122 // content::NotificationObserver method. | |
123 void Observe(int type, | |
124 const content::NotificationSource& source, | |
125 const content::NotificationDetails& details) override; | |
126 | |
127 // ImmersiveModeController::Observer methods. | 123 // ImmersiveModeController::Observer methods. |
128 void OnImmersiveRevealStarted() override; | 124 void OnImmersiveRevealStarted() override; |
129 void OnImmersiveModeControllerDestroyed() override; | 125 void OnImmersiveModeControllerDestroyed() override; |
130 | 126 |
131 ZoomBubbleExtensionInfo extension_info_; | 127 ZoomBubbleExtensionInfo extension_info_; |
132 | 128 |
133 // Singleton instance of the zoom bubble. The zoom bubble can only be shown on | 129 // Singleton instance of the zoom bubble. The zoom bubble can only be shown on |
134 // the active browser window, so there is no case in which it will be shown | 130 // the active browser window, so there is no case in which it will be shown |
135 // twice at the same time. | 131 // twice at the same time. |
136 static ZoomBubbleView* zoom_bubble_; | 132 static ZoomBubbleView* zoom_bubble_; |
(...skipping 13 matching lines...) Expand all Loading... |
150 content::WebContents* web_contents_; | 146 content::WebContents* web_contents_; |
151 | 147 |
152 // Whether the currently displayed bubble will automatically close. | 148 // Whether the currently displayed bubble will automatically close. |
153 bool auto_close_; | 149 bool auto_close_; |
154 | 150 |
155 // The immersive mode controller for the BrowserView containing | 151 // The immersive mode controller for the BrowserView containing |
156 // |web_contents_|. | 152 // |web_contents_|. |
157 // Not owned. | 153 // Not owned. |
158 ImmersiveModeController* immersive_mode_controller_; | 154 ImmersiveModeController* immersive_mode_controller_; |
159 | 155 |
160 // Used to register for fullscreen change notifications. | |
161 content::NotificationRegistrar registrar_; | |
162 | |
163 DISALLOW_COPY_AND_ASSIGN(ZoomBubbleView); | 156 DISALLOW_COPY_AND_ASSIGN(ZoomBubbleView); |
164 }; | 157 }; |
165 | 158 |
166 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ZOOM_BUBBLE_VIEW_H_ | 159 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ZOOM_BUBBLE_VIEW_H_ |
OLD | NEW |