Index: ui/views/widget/native_widget_mac.mm |
diff --git a/ui/views/widget/native_widget_mac.mm b/ui/views/widget/native_widget_mac.mm |
index 20db395761ee684482da88635be05860871c89e4..3e4383020924455ce719aeaf10fc0caaa386b31a 100644 |
--- a/ui/views/widget/native_widget_mac.mm |
+++ b/ui/views/widget/native_widget_mac.mm |
@@ -251,7 +251,13 @@ void NativeWidgetMac::SetWindowIcons(const gfx::ImageSkia& window_icon, |
} |
void NativeWidgetMac::InitModalType(ui::ModalType modal_type) { |
- NOTIMPLEMENTED(); |
+ if (modal_type == ui::MODAL_TYPE_NONE) |
+ return; |
+ |
+ // System modal windows not implemented (or used) on Mac. |
+ DCHECK_NE(ui::MODAL_TYPE_SYSTEM, modal_type); |
+ DCHECK(bridge_->parent()); |
+ // Everyhing happens upon show. |
} |
gfx::Rect NativeWidgetMac::GetWindowBoundsInScreen() const { |
@@ -299,6 +305,17 @@ void NativeWidgetMac::Close() { |
if (!bridge_) |
return; |
+ if (delegate_->IsModal()) { |
+ // Sheets can't be closed normally. This starts the sheet closing. Once the |
+ // sheet has finished animating, it will call sheetDidEnd: on the parent |
+ // window's delegate. Note it still needs to be asynchronous, since code |
+ // calling Widget::Close() doesn't expect things to be deleted upon return. |
+ [NSApp performSelector:@selector(endSheet:) |
+ withObject:GetNativeWindow() |
+ afterDelay:0]; |
+ return; |
+ } |
+ |
// Clear the view early to suppress repaints. |
bridge_->SetRootView(NULL); |