| 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 | 8 |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 // positioned correctly at the middle and slightly down from the button. | 333 // positioned correctly at the middle and slightly down from the button. |
| 334 NSPoint windowOrigin = self.anchorPoint; | 334 NSPoint windowOrigin = self.anchorPoint; |
| 335 NSSize offsets = NSMakeSize(info_bubble::kBubbleArrowXOffset + | 335 NSSize offsets = NSMakeSize(info_bubble::kBubbleArrowXOffset + |
| 336 info_bubble::kBubbleArrowWidth / 2.0, | 336 info_bubble::kBubbleArrowWidth / 2.0, |
| 337 info_bubble::kBubbleArrowHeight / 2.0); | 337 info_bubble::kBubbleArrowHeight / 2.0); |
| 338 offsets = [extensionView_ convertSize:offsets toView:nil]; | 338 offsets = [extensionView_ convertSize:offsets toView:nil]; |
| 339 windowOrigin.x -= NSWidth(frame) - offsets.width; | 339 windowOrigin.x -= NSWidth(frame) - offsets.width; |
| 340 windowOrigin.y -= NSHeight(frame) - offsets.height; | 340 windowOrigin.y -= NSHeight(frame) - offsets.height; |
| 341 frame.origin = windowOrigin; | 341 frame.origin = windowOrigin; |
| 342 | 342 |
| 343 // In case the window is animating already, change its size by creating a | 343 // Is the window still animating in? If so, then cancel that and create a new |
| 344 // new animation setting the opacity and new frame value. Otherwise, a | 344 // animation setting the opacity and new frame value. Otherwise the current |
| 345 // preexisting animation would continue after the frame is set, reverting | 345 // animation will continue after this frame is set, reverting the frame to |
| 346 // the frame to what it was when the animation started. | 346 // what it was when the animation started. |
| 347 NSWindow* window = [self window]; | 347 NSWindow* window = [self window]; |
| 348 id animator = [window animator]; | 348 if ([window isVisible] && [[window animator] alphaValue] < 1.0) { |
| 349 [NSAnimationContext beginGrouping]; | 349 [NSAnimationContext beginGrouping]; |
| 350 [[NSAnimationContext currentContext] setDuration:kAnimationDuration]; | 350 [[NSAnimationContext currentContext] setDuration:kAnimationDuration]; |
| 351 [animator setAlphaValue:1.0]; | 351 [[window animator] setAlphaValue:1.0]; |
| 352 [animator setFrame:frame display:YES]; | 352 [[window animator] setFrame:frame display:YES]; |
| 353 [NSAnimationContext endGrouping]; | 353 [NSAnimationContext endGrouping]; |
| 354 } else { |
| 355 [window setFrame:frame display:YES]; |
| 356 } |
| 354 | 357 |
| 355 // A NSViewFrameDidChangeNotification won't be sent until the extension view | 358 // A NSViewFrameDidChangeNotification won't be sent until the extension view |
| 356 // content is loaded. The window is hidden on init, so show it the first time | 359 // content is loaded. The window is hidden on init, so show it the first time |
| 357 // the notification is fired (and consequently the view contents have loaded). | 360 // the notification is fired (and consequently the view contents have loaded). |
| 358 if (![window isVisible]) { | 361 if (![window isVisible]) { |
| 359 [self showWindow:self]; | 362 [self showWindow:self]; |
| 360 } | 363 } |
| 361 } | 364 } |
| 362 | 365 |
| 363 - (void)onSizeChanged:(NSSize)newSize { | 366 - (void)onSizeChanged:(NSSize)newSize { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 return minSize; | 409 return minSize; |
| 407 } | 410 } |
| 408 | 411 |
| 409 // Private (TestingAPI) | 412 // Private (TestingAPI) |
| 410 + (NSSize)maxPopupSize { | 413 + (NSSize)maxPopupSize { |
| 411 NSSize maxSize = {ExtensionViewMac::kMaxWidth, ExtensionViewMac::kMaxHeight}; | 414 NSSize maxSize = {ExtensionViewMac::kMaxWidth, ExtensionViewMac::kMaxHeight}; |
| 412 return maxSize; | 415 return maxSize; |
| 413 } | 416 } |
| 414 | 417 |
| 415 @end | 418 @end |
| OLD | NEW |