| Index: chrome/browser/ui/cocoa/intents/web_intent_picker_view_controller.mm
|
| diff --git a/chrome/browser/ui/cocoa/intents/web_intent_picker_view_controller.mm b/chrome/browser/ui/cocoa/intents/web_intent_picker_view_controller.mm
|
| index 2109be6c98fa0fd16d810b4d374b2ac9796db64d..71836057dfa8fbcf5abe5b582d0b89141bf38eed 100644
|
| --- a/chrome/browser/ui/cocoa/intents/web_intent_picker_view_controller.mm
|
| +++ b/chrome/browser/ui/cocoa/intents/web_intent_picker_view_controller.mm
|
| @@ -27,7 +27,8 @@
|
|
|
| @interface WebIntentPickerViewController ()
|
|
|
| -- (void)performLayout;
|
| +- (void)performLayoutWithOldViewController:
|
| + (WebIntentViewController*)oldViewController;
|
| // Gets the view controller currently being displayed.
|
| - (WebIntentViewController*)currentViewController;
|
| - (WebIntentPickerState)newPickerState;
|
| @@ -63,6 +64,7 @@
|
|
|
| scoped_nsobject<NSView> view(
|
| [[FlippedView alloc] initWithFrame:ui::kWindowSizeDeterminedLater]);
|
| + [view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
|
| [self setView:view];
|
|
|
| closeButton_.reset([[HoverCloseButton alloc] initWithFrame:NSZeroRect]);
|
| @@ -134,15 +136,10 @@
|
| return;
|
|
|
| WebIntentPickerState newState = [self newPickerState];
|
| - NSView* currentView = [[self currentViewController] view];
|
| - if (state_ != newState || ![currentView superview]) {
|
| - [currentView removeFromSuperview];
|
| - // Clear the inline webview.
|
| - [inlineServiceViewController_ setServiceURL:GURL::EmptyGURL()];
|
| - [extensionPromptViewController_ clear];
|
| + WebIntentViewController* oldViewController = [self currentViewController];
|
| + if (state_ != newState || ![[oldViewController view] superview]) {
|
| state_ = newState;
|
| - currentView = [[self currentViewController] view];
|
| - [[self view] addSubview:currentView];
|
| + [[self view] addSubview:[[self currentViewController] view]];
|
|
|
| // Ensure that the close button is topmost.
|
| [closeButton_ removeFromSuperview];
|
| @@ -170,15 +167,18 @@
|
| break;
|
| }
|
|
|
| - [self performLayout];
|
| + [self performLayoutWithOldViewController:oldViewController];
|
| }
|
|
|
| -- (void)performLayout {
|
| +- (void)performLayoutWithOldViewController:
|
| + (WebIntentViewController*)oldViewController {
|
| WebIntentViewController* viewController = [self currentViewController];
|
| [viewController sizeToFitAndLayout];
|
| [[viewController view] setFrameOrigin:NSZeroPoint];
|
|
|
| NSRect bounds = [[viewController view] bounds];
|
| + NSWindow* window = [[self view] window];
|
| + NSRect windowFrame = [window frameRectForContentRect:bounds];
|
|
|
| NSRect closeFrame;
|
| closeFrame.size.width = ConstrainedWindow::GetCloseButtonSize();
|
| @@ -186,12 +186,43 @@
|
| closeFrame.origin.x = NSMaxX(bounds) - NSWidth(closeFrame) -
|
| ConstrainedWindowConstants::kCloseButtonPadding;
|
| closeFrame.origin.y = ConstrainedWindowConstants::kCloseButtonPadding;
|
| - [closeButton_ setFrame:closeFrame];
|
|
|
| - [[self view] setFrame:bounds];
|
| + if (oldViewController) {
|
| + scoped_nsobject<NSMutableArray> array([[NSMutableArray alloc] init]);
|
| + if (oldViewController && ![oldViewController isEqual:viewController]) {
|
| + [array addObject:@{
|
| + NSViewAnimationTargetKey: [viewController view],
|
| + NSViewAnimationEffectKey: NSViewAnimationFadeInEffect
|
| + }];
|
| + [array addObject:@{
|
| + NSViewAnimationTargetKey: [oldViewController view],
|
| + NSViewAnimationEffectKey: NSViewAnimationFadeOutEffect
|
| + }];
|
| + }
|
| + [array addObject:@{
|
| + NSViewAnimationTargetKey: window,
|
| + NSViewAnimationEndFrameKey: [NSValue valueWithRect:windowFrame]
|
| + }];
|
| + [array addObject:@{
|
| + NSViewAnimationTargetKey: closeButton_,
|
| + NSViewAnimationEndFrameKey: [NSValue valueWithRect:closeFrame]
|
| + }];
|
| +
|
| + scoped_nsobject<NSViewAnimation> animation(
|
| + [[NSViewAnimation alloc] initWithViewAnimations:array]);
|
| + [animation setAnimationBlockingMode:NSAnimationBlocking];
|
| + [animation setDuration:0.2];
|
| + [animation startAnimation];
|
| + } else {
|
| + [window setFrame:windowFrame display:YES];
|
| + [[self view] setFrame:bounds];
|
| + [closeButton_ setFrame:closeFrame];
|
| + }
|
|
|
| - NSWindow* window = [[self view] window];
|
| - [window setFrame:[window frameRectForContentRect:bounds] display:YES];
|
| + if (oldViewController && ![oldViewController isEqual:viewController]) {
|
| + [[oldViewController view] removeFromSuperview];
|
| + [oldViewController viewRemovedFromSuperview];
|
| + }
|
| }
|
|
|
| - (WebIntentViewController*)currentViewController {
|
|
|