| 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/js_modal_dialog.h" | 5 #include "chrome/browser/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/native_app_modal_dialog.h" | 10 #include "chrome/browser/native_app_modal_dialog.h" | 
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 102   if (is_before_unload_dialog_) | 102   if (is_before_unload_dialog_) | 
| 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   UpdateDelegate(false, L"", suppress_js_messages); | 112 | 
|  | 113   if (!skip_this_dialog_) { | 
|  | 114     delegate_->OnMessageBoxClosed(reply_msg_, false, std::wstring()); | 
|  | 115     if (suppress_js_messages) | 
|  | 116       delegate_->SetSuppressMessageBoxes(true); | 
|  | 117   } | 
|  | 118 | 
|  | 119   Cleanup(); | 
| 113 } | 120 } | 
| 114 | 121 | 
| 115 void JavaScriptAppModalDialog::OnAccept(const std::wstring& prompt_text, | 122 void JavaScriptAppModalDialog::OnAccept(const std::wstring& prompt_text, | 
| 116                                         bool suppress_js_messages) { | 123                                         bool suppress_js_messages) { | 
| 117   CompleteDialog(); | 124   CompleteDialog(); | 
| 118   UpdateDelegate(true, prompt_text, suppress_js_messages); | 125 | 
|  | 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(); | 
| 119 } | 133 } | 
| 120 | 134 | 
| 121 void JavaScriptAppModalDialog::OnClose() { | 135 void JavaScriptAppModalDialog::OnClose() { | 
| 122   // Should we be handling suppress here too? See crbug.com/65008. | 136   Cleanup(); | 
| 123   UpdateDelegate(false, L"", false); |  | 
| 124 } | 137 } | 
| 125 | 138 | 
| 126 void JavaScriptAppModalDialog::UpdateDelegate(bool success, | 139 void JavaScriptAppModalDialog::Cleanup() { | 
| 127                                               const std::wstring& prompt_text, | 140   if (skip_this_dialog_) { | 
| 128                                               bool suppress_js_messages) { | 141     // We can't use the |delegate_|, because we might be in the process of | 
| 129   if (skip_this_dialog_) | 142     // destroying it. | 
| 130     return; | 143     if (tab_contents_) | 
| 131 | 144       tab_contents_->OnMessageBoxClosed(reply_msg_, false, L""); | 
| 132   delegate_->OnMessageBoxClosed(reply_msg_, success, prompt_text); | 145 // The extension_host_ will always be a dirty pointer on OS X because the alert | 
| 133   if (suppress_js_messages) | 146 // window will cause the extension popup to close since it is resigning its key | 
| 134     delegate_->SetSuppressMessageBoxes(true); | 147 // state, destroying the host. http://crbug.com/29355 | 
|  | 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   } | 
| 135 } | 155 } | 
| OLD | NEW | 
|---|