| 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 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 if (prompt_override) | 261 if (prompt_override) |
| 262 dialog->SetOverridePromptText(*prompt_override); | 262 dialog->SetOverridePromptText(*prompt_override); |
| 263 dialog->native_dialog()->AcceptAppModalDialog(); | 263 dialog->native_dialog()->AcceptAppModalDialog(); |
| 264 } else { | 264 } else { |
| 265 dialog->native_dialog()->CancelAppModalDialog(); | 265 dialog->native_dialog()->CancelAppModalDialog(); |
| 266 } | 266 } |
| 267 return true; | 267 return true; |
| 268 } | 268 } |
| 269 | 269 |
| 270 void JavaScriptDialogManager::CancelDialogs(content::WebContents* web_contents, | 270 void JavaScriptDialogManager::CancelDialogs(content::WebContents* web_contents, |
| 271 bool suppress_callbacks, | |
| 272 bool reset_state) { | 271 bool reset_state) { |
| 273 AppModalDialogQueue* queue = AppModalDialogQueue::GetInstance(); | 272 AppModalDialogQueue* queue = AppModalDialogQueue::GetInstance(); |
| 274 AppModalDialog* active_dialog = queue->active_dialog(); | 273 AppModalDialog* active_dialog = queue->active_dialog(); |
| 275 for (AppModalDialogQueue::iterator i = queue->begin(); | 274 for (AppModalDialogQueue::iterator i = queue->begin(); |
| 276 i != queue->end(); ++i) { | 275 i != queue->end(); ++i) { |
| 277 // Invalidating the active dialog might trigger showing a not-yet | 276 // Invalidating the active dialog might trigger showing a not-yet |
| 278 // invalidated dialog, so invalidate the active dialog last. | 277 // invalidated dialog, so invalidate the active dialog last. |
| 279 if ((*i) == active_dialog) | 278 if ((*i) == active_dialog) |
| 280 continue; | 279 continue; |
| 281 if ((*i)->web_contents() == web_contents) | 280 if ((*i)->web_contents() == web_contents) |
| 282 (*i)->Invalidate(suppress_callbacks); | 281 (*i)->Invalidate(); |
| 283 } | 282 } |
| 284 if (active_dialog && active_dialog->web_contents() == web_contents) | 283 if (active_dialog && active_dialog->web_contents() == web_contents) |
| 285 active_dialog->Invalidate(suppress_callbacks); | 284 active_dialog->Invalidate(); |
| 286 | 285 |
| 287 if (reset_state) | 286 if (reset_state) |
| 288 javascript_dialog_extra_data_.erase(web_contents); | 287 javascript_dialog_extra_data_.erase(web_contents); |
| 289 } | 288 } |
| 290 | 289 |
| 291 void JavaScriptDialogManager::OnBeforeUnloadDialogClosed( | 290 void JavaScriptDialogManager::OnBeforeUnloadDialogClosed( |
| 292 content::WebContents* web_contents, | 291 content::WebContents* web_contents, |
| 293 DialogClosedCallback callback, | 292 DialogClosedCallback callback, |
| 294 bool success, | 293 bool success, |
| 295 const base::string16& user_input) { | 294 const base::string16& user_input) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 315 // lazy background page after the dialog closes. (Dialogs are closed before | 314 // lazy background page after the dialog closes. (Dialogs are closed before |
| 316 // their WebContents is destroyed so |web_contents| is still valid here.) | 315 // their WebContents is destroyed so |web_contents| is still valid here.) |
| 317 extensions_client_->OnDialogClosed(web_contents); | 316 extensions_client_->OnDialogClosed(web_contents); |
| 318 | 317 |
| 319 last_close_time_ = base::TimeTicks::Now(); | 318 last_close_time_ = base::TimeTicks::Now(); |
| 320 | 319 |
| 321 callback.Run(success, user_input); | 320 callback.Run(success, user_input); |
| 322 } | 321 } |
| 323 | 322 |
| 324 } // namespace app_modal | 323 } // namespace app_modal |
| OLD | NEW |