OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #import "ui/views/cocoa/views_nswindow_close_animator.h" |
| 6 |
| 7 #import <AppKit/AppKit.h> |
| 8 |
| 9 #import "ui/base/cocoa/constrained_window/constrained_window_animation.h" |
| 10 |
| 11 @interface ViewsNSWindowCloseAnimator : NSObject<NSAnimationDelegate> |
| 12 - (id)initWithWindow:(NSWindow*)window; |
| 13 @end |
| 14 |
| 15 namespace views { |
| 16 |
| 17 void CloseNativeWindowWithAnimation(NSWindow* window) { |
| 18 [[ViewsNSWindowCloseAnimator alloc] initWithWindow:window]; |
| 19 } |
| 20 |
| 21 } // namespace views |
| 22 |
| 23 @implementation ViewsNSWindowCloseAnimator { |
| 24 @private |
| 25 base::scoped_nsobject<NSWindow> window_; |
| 26 base::scoped_nsobject<NSAnimation> animation_; |
| 27 } |
| 28 |
| 29 - (id)initWithWindow:(NSWindow*)window { |
| 30 if ((self = [super init])) { |
| 31 window_.reset([window retain]); |
| 32 animation_.reset( |
| 33 [[ConstrainedWindowAnimationHide alloc] initWithWindow:window]); |
| 34 [animation_ setDelegate:self]; |
| 35 [animation_ setAnimationBlockingMode:NSAnimationNonblocking]; |
| 36 [animation_ startAnimation]; |
| 37 } |
| 38 return self; |
| 39 } |
| 40 |
| 41 - (void)animationDidEnd:(NSAnimation*)animation { |
| 42 [window_ close]; |
| 43 [animation_ setDelegate:nil]; |
| 44 [self release]; |
| 45 } |
| 46 |
| 47 @end |
OLD | NEW |