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 27 matching lines...) Expand all Loading... |
72 scoped_ptr<const extensions::IconImage> icon_image; | 72 scoped_ptr<const extensions::IconImage> icon_image; |
73 }; | 73 }; |
74 | 74 |
75 ZoomBubbleView(views::View* anchor_view, | 75 ZoomBubbleView(views::View* anchor_view, |
76 content::WebContents* web_contents, | 76 content::WebContents* web_contents, |
77 bool auto_close, | 77 bool auto_close, |
78 ImmersiveModeController* immersive_mode_controller, | 78 ImmersiveModeController* immersive_mode_controller, |
79 FullscreenController* fullscreen_controller); | 79 FullscreenController* fullscreen_controller); |
80 ~ZoomBubbleView() override; | 80 ~ZoomBubbleView() override; |
81 | 81 |
82 // If the bubble is not anchored to a view, places the bubble in the top | 82 // ManagedFullScreenBubbleDelegateView: |
83 // right (left in RTL) of the |screen_bounds| that contain |web_contents_|'s | 83 void OnGestureEvent(ui::GestureEvent* event) override; |
84 // browser window. Because the positioning is based on the size of the | 84 void OnMouseEntered(const ui::MouseEvent& event) override; |
85 // bubble, this must be called after the bubble is created. | 85 void OnMouseExited(const ui::MouseEvent& event) override; |
86 void AdjustForFullscreen(const gfx::Rect& screen_bounds); | 86 void Init() override; |
| 87 void WindowClosing() override; |
| 88 void Close() override; |
| 89 |
| 90 // views::ButtonListener: |
| 91 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
| 92 |
| 93 // ImmersiveModeController::Observer: |
| 94 void OnImmersiveRevealStarted() override; |
| 95 void OnImmersiveModeControllerDestroyed() override; |
| 96 |
| 97 // extensions::IconImage::Observer: |
| 98 void OnExtensionIconImageChanged(extensions::IconImage* /* image */) override; |
87 | 99 |
88 // Refreshes the bubble by changing the zoom percentage appropriately and | 100 // Refreshes the bubble by changing the zoom percentage appropriately and |
89 // resetting the timer if necessary. | 101 // resetting the timer if necessary. |
90 void Refresh(); | 102 void Refresh(); |
91 | 103 |
92 void Close(); | |
93 | |
94 // Sets information about the extension that initiated the zoom change. | 104 // Sets information about the extension that initiated the zoom change. |
95 // Calling this method asserts that the extension |extension| did initiate | 105 // Calling this method asserts that the extension |extension| did initiate |
96 // the zoom change. | 106 // the zoom change. |
97 void SetExtensionInfo(const extensions::Extension* extension); | 107 void SetExtensionInfo(const extensions::Extension* extension); |
98 | 108 |
99 // Starts a timer which will close the bubble if |auto_close_| is true. | 109 // Starts a timer which will close the bubble if |auto_close_| is true. |
100 void StartTimerIfNecessary(); | 110 void StartTimerIfNecessary(); |
101 | 111 |
102 // Stops the auto-close timer. | 112 // Stops the auto-close timer. |
103 void StopTimer(); | 113 void StopTimer(); |
104 | 114 |
105 // extensions::IconImage::Observer overrides: | |
106 void OnExtensionIconImageChanged(extensions::IconImage* /* image */) override; | |
107 | |
108 // views::View methods. | |
109 void OnMouseEntered(const ui::MouseEvent& event) override; | |
110 void OnMouseExited(const ui::MouseEvent& event) override; | |
111 | |
112 // ui::EventHandler method. | |
113 void OnGestureEvent(ui::GestureEvent* event) override; | |
114 | |
115 // views::ButtonListener method. | |
116 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | |
117 | |
118 // views::BubbleDelegateView method. | |
119 void Init() override; | |
120 void WindowClosing() override; | |
121 | |
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. | |
128 void OnImmersiveRevealStarted() override; | |
129 void OnImmersiveModeControllerDestroyed() override; | |
130 | |
131 ZoomBubbleExtensionInfo extension_info_; | 115 ZoomBubbleExtensionInfo extension_info_; |
132 | 116 |
133 // Singleton instance of the zoom bubble. The zoom bubble can only be shown on | 117 // 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 | 118 // the active browser window, so there is no case in which it will be shown |
135 // twice at the same time. | 119 // twice at the same time. |
136 static ZoomBubbleView* zoom_bubble_; | 120 static ZoomBubbleView* zoom_bubble_; |
137 | 121 |
138 // Timer used to close the bubble when |auto_close_| is true. | 122 // Timer used to close the bubble when |auto_close_| is true. |
139 base::OneShotTimer<ZoomBubbleView> timer_; | 123 base::OneShotTimer<ZoomBubbleView> timer_; |
140 | 124 |
141 // Image button in the zoom bubble that will show the |extension_icon_| image | 125 // Image button in the zoom bubble that will show the |extension_icon_| image |
142 // if an extension initiated the zoom change, and links to that extension at | 126 // if an extension initiated the zoom change, and links to that extension at |
143 // "chrome://extensions". | 127 // "chrome://extensions". |
144 views::ImageButton* image_button_; | 128 views::ImageButton* image_button_; |
145 | 129 |
146 // Label displaying the zoom percentage. | 130 // Label displaying the zoom percentage. |
147 views::Label* label_; | 131 views::Label* label_; |
148 | 132 |
149 // The WebContents for the page whose zoom has changed. | 133 // The WebContents for the page whose zoom has changed. |
150 content::WebContents* web_contents_; | 134 content::WebContents* web_contents_; |
151 | 135 |
152 // Whether the currently displayed bubble will automatically close. | 136 // Whether the currently displayed bubble will automatically close. |
153 bool auto_close_; | 137 bool auto_close_; |
154 | 138 |
155 // The immersive mode controller for the BrowserView containing | 139 // The immersive mode controller for the BrowserView containing |
156 // |web_contents_|. | 140 // |web_contents_|. |
157 // Not owned. | 141 // Not owned. |
158 ImmersiveModeController* immersive_mode_controller_; | 142 ImmersiveModeController* immersive_mode_controller_; |
159 | 143 |
160 // Used to register for fullscreen change notifications. | |
161 content::NotificationRegistrar registrar_; | |
162 | |
163 DISALLOW_COPY_AND_ASSIGN(ZoomBubbleView); | 144 DISALLOW_COPY_AND_ASSIGN(ZoomBubbleView); |
164 }; | 145 }; |
165 | 146 |
166 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ZOOM_BUBBLE_VIEW_H_ | 147 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ZOOM_BUBBLE_VIEW_H_ |
OLD | NEW |