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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
71 // Called when the window moves or resizes. Notifies the extension. | |
72 - (void)onWindowChanged; | |
73 | |
74 @end | 71 @end |
75 | 72 |
76 class ExtensionPopupContainer : public ExtensionViewMac::Container { | 73 class ExtensionPopupContainer : public ExtensionViewMac::Container { |
77 public: | 74 public: |
78 explicit ExtensionPopupContainer(ExtensionPopupController* controller) | 75 explicit ExtensionPopupContainer(ExtensionPopupController* controller) |
79 : controller_(controller) { | 76 : controller_(controller) { |
80 } | 77 } |
81 | 78 |
82 void OnExtensionSizeChanged(ExtensionViewMac* view, | 79 void OnExtensionSizeChanged(ExtensionViewMac* view, |
83 const gfx::Size& new_size) override { | 80 const gfx::Size& new_size) override { |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 frame.size = [extensionView_ convertSize:frame.size fromView:nil]; | 396 frame.size = [extensionView_ convertSize:frame.size fromView:nil]; |
400 | 397 |
401 [extensionView_ setFrame:frame]; | 398 [extensionView_ setFrame:frame]; |
402 [extensionView_ setNeedsDisplay:YES]; | 399 [extensionView_ setNeedsDisplay:YES]; |
403 } | 400 } |
404 | 401 |
405 - (void)onViewDidShow { | 402 - (void)onViewDidShow { |
406 [self onSizeChanged:pendingSize_]; | 403 [self onSizeChanged:pendingSize_]; |
407 } | 404 } |
408 | 405 |
409 - (void)onWindowChanged { | |
410 // The window is positioned before creating the host, to ensure the host is | |
411 // created with the correct screen information. | |
412 if (!host_) | |
413 return; | |
414 | |
415 ExtensionViewMac* extensionView = | |
416 static_cast<ExtensionViewMac*>(host_->view()); | |
417 // Let the extension view know, so that it can tell plugins. | |
418 if (extensionView) | |
419 extensionView->WindowFrameChanged(); | |
420 } | |
421 | |
422 - (void)windowDidResize:(NSNotification*)notification { | |
423 [self onWindowChanged]; | |
424 } | |
425 | |
426 - (void)windowDidMove:(NSNotification*)notification { | |
427 [self onWindowChanged]; | |
428 } | |
429 | |
430 // Private (TestingAPI) | 406 // Private (TestingAPI) |
431 + (void)setAnimationsEnabledForTesting:(BOOL)enabled { | 407 + (void)setAnimationsEnabledForTesting:(BOOL)enabled { |
432 gAnimationsEnabled = enabled; | 408 gAnimationsEnabled = enabled; |
433 } | 409 } |
434 | 410 |
435 // Private (TestingAPI) | 411 // Private (TestingAPI) |
436 - (NSView*)view { | 412 - (NSView*)view { |
437 return extensionView_; | 413 return extensionView_; |
438 } | 414 } |
439 | 415 |
440 // Private (TestingAPI) | 416 // Private (TestingAPI) |
441 + (NSSize)minPopupSize { | 417 + (NSSize)minPopupSize { |
442 NSSize minSize = {ExtensionViewMac::kMinWidth, ExtensionViewMac::kMinHeight}; | 418 NSSize minSize = {ExtensionViewMac::kMinWidth, ExtensionViewMac::kMinHeight}; |
443 return minSize; | 419 return minSize; |
444 } | 420 } |
445 | 421 |
446 // Private (TestingAPI) | 422 // Private (TestingAPI) |
447 + (NSSize)maxPopupSize { | 423 + (NSSize)maxPopupSize { |
448 NSSize maxSize = {ExtensionViewMac::kMaxWidth, ExtensionViewMac::kMaxHeight}; | 424 NSSize maxSize = {ExtensionViewMac::kMaxWidth, ExtensionViewMac::kMaxHeight}; |
449 return maxSize; | 425 return maxSize; |
450 } | 426 } |
451 | 427 |
452 @end | 428 @end |
OLD | NEW |