| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "ui/views/widget/native_widget_mac.h" | 5 #include "ui/views/widget/native_widget_mac.h" |
| 6 | 6 |
| 7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 // does not do this. So post a regular task. | 375 // does not do this. So post a regular task. |
| 376 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, base::BindBlock(^{ | 376 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, base::BindBlock(^{ |
| 377 [window close]; | 377 [window close]; |
| 378 })); | 378 })); |
| 379 } | 379 } |
| 380 | 380 |
| 381 void NativeWidgetMac::CloseNow() { | 381 void NativeWidgetMac::CloseNow() { |
| 382 if (!bridge_) | 382 if (!bridge_) |
| 383 return; | 383 return; |
| 384 | 384 |
| 385 // Cocoa ignores -close calls on open sheets, so they should be closed | |
| 386 // asynchronously, using Widget::Close(). | |
| 387 DCHECK(!IsWindowModalSheet()); | |
| 388 | |
| 389 // NSWindows must be retained until -[NSWindow close] returns. | 385 // NSWindows must be retained until -[NSWindow close] returns. |
| 390 base::scoped_nsobject<NSWindow> window(GetNativeWindow(), | 386 base::scoped_nsobject<NSWindow> window(GetNativeWindow(), |
| 391 base::scoped_policy::RETAIN); | 387 base::scoped_policy::RETAIN); |
| 392 | 388 |
| 393 // If there's a bridge at this point, it means there must be a window as well. | 389 // If there's a bridge at this point, it means there must be a window as well. |
| 394 DCHECK(window); | 390 DCHECK(window); |
| 395 [window close]; | 391 [window close]; |
| 396 // Note: |this| is deleted here when ownership_ == NATIVE_WIDGET_OWNS_WIDGET. | 392 // Note: |this| is deleted here when ownership_ == NATIVE_WIDGET_OWNS_WIDGET. |
| 397 } | 393 } |
| 398 | 394 |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 778 [[ViewsNSWindowCloseAnimator alloc] initWithWindow:window]; | 774 [[ViewsNSWindowCloseAnimator alloc] initWithWindow:window]; |
| 779 } | 775 } |
| 780 | 776 |
| 781 - (void)animationDidEnd:(NSAnimation*)animation { | 777 - (void)animationDidEnd:(NSAnimation*)animation { |
| 782 [window_ close]; | 778 [window_ close]; |
| 783 [animation_ setDelegate:nil]; | 779 [animation_ setDelegate:nil]; |
| 784 [self release]; | 780 [self release]; |
| 785 } | 781 } |
| 786 | 782 |
| 787 @end | 783 @end |
| OLD | NEW |