OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/app_modal/javascript_dialog_manager.h" | 5 #include "components/app_modal/javascript_dialog_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 bool JavaScriptDialogManager::HandleJavaScriptDialog( | 241 bool JavaScriptDialogManager::HandleJavaScriptDialog( |
242 content::WebContents* web_contents, | 242 content::WebContents* web_contents, |
243 bool accept, | 243 bool accept, |
244 const base::string16* prompt_override) { | 244 const base::string16* prompt_override) { |
245 AppModalDialogQueue* dialog_queue = AppModalDialogQueue::GetInstance(); | 245 AppModalDialogQueue* dialog_queue = AppModalDialogQueue::GetInstance(); |
246 if (!dialog_queue->HasActiveDialog() || | 246 if (!dialog_queue->HasActiveDialog() || |
247 !dialog_queue->active_dialog()->IsJavaScriptModalDialog() || | 247 !dialog_queue->active_dialog()->IsJavaScriptModalDialog() || |
248 dialog_queue->active_dialog()->web_contents() != web_contents) { | 248 dialog_queue->active_dialog()->web_contents() != web_contents) { |
249 return false; | 249 return false; |
250 } | 250 } |
| 251 |
251 JavaScriptAppModalDialog* dialog = static_cast<JavaScriptAppModalDialog*>( | 252 JavaScriptAppModalDialog* dialog = static_cast<JavaScriptAppModalDialog*>( |
252 dialog_queue->active_dialog()); | 253 dialog_queue->active_dialog()); |
| 254 |
| 255 if (dialog->javascript_dialog_type() == |
| 256 content::JavaScriptDialogType::JAVASCRIPT_DIALOG_TYPE_ALERT) { |
| 257 // Alert dialogs only have one button: OK. Any "handling" of this dialog has |
| 258 // to be a click on the OK button. |
| 259 accept = true; |
| 260 } |
| 261 |
253 if (accept) { | 262 if (accept) { |
254 if (prompt_override) | 263 if (prompt_override) |
255 dialog->SetOverridePromptText(*prompt_override); | 264 dialog->SetOverridePromptText(*prompt_override); |
256 dialog->native_dialog()->AcceptAppModalDialog(); | 265 dialog->native_dialog()->AcceptAppModalDialog(); |
257 } else { | 266 } else { |
258 dialog->native_dialog()->CancelAppModalDialog(); | 267 dialog->native_dialog()->CancelAppModalDialog(); |
259 } | 268 } |
260 return true; | 269 return true; |
261 } | 270 } |
262 | 271 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 // lazy background page after the dialog closes. (Dialogs are closed before | 316 // lazy background page after the dialog closes. (Dialogs are closed before |
308 // their WebContents is destroyed so |web_contents| is still valid here.) | 317 // their WebContents is destroyed so |web_contents| is still valid here.) |
309 extensions_client_->OnDialogClosed(web_contents); | 318 extensions_client_->OnDialogClosed(web_contents); |
310 | 319 |
311 last_close_time_ = base::TimeTicks::Now(); | 320 last_close_time_ = base::TimeTicks::Now(); |
312 | 321 |
313 callback.Run(success, user_input); | 322 callback.Run(success, user_input); |
314 } | 323 } |
315 | 324 |
316 } // namespace app_modal | 325 } // namespace app_modal |
OLD | NEW |