OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #import "chrome/browser/ui/cocoa/single_web_contents_dialog_manager_cocoa.h" | 5 #import "chrome/browser/ui/cocoa/single_web_contents_dialog_manager_cocoa.h" |
6 | 6 |
7 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sh
eet.h" | 7 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sh
eet.h" |
8 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h" | 8 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h" |
9 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_con
troller.h" | 9 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_con
troller.h" |
10 #include "components/web_modal/web_contents_modal_dialog_host.h" | 10 #include "components/web_modal/web_contents_modal_dialog_host.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 NSWindow* parent_window = | 51 NSWindow* parent_window = |
52 delegate_->GetWebContents()->GetTopLevelNativeWindow(); | 52 delegate_->GetWebContents()->GetTopLevelNativeWindow(); |
53 [[ConstrainedWindowSheetController controllerForParentWindow:parent_window] | 53 [[ConstrainedWindowSheetController controllerForParentWindow:parent_window] |
54 hideSheet]; | 54 hideSheet]; |
55 } | 55 } |
56 | 56 |
57 void SingleWebContentsDialogManagerCocoa::Close() { | 57 void SingleWebContentsDialogManagerCocoa::Close() { |
58 [[ConstrainedWindowSheetController controllerForSheet:sheet_] | 58 [[ConstrainedWindowSheetController controllerForSheet:sheet_] |
59 closeSheet:sheet_]; | 59 closeSheet:sheet_]; |
60 client_->set_manager(nullptr); | 60 client_->set_manager(nullptr); |
61 | |
62 bool dialog_was_open = client_->DialogWasShown(); | |
63 client_->OnDialogClosing(); // |client_| might delete itself here. | 61 client_->OnDialogClosing(); // |client_| might delete itself here. |
64 | 62 delegate_->WillClose(dialog()); // Deletes |this|. |
65 if (dialog_was_open) | |
66 delegate_->WillClose(dialog()); // Deletes |this|. | |
67 } | 63 } |
68 | 64 |
69 void SingleWebContentsDialogManagerCocoa::Focus() { | 65 void SingleWebContentsDialogManagerCocoa::Focus() { |
70 } | 66 } |
71 | 67 |
72 void SingleWebContentsDialogManagerCocoa::Pulse() { | 68 void SingleWebContentsDialogManagerCocoa::Pulse() { |
73 [[ConstrainedWindowSheetController controllerForSheet:sheet_] | 69 [[ConstrainedWindowSheetController controllerForSheet:sheet_] |
74 pulseSheet:sheet_]; | 70 pulseSheet:sheet_]; |
75 } | 71 } |
76 | 72 |
77 void SingleWebContentsDialogManagerCocoa::HostChanged( | 73 void SingleWebContentsDialogManagerCocoa::HostChanged( |
78 web_modal::WebContentsModalDialogHost* new_host) { | 74 web_modal::WebContentsModalDialogHost* new_host) { |
79 // No need to observe the host. For Cocoa, the constrained window controller | 75 // No need to observe the host. For Cocoa, the constrained window controller |
80 // will reposition the dialog when necessary. The host can also never change. | 76 // will reposition the dialog when necessary. The host can also never change. |
81 // Tabs showing a dialog can not be dragged off a Cocoa browser window. | 77 // Tabs showing a dialog can not be dragged off a Cocoa browser window. |
82 // However, closing a tab with a dialog open will set the host back to null. | 78 // However, closing a tab with a dialog open will set the host back to null. |
83 DCHECK_NE(!!host_, !!new_host); | 79 DCHECK_NE(!!host_, !!new_host); |
84 host_ = new_host; | 80 host_ = new_host; |
85 } | 81 } |
86 | 82 |
87 gfx::NativeWindow SingleWebContentsDialogManagerCocoa::dialog() { | 83 gfx::NativeWindow SingleWebContentsDialogManagerCocoa::dialog() { |
88 return [sheet_ sheetWindow]; | 84 return [sheet_ sheetWindow]; |
89 } | 85 } |
OLD | NEW |