| 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 27 matching lines...) Expand all Loading... |
| 38 base::scoped_nsobject<NSAnimation> animation_; | 38 base::scoped_nsobject<NSAnimation> animation_; |
| 39 } | 39 } |
| 40 | 40 |
| 41 + (void)closeWindowWithAnimation:(NSWindow*)window; | 41 + (void)closeWindowWithAnimation:(NSWindow*)window; |
| 42 | 42 |
| 43 @end | 43 @end |
| 44 | 44 |
| 45 namespace views { | 45 namespace views { |
| 46 namespace { | 46 namespace { |
| 47 | 47 |
| 48 bool SheetsEnabled() { |
| 49 return false; |
| 50 } |
| 51 |
| 48 NSInteger StyleMaskForParams(const Widget::InitParams& params) { | 52 NSInteger StyleMaskForParams(const Widget::InitParams& params) { |
| 49 // If the Widget is modal, it will be displayed as a sheet. This works best if | 53 // If the Widget is modal, it will be displayed as a sheet. This works best if |
| 50 // it has NSTitledWindowMask. For example, with NSBorderlessWindowMask, the | 54 // it has NSTitledWindowMask. For example, with NSBorderlessWindowMask, the |
| 51 // parent window still accepts input. | 55 // parent window still accepts input. |
| 52 if (params.delegate && | 56 if (SheetsEnabled() && params.delegate && |
| 53 params.delegate->GetModalType() == ui::MODAL_TYPE_WINDOW) | 57 params.delegate->GetModalType() == ui::MODAL_TYPE_WINDOW) |
| 54 return NSTitledWindowMask; | 58 return NSTitledWindowMask; |
| 55 | 59 |
| 56 // TODO(tapted): Determine better masks when there are use cases for it. | 60 // TODO(tapted): Determine better masks when there are use cases for it. |
| 57 if (params.remove_standard_frame) | 61 if (params.remove_standard_frame) |
| 58 return NSBorderlessWindowMask; | 62 return NSBorderlessWindowMask; |
| 59 | 63 |
| 60 if (params.type == Widget::InitParams::TYPE_WINDOW) { | 64 if (params.type == Widget::InitParams::TYPE_WINDOW) { |
| 61 return NSTitledWindowMask | NSClosableWindowMask | | 65 return NSTitledWindowMask | NSClosableWindowMask | |
| 62 NSMiniaturizableWindowMask | NSResizableWindowMask | | 66 NSMiniaturizableWindowMask | NSResizableWindowMask | |
| (...skipping 26 matching lines...) Expand all Loading... |
| 89 id<NSWindowDelegate> window_delegate = [window delegate]; | 93 id<NSWindowDelegate> window_delegate = [window delegate]; |
| 90 if ([window_delegate respondsToSelector:@selector(nativeWidgetMac)]) { | 94 if ([window_delegate respondsToSelector:@selector(nativeWidgetMac)]) { |
| 91 ViewsNSWindowDelegate* delegate = | 95 ViewsNSWindowDelegate* delegate = |
| 92 base::mac::ObjCCastStrict<ViewsNSWindowDelegate>(window_delegate); | 96 base::mac::ObjCCastStrict<ViewsNSWindowDelegate>(window_delegate); |
| 93 return [delegate nativeWidgetMac]->bridge_.get(); | 97 return [delegate nativeWidgetMac]->bridge_.get(); |
| 94 } | 98 } |
| 95 return nullptr; // Not created by NativeWidgetMac. | 99 return nullptr; // Not created by NativeWidgetMac. |
| 96 } | 100 } |
| 97 | 101 |
| 98 bool NativeWidgetMac::IsWindowModalSheet() const { | 102 bool NativeWidgetMac::IsWindowModalSheet() const { |
| 99 return bridge_ && bridge_->parent() && | 103 return SheetsEnabled() && bridge_ && bridge_->parent() && |
| 100 GetWidget()->widget_delegate()->GetModalType() == | 104 GetWidget()->widget_delegate()->GetModalType() == |
| 101 ui::MODAL_TYPE_WINDOW; | 105 ui::MODAL_TYPE_WINDOW; |
| 102 } | 106 } |
| 103 | 107 |
| 104 void NativeWidgetMac::OnWindowDestroyed() { | 108 void NativeWidgetMac::OnWindowDestroyed() { |
| 105 DCHECK(bridge_); | 109 DCHECK(bridge_); |
| 106 bridge_.reset(); | 110 bridge_.reset(); |
| 107 delegate_->OnNativeWidgetDestroyed(); | 111 delegate_->OnNativeWidgetDestroyed(); |
| 108 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) | 112 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) |
| 109 delete this; | 113 delete this; |
| (...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 780 [[ViewsNSWindowCloseAnimator alloc] initWithWindow:window]; | 784 [[ViewsNSWindowCloseAnimator alloc] initWithWindow:window]; |
| 781 } | 785 } |
| 782 | 786 |
| 783 - (void)animationDidEnd:(NSAnimation*)animation { | 787 - (void)animationDidEnd:(NSAnimation*)animation { |
| 784 [window_ close]; | 788 [window_ close]; |
| 785 [animation_ setDelegate:nil]; | 789 [animation_ setDelegate:nil]; |
| 786 [self release]; | 790 [self release]; |
| 787 } | 791 } |
| 788 | 792 |
| 789 @end | 793 @end |
| OLD | NEW |