Chromium Code Reviews| 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 if (!skip_this_dialog_) { |
| 114 delegate_->OnMessageBoxClosed(reply_msg_, false, std::wstring()); | 114 delegate_->OnMessageBoxClosed(reply_msg_, false, std::wstring()); |
| 115 if (suppress_js_messages) | 115 if (suppress_js_messages) |
| 116 delegate_->SetSuppressMessageBoxes(true); | 116 delegate_->SetSuppressMessageBoxes(true); |
| 117 } | 117 } |
| 118 | |
| 119 Cleanup(); | |
| 120 } | 118 } |
| 121 | 119 |
| 122 void JavaScriptAppModalDialog::OnAccept(const std::wstring& prompt_text, | 120 void JavaScriptAppModalDialog::OnAccept(const std::wstring& prompt_text, |
| 123 bool suppress_js_messages) { | 121 bool suppress_js_messages) { |
| 124 CompleteDialog(); | 122 CompleteDialog(); |
| 125 | 123 |
| 126 if (!skip_this_dialog_) { | 124 if (!skip_this_dialog_) { |
|
Matt Perry
2010/12/03 00:39:22
maybe this block is what should go into Cleanup.
| |
| 127 delegate_->OnMessageBoxClosed(reply_msg_, true, prompt_text); | 125 delegate_->OnMessageBoxClosed(reply_msg_, true, prompt_text); |
| 128 if (suppress_js_messages) | 126 if (suppress_js_messages) |
| 129 delegate_->SetSuppressMessageBoxes(true); | 127 delegate_->SetSuppressMessageBoxes(true); |
| 130 } | 128 } |
| 131 | |
| 132 Cleanup(); | |
| 133 } | 129 } |
| 134 | 130 |
| 135 void JavaScriptAppModalDialog::OnClose() { | 131 void JavaScriptAppModalDialog::OnClose() { |
| 136 Cleanup(); | 132 if (!skip_this_dialog_) { |
| 137 } | 133 delegate_->OnMessageBoxClosed(reply_msg_, true, L""); |
| 138 | 134 // TODO(aa): It would be good to handle supress here, too, but we need to |
| 139 void JavaScriptAppModalDialog::Cleanup() { | 135 // get passed the bit. |
| 140 if (skip_this_dialog_) { | |
| 141 // We can't use the |delegate_|, because we might be in the process of | |
| 142 // destroying it. | |
| 143 if (tab_contents_) | |
| 144 tab_contents_->OnMessageBoxClosed(reply_msg_, false, L""); | |
| 145 // The extension_host_ will always be a dirty pointer on OS X because the alert | |
| 146 // window will cause the extension popup to close since it is resigning its key | |
| 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 } | 136 } |
| 155 } | 137 } |
| OLD | NEW |