OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_EXTENSIONS_EXTENSION_POPUP_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_POPUP_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_POPUP_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_POPUP_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "chrome/browser/extensions/extension_host.h" | 9 #include "chrome/browser/extensions/extension_host.h" |
10 #include "chrome/browser/views/browser_bubble.h" | 10 #include "chrome/browser/views/browser_bubble.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 // |popup_token| is the address of the deleted ExtensionPopup. | 41 // |popup_token| is the address of the deleted ExtensionPopup. |
42 virtual void ExtensionPopupClosed(void* popup_token) {} | 42 virtual void ExtensionPopupClosed(void* popup_token) {} |
43 | 43 |
44 // Called when the ExtensionHost is first created for the pop-up view. | 44 // Called when the ExtensionHost is first created for the pop-up view. |
45 // Note that this is invoked BEFORE the ExtensionPopup is created, and can | 45 // Note that this is invoked BEFORE the ExtensionPopup is created, and can |
46 // be used to provide extra configuration of the host before it is pushed | 46 // be used to provide extra configuration of the host before it is pushed |
47 // into the popup. An example use is for automation resource routing in | 47 // into the popup. An example use is for automation resource routing in |
48 // Chrome-Frame. See extension_popup_api.cc. | 48 // Chrome-Frame. See extension_popup_api.cc. |
49 virtual void ExtensionHostCreated(ExtensionHost* host) {} | 49 virtual void ExtensionHostCreated(ExtensionHost* host) {} |
50 | 50 |
| 51 // Called immediately after a popup is created, but before the hosted |
| 52 // extension has loaded and before the popup has been displayed. Use to |
| 53 // finalize configuration of |popup|. |
| 54 virtual void ExtensionPopupCreated(ExtensionPopup* popup) {} |
| 55 |
51 // Called when the ExtensionPopup is resized. Note that the popup may have | 56 // Called when the ExtensionPopup is resized. Note that the popup may have |
52 // an empty bounds, if a popup is repositioned before the hosted content | 57 // an empty bounds, if a popup is repositioned before the hosted content |
53 // has loaded. | 58 // has loaded. |
54 virtual void ExtensionPopupResized(ExtensionPopup* popup) {} | 59 virtual void ExtensionPopupResized(ExtensionPopup* popup) {} |
55 }; | 60 }; |
56 | 61 |
57 enum PopupChrome { | 62 enum PopupChrome { |
58 BUBBLE_CHROME, | 63 BUBBLE_CHROME, |
59 RECTANGLE_CHROME | 64 RECTANGLE_CHROME |
60 }; | 65 }; |
(...skipping 28 matching lines...) Expand all Loading... |
89 static ExtensionPopup* Show(const GURL& url, Browser* browser, | 94 static ExtensionPopup* Show(const GURL& url, Browser* browser, |
90 Profile* profile, | 95 Profile* profile, |
91 gfx::NativeWindow frame_window, | 96 gfx::NativeWindow frame_window, |
92 const gfx::Rect& relative_to, | 97 const gfx::Rect& relative_to, |
93 BubbleBorder::ArrowLocation arrow_location, | 98 BubbleBorder::ArrowLocation arrow_location, |
94 bool activate_on_show, | 99 bool activate_on_show, |
95 bool inspect_with_devtools, | 100 bool inspect_with_devtools, |
96 PopupChrome chrome, | 101 PopupChrome chrome, |
97 Observer* observer); | 102 Observer* observer); |
98 | 103 |
| 104 // Assigns the maximal width and height, respectively, to which the popup |
| 105 // may expand. If these routines are not called, the popup will resize to |
| 106 // no larger than |kMaxWidth| x |kMaxHeight|. Note that the popup will |
| 107 // never expand to larger than the dimensions of the screen. |
| 108 void set_max_width(int width) { max_size_.set_width(width); } |
| 109 void set_max_height(int height) { max_size_.set_height(height); } |
| 110 |
99 // Closes the ExtensionPopup (this will cause the delegate | 111 // Closes the ExtensionPopup (this will cause the delegate |
100 // ExtensionPopupIsClosing and ExtensionPopupClosed to fire. | 112 // ExtensionPopupIsClosing and ExtensionPopupClosed to fire. |
101 void Close(); | 113 void Close(); |
102 | 114 |
103 // Some clients wish to do their own custom focus change management. If this | 115 // Some clients wish to do their own custom focus change management. If this |
104 // is set to false, then the ExtensionPopup will not do anything in response | 116 // is set to false, then the ExtensionPopup will not do anything in response |
105 // to the BubbleLostFocus() calls it gets from the BrowserBubble. | 117 // to the BubbleLostFocus() calls it gets from the BrowserBubble. |
106 void set_close_on_lost_focus(bool close_on_lost_focus) { | 118 void set_close_on_lost_focus(bool close_on_lost_focus) { |
107 close_on_lost_focus_ = close_on_lost_focus; | 119 close_on_lost_focus_ = close_on_lost_focus; |
108 } | 120 } |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 // popup. This has to be a separate window in order to support transparency. | 208 // popup. This has to be a separate window in order to support transparency. |
197 // Layered windows can't contain native child windows, so we wouldn't be | 209 // Layered windows can't contain native child windows, so we wouldn't be |
198 // able to have the ExtensionView child. | 210 // able to have the ExtensionView child. |
199 views::Widget* border_widget_; | 211 views::Widget* border_widget_; |
200 BubbleBorder* border_; | 212 BubbleBorder* border_; |
201 views::View* border_view_; | 213 views::View* border_view_; |
202 | 214 |
203 // The type of chrome associated with the popup window. | 215 // The type of chrome associated with the popup window. |
204 PopupChrome popup_chrome_; | 216 PopupChrome popup_chrome_; |
205 | 217 |
| 218 // The maximal size to which the popup may expand. |
| 219 gfx::Size max_size_; |
| 220 |
206 // The observer of this popup. | 221 // The observer of this popup. |
207 Observer* observer_; | 222 Observer* observer_; |
208 | 223 |
209 // A cached copy of the arrow-position for the bubble chrome. | 224 // A cached copy of the arrow-position for the bubble chrome. |
210 // If a black-border was requested, we still need this value to determine | 225 // If a black-border was requested, we still need this value to determine |
211 // the position of the pop-up in relation to |relative_to_|. | 226 // the position of the pop-up in relation to |relative_to_|. |
212 BubbleBorder::ArrowLocation anchor_position_; | 227 BubbleBorder::ArrowLocation anchor_position_; |
213 | 228 |
214 // ExtensionPopup's lifetime is managed via reference counting, but it does | 229 // ExtensionPopup's lifetime is managed via reference counting, but it does |
215 // not expose the RefCounted interface. Instead, the lifetime is tied to | 230 // not expose the RefCounted interface. Instead, the lifetime is tied to |
216 // this member variable. | 231 // this member variable. |
217 class InternalRefCounter : public base::RefCounted<InternalRefCounter> { | 232 class InternalRefCounter : public base::RefCounted<InternalRefCounter> { |
218 }; | 233 }; |
219 InternalRefCounter* instance_lifetime_; | 234 InternalRefCounter* instance_lifetime_; |
220 | 235 |
221 DISALLOW_COPY_AND_ASSIGN(ExtensionPopup); | 236 DISALLOW_COPY_AND_ASSIGN(ExtensionPopup); |
222 }; | 237 }; |
223 | 238 |
224 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_POPUP_H_ | 239 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_POPUP_H_ |
OLD | NEW |