| 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 |
| 10 #include <memory> |
| 9 #include <string> | 11 #include <string> |
| 10 | 12 |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #import "chrome/browser/ui/cocoa/base_bubble_controller.h" | 13 #import "chrome/browser/ui/cocoa/base_bubble_controller.h" |
| 13 #import "chrome/browser/ui/cocoa/info_bubble_view.h" | 14 #import "chrome/browser/ui/cocoa/info_bubble_view.h" |
| 14 #include "content/public/browser/notification_registrar.h" | 15 #include "content/public/browser/notification_registrar.h" |
| 15 | 16 |
| 16 class Browser; | 17 class Browser; |
| 17 class ExtensionPopupNotificationBridge; | 18 class ExtensionPopupNotificationBridge; |
| 18 class ExtensionPopupContainer; | 19 class ExtensionPopupContainer; |
| 19 | 20 |
| 20 namespace extensions { | 21 namespace extensions { |
| 21 class ExtensionViewHost; | 22 class ExtensionViewHost; |
| 22 } | 23 } |
| 23 | 24 |
| 24 // This controller manages a single browser action popup that can appear once a | 25 // This controller manages a single browser action popup that can appear once a |
| 25 // user has clicked on a browser action button. It instantiates the extension | 26 // user has clicked on a browser action button. It instantiates the extension |
| 26 // popup view showing the content and resizes the window to accomodate any size | 27 // popup view showing the content and resizes the window to accomodate any size |
| 27 // changes as they occur. | 28 // changes as they occur. |
| 28 // | 29 // |
| 29 // There can only be one browser action popup open at a time, so a static | 30 // There can only be one browser action popup open at a time, so a static |
| 30 // variable holds a reference to the current popup. | 31 // variable holds a reference to the current popup. |
| 31 @interface ExtensionPopupController : BaseBubbleController { | 32 @interface ExtensionPopupController : BaseBubbleController { |
| 32 @private | 33 @private |
| 33 // The native extension view retrieved from the extension host. Weak. | 34 // The native extension view retrieved from the extension host. Weak. |
| 34 NSView* extensionView_; | 35 NSView* extensionView_; |
| 35 | 36 |
| 36 // The current frame of the extension view. Cached to prevent setting the | 37 // The current frame of the extension view. Cached to prevent setting the |
| 37 // frame if the size hasn't changed. | 38 // frame if the size hasn't changed. |
| 38 NSRect extensionFrame_; | 39 NSRect extensionFrame_; |
| 39 | 40 |
| 40 // The extension host object. | 41 // The extension host object. |
| 41 scoped_ptr<extensions::ExtensionViewHost> host_; | 42 std::unique_ptr<extensions::ExtensionViewHost> host_; |
| 42 | 43 |
| 43 content::NotificationRegistrar registrar_; | 44 content::NotificationRegistrar registrar_; |
| 44 scoped_ptr<ExtensionPopupNotificationBridge> notificationBridge_; | 45 std::unique_ptr<ExtensionPopupNotificationBridge> notificationBridge_; |
| 45 scoped_ptr<ExtensionPopupContainer> container_; | 46 std::unique_ptr<ExtensionPopupContainer> container_; |
| 46 | 47 |
| 47 std::string extensionId_; | 48 std::string extensionId_; |
| 48 | 49 |
| 49 // Whether the popup has a devtools window attached to it. | 50 // Whether the popup has a devtools window attached to it. |
| 50 BOOL beingInspected_; | 51 BOOL beingInspected_; |
| 51 | 52 |
| 52 // There's an extra windowDidResignKey: notification right after a | 53 // There's an extra windowDidResignKey: notification right after a |
| 53 // ConstrainedWindow closes that should be ignored. | 54 // ConstrainedWindow closes that should be ignored. |
| 54 BOOL ignoreWindowDidResignKey_; | 55 BOOL ignoreWindowDidResignKey_; |
| 55 | 56 |
| 56 // The size once the ExtensionView has loaded. | 57 // The size once the ExtensionView has loaded. |
| 57 NSSize pendingSize_; | 58 NSSize pendingSize_; |
| 58 } | 59 } |
| 59 | 60 |
| 60 // Starts the process of showing the given popup URL. Instantiates an | 61 // Starts the process of showing the given popup URL. Instantiates an |
| 61 // ExtensionPopupController with the parent window retrieved from |browser|, a | 62 // ExtensionPopupController with the parent window retrieved from |browser|, a |
| 62 // host for the popup created by the extension process manager specific to the | 63 // host for the popup created by the extension process manager specific to the |
| 63 // browser profile and the remaining arguments |anchoredAt| and |arrowLocation|. | 64 // browser profile and the remaining arguments |anchoredAt| and |arrowLocation|. |
| 64 // |anchoredAt| is expected to be in the window's coordinates at the bottom | 65 // |anchoredAt| is expected to be in the window's coordinates at the bottom |
| 65 // center of the browser action button. | 66 // center of the browser action button. |
| 66 // The actual display of the popup is delayed until the page contents finish | 67 // The actual display of the popup is delayed until the page contents finish |
| 67 // loading in order to minimize UI flashing and resizing. | 68 // loading in order to minimize UI flashing and resizing. |
| 68 // Passing YES to |devMode| will launch the webkit inspector for the popup, | 69 // Passing YES to |devMode| will launch the webkit inspector for the popup, |
| 69 // and prevent the popup from closing when focus is lost. It will be closed | 70 // and prevent the popup from closing when focus is lost. It will be closed |
| 70 // after the inspector is closed, or another popup is opened. | 71 // after the inspector is closed, or another popup is opened. |
| 71 + (ExtensionPopupController*)host:(scoped_ptr<extensions::ExtensionViewHost>) | 72 + (ExtensionPopupController*) |
| 72 host | 73 host:(std::unique_ptr<extensions::ExtensionViewHost>)host |
| 73 inBrowser:(Browser*)browser | 74 inBrowser:(Browser*)browser |
| 74 anchoredAt:(NSPoint)anchoredAt | 75 anchoredAt:(NSPoint)anchoredAt |
| 75 arrowLocation:(info_bubble::BubbleArrowLocation) | 76 arrowLocation:(info_bubble::BubbleArrowLocation)arrowLocation |
| 76 arrowLocation | 77 devMode:(BOOL)devMode; |
| 77 devMode:(BOOL)devMode; | |
| 78 | 78 |
| 79 // Returns the controller used to display the popup being shown. If no popup is | 79 // Returns the controller used to display the popup being shown. If no popup is |
| 80 // currently open, then nil is returned. Static because only one extension popup | 80 // currently open, then nil is returned. Static because only one extension popup |
| 81 // window can be open at a time. | 81 // window can be open at a time. |
| 82 + (ExtensionPopupController*)popup; | 82 + (ExtensionPopupController*)popup; |
| 83 | 83 |
| 84 // Whether the popup is in the process of closing (via Core Animation). | 84 // Whether the popup is in the process of closing (via Core Animation). |
| 85 - (BOOL)isClosing; | 85 - (BOOL)isClosing; |
| 86 | 86 |
| 87 // Show the dev tools attached to the popup. | 87 // Show the dev tools attached to the popup. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 100 + (void)setAnimationsEnabledForTesting:(BOOL)enabled; | 100 + (void)setAnimationsEnabledForTesting:(BOOL)enabled; |
| 101 // Returns a weak pointer to the current popup's view. | 101 // Returns a weak pointer to the current popup's view. |
| 102 - (NSView*)view; | 102 - (NSView*)view; |
| 103 // Returns the minimum allowed size for an extension popup. | 103 // Returns the minimum allowed size for an extension popup. |
| 104 + (NSSize)minPopupSize; | 104 + (NSSize)minPopupSize; |
| 105 // Returns the maximum allowed size for an extension popup. | 105 // Returns the maximum allowed size for an extension popup. |
| 106 + (NSSize)maxPopupSize; | 106 + (NSSize)maxPopupSize; |
| 107 @end | 107 @end |
| 108 | 108 |
| 109 #endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_EXTENSION_POPUP_CONTROLLER_H_ | 109 #endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_EXTENSION_POPUP_CONTROLLER_H_ |
| OLD | NEW |