| Index: ui/views/cocoa/views_nswindow_close_animator.mm
|
| diff --git a/ui/views/cocoa/views_nswindow_close_animator.mm b/ui/views/cocoa/views_nswindow_close_animator.mm
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..66764973251619de9ae71e6fbcfd42a976f81b23
|
| --- /dev/null
|
| +++ b/ui/views/cocoa/views_nswindow_close_animator.mm
|
| @@ -0,0 +1,47 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#import "ui/views/cocoa/views_nswindow_close_animator.h"
|
| +
|
| +#import <AppKit/AppKit.h>
|
| +
|
| +#import "ui/base/cocoa/constrained_window/constrained_window_animation.h"
|
| +
|
| +@interface ViewsNSWindowCloseAnimator : NSObject<NSAnimationDelegate>
|
| +- (id)initWithWindow:(NSWindow*)window;
|
| +@end
|
| +
|
| +namespace views {
|
| +
|
| +void CloseNativeWindowWithAnimation(NSWindow* window) {
|
| + [[ViewsNSWindowCloseAnimator alloc] initWithWindow:window];
|
| +}
|
| +
|
| +} // namespace views
|
| +
|
| +@implementation ViewsNSWindowCloseAnimator {
|
| + @private
|
| + base::scoped_nsobject<NSWindow> window_;
|
| + base::scoped_nsobject<NSAnimation> animation_;
|
| +}
|
| +
|
| +- (id)initWithWindow:(NSWindow*)window {
|
| + if ((self = [super init])) {
|
| + window_.reset([window retain]);
|
| + animation_.reset(
|
| + [[ConstrainedWindowAnimationHide alloc] initWithWindow:window]);
|
| + [animation_ setDelegate:self];
|
| + [animation_ setAnimationBlockingMode:NSAnimationNonblocking];
|
| + [animation_ startAnimation];
|
| + }
|
| + return self;
|
| +}
|
| +
|
| +- (void)animationDidEnd:(NSAnimation*)animation {
|
| + [window_ close];
|
| + [animation_ setDelegate:nil];
|
| + [self release];
|
| +}
|
| +
|
| +@end
|
|
|