diff options
-rw-r--r-- | chrome/browser/app_modal_dialog_queue.cc | 16 | ||||
-rw-r--r-- | chrome/browser/app_modal_dialog_queue.h | 6 |
2 files changed, 20 insertions, 2 deletions
diff --git a/chrome/browser/app_modal_dialog_queue.cc b/chrome/browser/app_modal_dialog_queue.cc index 3d4f2da..bcf1859 100644 --- a/chrome/browser/app_modal_dialog_queue.cc +++ b/chrome/browser/app_modal_dialog_queue.cc @@ -23,13 +23,27 @@ void AppModalDialogQueue::ShowNextDialog() { } void AppModalDialogQueue::ActivateModalDialog() { + if (showing_modal_dialog_) { + // As part of showing a modal dialog we may end up back in this method + // (showing a dialog activates the TabContents, which can trigger a call + // to ActivateModalDialog). We ignore such a request as after the call to + // activate the tab contents the dialog is shown. + return; + } if (active_dialog_) active_dialog_->ActivateModalDialog(); } void AppModalDialogQueue::ShowModalDialog(AppModalDialog* dialog) { - dialog->ShowModalDialog(); + // Be sure and set the active_dialog_ field first, otherwise if + // ShowModalDialog triggers a call back to the queue they'll get the old + // dialog. Also, if the dialog calls |ShowNextDialog()| before returning, that + // would write NULL into |active_dialog_| and this function would then undo + // that. active_dialog_ = dialog; + showing_modal_dialog_ = true; + dialog->ShowModalDialog(); + showing_modal_dialog_ = false; } AppModalDialog* AppModalDialogQueue::GetNextDialog() { diff --git a/chrome/browser/app_modal_dialog_queue.h b/chrome/browser/app_modal_dialog_queue.h index 66ba3ff..b9709b3 100644 --- a/chrome/browser/app_modal_dialog_queue.h +++ b/chrome/browser/app_modal_dialog_queue.h @@ -54,7 +54,7 @@ class AppModalDialogQueue { private: friend struct DefaultSingletonTraits<AppModalDialogQueue>; - AppModalDialogQueue() : active_dialog_(NULL) {} + AppModalDialogQueue() : active_dialog_(NULL), showing_modal_dialog_(false) {} // Shows |dialog| and notifies the BrowserList that a modal dialog is showing. void ShowModalDialog(AppModalDialog* dialog); @@ -73,6 +73,10 @@ class AppModalDialogQueue { // active app-modal dialog box. AppModalDialog* active_dialog_; + // Stores if |ShowModalDialog()| is currently being called on an app-modal + // dialog. + bool showing_modal_dialog_; + DISALLOW_COPY_AND_ASSIGN(AppModalDialogQueue); }; |