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_COCOA_EXTENSIONS_EXTENSION_POPUP_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_EXTENSIONS_EXTENSION_POPUP_CONTROLLER_H_ |
6 #define CHROME_BROWSER_UI_COCOA_EXTENSIONS_EXTENSION_POPUP_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_COCOA_EXTENSIONS_EXTENSION_POPUP_CONTROLLER_H_ |
7 | 7 |
8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
9 | 9 |
10 #import "base/memory/scoped_nsobject.h" | 10 #import "base/memory/scoped_nsobject.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #import "chrome/browser/ui/cocoa/base_bubble_controller.h" | 12 #import "chrome/browser/ui/cocoa/base_bubble_controller.h" |
13 #import "chrome/browser/ui/cocoa/info_bubble_view.h" | 13 #import "chrome/browser/ui/cocoa/info_bubble_view.h" |
14 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
15 | 15 |
16 | 16 |
17 class Browser; | 17 class Browser; |
18 class DevtoolsNotificationBridge; | 18 class DevtoolsNotificationBridge; |
19 class ExtensionHost; | |
20 class ExtensionPopupContainer; | 19 class ExtensionPopupContainer; |
21 | 20 |
22 namespace content { | 21 namespace content { |
23 class NotificationRegistrar; | 22 class NotificationRegistrar; |
24 } | 23 } |
25 | 24 |
| 25 namespace extensions { |
| 26 class ExtensionHost; |
| 27 } |
| 28 |
26 // This controller manages a single browser action popup that can appear once a | 29 // This controller manages a single browser action popup that can appear once a |
27 // user has clicked on a browser action button. It instantiates the extension | 30 // user has clicked on a browser action button. It instantiates the extension |
28 // popup view showing the content and resizes the window to accomodate any size | 31 // popup view showing the content and resizes the window to accomodate any size |
29 // changes as they occur. | 32 // changes as they occur. |
30 // | 33 // |
31 // There can only be one browser action popup open at a time, so a static | 34 // There can only be one browser action popup open at a time, so a static |
32 // variable holds a reference to the current popup. | 35 // variable holds a reference to the current popup. |
33 @interface ExtensionPopupController : BaseBubbleController { | 36 @interface ExtensionPopupController : BaseBubbleController { |
34 @private | 37 @private |
35 // The native extension view retrieved from the extension host. Weak. | 38 // The native extension view retrieved from the extension host. Weak. |
36 NSView* extensionView_; | 39 NSView* extensionView_; |
37 | 40 |
38 // The current frame of the extension view. Cached to prevent setting the | 41 // The current frame of the extension view. Cached to prevent setting the |
39 // frame if the size hasn't changed. | 42 // frame if the size hasn't changed. |
40 NSRect extensionFrame_; | 43 NSRect extensionFrame_; |
41 | 44 |
42 // The extension host object. | 45 // The extension host object. |
43 scoped_ptr<ExtensionHost> host_; | 46 scoped_ptr<extensions::ExtensionHost> host_; |
44 | 47 |
45 scoped_ptr<content::NotificationRegistrar> registrar_; | 48 scoped_ptr<content::NotificationRegistrar> registrar_; |
46 scoped_ptr<DevtoolsNotificationBridge> notificationBridge_; | 49 scoped_ptr<DevtoolsNotificationBridge> notificationBridge_; |
47 scoped_ptr<ExtensionPopupContainer> container_; | 50 scoped_ptr<ExtensionPopupContainer> container_; |
48 | 51 |
49 // Whether the popup has a devtools window attached to it. | 52 // Whether the popup has a devtools window attached to it. |
50 BOOL beingInspected_; | 53 BOOL beingInspected_; |
51 | 54 |
52 // The size once the ExtensionView has loaded. | 55 // The size once the ExtensionView has loaded. |
53 NSSize pendingSize_; | 56 NSSize pendingSize_; |
54 } | 57 } |
55 | 58 |
56 // Returns the ExtensionHost object associated with this popup. | 59 // Returns the ExtensionHost object associated with this popup. |
57 - (ExtensionHost*)extensionHost; | 60 - (extensions::ExtensionHost*)extensionHost; |
58 | 61 |
59 // Starts the process of showing the given popup URL. Instantiates an | 62 // Starts the process of showing the given popup URL. Instantiates an |
60 // ExtensionPopupController with the parent window retrieved from |browser|, a | 63 // ExtensionPopupController with the parent window retrieved from |browser|, a |
61 // host for the popup created by the extension process manager specific to the | 64 // host for the popup created by the extension process manager specific to the |
62 // browser profile and the remaining arguments |anchoredAt| and |arrowLocation|. | 65 // browser profile and the remaining arguments |anchoredAt| and |arrowLocation|. |
63 // |anchoredAt| is expected to be in the window's coordinates at the bottom | 66 // |anchoredAt| is expected to be in the window's coordinates at the bottom |
64 // center of the browser action button. | 67 // center of the browser action button. |
65 // The actual display of the popup is delayed until the page contents finish | 68 // The actual display of the popup is delayed until the page contents finish |
66 // loading in order to minimize UI flashing and resizing. | 69 // loading in order to minimize UI flashing and resizing. |
67 // Passing YES to |devMode| will launch the webkit inspector for the popup, | 70 // Passing YES to |devMode| will launch the webkit inspector for the popup, |
(...skipping 25 matching lines...) Expand all Loading... |
93 @interface ExtensionPopupController(TestingAPI) | 96 @interface ExtensionPopupController(TestingAPI) |
94 // Returns a weak pointer to the current popup's view. | 97 // Returns a weak pointer to the current popup's view. |
95 - (NSView*)view; | 98 - (NSView*)view; |
96 // Returns the minimum allowed size for an extension popup. | 99 // Returns the minimum allowed size for an extension popup. |
97 + (NSSize)minPopupSize; | 100 + (NSSize)minPopupSize; |
98 // Returns the maximum allowed size for an extension popup. | 101 // Returns the maximum allowed size for an extension popup. |
99 + (NSSize)maxPopupSize; | 102 + (NSSize)maxPopupSize; |
100 @end | 103 @end |
101 | 104 |
102 #endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_EXTENSION_POPUP_CONTROLLER_H_ | 105 #endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_EXTENSION_POPUP_CONTROLLER_H_ |
OLD | NEW |