OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/ui/app_modal_dialogs/js_modal_dialog.h" | 5 #include "chrome/browser/ui/app_modal_dialogs/js_modal_dialog.h" |
6 | 6 |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "chrome/browser/browser_shutdown.h" | 8 #include "chrome/browser/browser_shutdown.h" |
9 #include "chrome/browser/extensions/extension_host.h" | 9 #include "chrome/browser/extensions/extension_host.h" |
10 #include "chrome/browser/tab_contents/tab_contents.h" | 10 #include "chrome/browser/tab_contents/tab_contents.h" |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 browser_shutdown::SetTryingToQuit(false); | 103 browser_shutdown::SetTryingToQuit(false); |
104 | 104 |
105 // We need to do this before WM_DESTROY (WindowClosing()) as any parent frame | 105 // We need to do this before WM_DESTROY (WindowClosing()) as any parent frame |
106 // will receive its activation messages before this dialog receives | 106 // will receive its activation messages before this dialog receives |
107 // WM_DESTROY. The parent frame would then try to activate any modal dialogs | 107 // WM_DESTROY. The parent frame would then try to activate any modal dialogs |
108 // that were still open in the ModalDialogQueue, which would send activation | 108 // that were still open in the ModalDialogQueue, which would send activation |
109 // back to this one. The framework should be improved to handle this, so this | 109 // back to this one. The framework should be improved to handle this, so this |
110 // is a temporary workaround. | 110 // is a temporary workaround. |
111 CompleteDialog(); | 111 CompleteDialog(); |
112 | 112 |
113 if (!skip_this_dialog_) { | 113 UpdateDelegate(false, L"", suppress_js_messages); |
114 delegate_->OnMessageBoxClosed(reply_msg_, false, std::wstring()); | |
115 if (suppress_js_messages) | |
116 delegate_->SetSuppressMessageBoxes(true); | |
117 } | |
118 | |
119 Cleanup(); | |
120 } | 114 } |
121 | 115 |
122 void JavaScriptAppModalDialog::OnAccept(const std::wstring& prompt_text, | 116 void JavaScriptAppModalDialog::OnAccept(const std::wstring& prompt_text, |
123 bool suppress_js_messages) { | 117 bool suppress_js_messages) { |
124 CompleteDialog(); | 118 CompleteDialog(); |
125 | 119 UpdateDelegate(true, prompt_text, suppress_js_messages); |
126 if (!skip_this_dialog_) { | |
127 delegate_->OnMessageBoxClosed(reply_msg_, true, prompt_text); | |
128 if (suppress_js_messages) | |
129 delegate_->SetSuppressMessageBoxes(true); | |
130 } | |
131 | |
132 Cleanup(); | |
133 } | 120 } |
134 | 121 |
135 void JavaScriptAppModalDialog::OnClose() { | 122 void JavaScriptAppModalDialog::OnClose() { |
136 Cleanup(); | 123 // Should we be handling suppress here too? See crbug.com/65008. |
| 124 UpdateDelegate(false, L"", false); |
137 } | 125 } |
138 | 126 |
139 void JavaScriptAppModalDialog::Cleanup() { | 127 void JavaScriptAppModalDialog::UpdateDelegate(bool success, |
140 if (skip_this_dialog_) { | 128 const std::wstring& prompt_text, |
141 // We can't use the |delegate_|, because we might be in the process of | 129 bool suppress_js_messages) { |
142 // destroying it. | 130 if (skip_this_dialog_) |
143 if (tab_contents_) | 131 return; |
144 tab_contents_->OnMessageBoxClosed(reply_msg_, false, L""); | 132 |
145 // The extension_host_ will always be a dirty pointer on OS X because the alert | 133 delegate_->OnMessageBoxClosed(reply_msg_, success, prompt_text); |
146 // window will cause the extension popup to close since it is resigning its key | 134 if (suppress_js_messages) |
147 // state, destroying the host. http://crbug.com/29355 | 135 delegate_->SetSuppressMessageBoxes(true); |
148 #if !defined(OS_MACOSX) | |
149 else if (extension_host_) | |
150 extension_host_->OnMessageBoxClosed(reply_msg_, false, L""); | |
151 else | |
152 NOTREACHED(); | |
153 #endif | |
154 } | |
155 } | 136 } |
OLD | NEW |