| 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 #import "chrome/browser/ui/cocoa/extensions/extension_popup_controller.h" | 5 #import "chrome/browser/ui/cocoa/extensions/extension_popup_controller.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 } // namespace | 50 } // namespace |
| 51 | 51 |
| 52 @interface ExtensionPopupController (Private) | 52 @interface ExtensionPopupController (Private) |
| 53 // Callers should be using the public static method for initialization. | 53 // Callers should be using the public static method for initialization. |
| 54 - (id)initWithParentWindow:(NSWindow*)parentWindow | 54 - (id)initWithParentWindow:(NSWindow*)parentWindow |
| 55 anchoredAt:(NSPoint)anchoredAt | 55 anchoredAt:(NSPoint)anchoredAt |
| 56 arrowLocation:(info_bubble::BubbleArrowLocation)arrowLocation | 56 arrowLocation:(info_bubble::BubbleArrowLocation)arrowLocation |
| 57 devMode:(BOOL)devMode; | 57 devMode:(BOOL)devMode; |
| 58 | 58 |
| 59 // Set the ExtensionViewHost, taking ownership. | 59 // Set the ExtensionViewHost, taking ownership. |
| 60 - (void)setExtensionViewHost:(scoped_ptr<ExtensionViewHost>)host; | 60 - (void)setExtensionViewHost:(std::unique_ptr<ExtensionViewHost>)host; |
| 61 | 61 |
| 62 // Called when the extension's hosted NSView has been resized. | 62 // Called when the extension's hosted NSView has been resized. |
| 63 - (void)extensionViewFrameChanged; | 63 - (void)extensionViewFrameChanged; |
| 64 | 64 |
| 65 // Called when the extension's size changes. | 65 // Called when the extension's size changes. |
| 66 - (void)onSizeChanged:(NSSize)newSize; | 66 - (void)onSizeChanged:(NSSize)newSize; |
| 67 | 67 |
| 68 // Called when the extension view is shown. | 68 // Called when the extension view is shown. |
| 69 - (void)onViewDidShow; | 69 - (void)onViewDidShow; |
| 70 | 70 |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 } | 247 } |
| 248 | 248 |
| 249 - (ExtensionViewHost*)extensionViewHost { | 249 - (ExtensionViewHost*)extensionViewHost { |
| 250 return host_.get(); | 250 return host_.get(); |
| 251 } | 251 } |
| 252 | 252 |
| 253 - (void)setBeingInspected:(BOOL)beingInspected { | 253 - (void)setBeingInspected:(BOOL)beingInspected { |
| 254 beingInspected_ = beingInspected; | 254 beingInspected_ = beingInspected; |
| 255 } | 255 } |
| 256 | 256 |
| 257 + (ExtensionPopupController*)host:(scoped_ptr<ExtensionViewHost>)host | 257 + (ExtensionPopupController*)host:(std::unique_ptr<ExtensionViewHost>)host |
| 258 inBrowser:(Browser*)browser | 258 inBrowser:(Browser*)browser |
| 259 anchoredAt:(NSPoint)anchoredAt | 259 anchoredAt:(NSPoint)anchoredAt |
| 260 arrowLocation:(info_bubble::BubbleArrowLocation) | 260 arrowLocation: |
| 261 arrowLocation | 261 (info_bubble::BubbleArrowLocation)arrowLocation |
| 262 devMode:(BOOL)devMode { | 262 devMode:(BOOL)devMode { |
| 263 DCHECK([NSThread isMainThread]); | 263 DCHECK([NSThread isMainThread]); |
| 264 DCHECK(browser); | 264 DCHECK(browser); |
| 265 DCHECK(host); | 265 DCHECK(host); |
| 266 | 266 |
| 267 if (gPopup) | 267 if (gPopup) |
| 268 [gPopup close]; // Starts the animation to fade out the popup. | 268 [gPopup close]; // Starts the animation to fade out the popup. |
| 269 | 269 |
| 270 // Create the popup first. This establishes an initially hidden NSWindow so | 270 // Create the popup first. This establishes an initially hidden NSWindow so |
| 271 // that the renderer is able to gather correct screen metrics for the initial | 271 // that the renderer is able to gather correct screen metrics for the initial |
| 272 // paint. | 272 // paint. |
| 273 gPopup = [[ExtensionPopupController alloc] | 273 gPopup = [[ExtensionPopupController alloc] |
| 274 initWithParentWindow:browser->window()->GetNativeWindow() | 274 initWithParentWindow:browser->window()->GetNativeWindow() |
| 275 anchoredAt:anchoredAt | 275 anchoredAt:anchoredAt |
| 276 arrowLocation:arrowLocation | 276 arrowLocation:arrowLocation |
| 277 devMode:devMode]; | 277 devMode:devMode]; |
| 278 [gPopup setExtensionViewHost:std::move(host)]; | 278 [gPopup setExtensionViewHost:std::move(host)]; |
| 279 return gPopup; | 279 return gPopup; |
| 280 } | 280 } |
| 281 | 281 |
| 282 + (ExtensionPopupController*)popup { | 282 + (ExtensionPopupController*)popup { |
| 283 return gPopup; | 283 return gPopup; |
| 284 } | 284 } |
| 285 | 285 |
| 286 - (void)setExtensionViewHost:(scoped_ptr<ExtensionViewHost>)host { | 286 - (void)setExtensionViewHost:(std::unique_ptr<ExtensionViewHost>)host { |
| 287 DCHECK(!host_); | 287 DCHECK(!host_); |
| 288 DCHECK(host); | 288 DCHECK(host); |
| 289 host_.swap(host); | 289 host_.swap(host); |
| 290 | 290 |
| 291 extensionId_ = host_->extension_id(); | 291 extensionId_ = host_->extension_id(); |
| 292 container_.reset(new ExtensionPopupContainer(self)); | 292 container_.reset(new ExtensionPopupContainer(self)); |
| 293 ExtensionViewMac* hostView = static_cast<ExtensionViewMac*>(host_->view()); | 293 ExtensionViewMac* hostView = static_cast<ExtensionViewMac*>(host_->view()); |
| 294 hostView->set_container(container_.get()); | 294 hostView->set_container(container_.get()); |
| 295 hostView->CreateWidgetHostViewIn([self bubble]); | 295 hostView->CreateWidgetHostViewIn([self bubble]); |
| 296 | 296 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 return minSize; | 419 return minSize; |
| 420 } | 420 } |
| 421 | 421 |
| 422 // Private (TestingAPI) | 422 // Private (TestingAPI) |
| 423 + (NSSize)maxPopupSize { | 423 + (NSSize)maxPopupSize { |
| 424 NSSize maxSize = {ExtensionViewMac::kMaxWidth, ExtensionViewMac::kMaxHeight}; | 424 NSSize maxSize = {ExtensionViewMac::kMaxWidth, ExtensionViewMac::kMaxHeight}; |
| 425 return maxSize; | 425 return maxSize; |
| 426 } | 426 } |
| 427 | 427 |
| 428 @end | 428 @end |
| OLD | NEW |