| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/app_modal_dialog_queue.h" | 5 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" |
| 6 | 6 |
| 7 #include "base/memory/singleton.h" | 7 #include "base/memory/singleton.h" |
| 8 | 8 |
| 9 void AppModalDialogQueue::AddDialog(AppModalDialog* dialog) { | 9 void AppModalDialogQueue::AddDialog(AppModalDialog* dialog) { |
| 10 if (!active_dialog_) { | 10 if (!active_dialog_) { |
| 11 ShowModalDialog(dialog); | 11 ShowModalDialog(dialog); |
| 12 return; | 12 return; |
| 13 } | 13 } |
| 14 app_modal_dialog_queue_.push_back(dialog); | 14 app_modal_dialog_queue_.push_back(dialog); |
| 15 } | 15 } |
| 16 | 16 |
| 17 void AppModalDialogQueue::ShowNextDialog() { | 17 void AppModalDialogQueue::ShowNextDialog() { |
| 18 AppModalDialog* dialog = GetNextDialog(); | 18 AppModalDialog* dialog = GetNextDialog(); |
| 19 if (dialog) | 19 if (dialog) |
| 20 ShowModalDialog(dialog); | 20 ShowModalDialog(dialog); |
| 21 else | 21 else |
| 22 active_dialog_ = NULL; | 22 active_dialog_ = NULL; |
| 23 } | 23 } |
| 24 | 24 |
| 25 void AppModalDialogQueue::ActivateModalDialog() { | 25 void AppModalDialogQueue::ActivateModalDialog() { |
| 26 if (showing_modal_dialog_) { | 26 if (showing_modal_dialog_) { |
| 27 // As part of showing a modal dialog we may end up back in this method | 27 // As part of showing a modal dialog we may end up back in this method |
| 28 // (showing a dialog activates the TabContents, which can trigger a call | 28 // (showing a dialog activates the WebContents, which can trigger a call |
| 29 // to ActivateModalDialog). We ignore such a request as after the call to | 29 // to ActivateModalDialog). We ignore such a request as after the call to |
| 30 // activate the tab contents the dialog is shown. | 30 // activate the tab contents the dialog is shown. |
| 31 return; | 31 return; |
| 32 } | 32 } |
| 33 if (active_dialog_) | 33 if (active_dialog_) |
| 34 active_dialog_->ActivateModalDialog(); | 34 active_dialog_->ActivateModalDialog(); |
| 35 } | 35 } |
| 36 | 36 |
| 37 AppModalDialogQueue::AppModalDialogQueue() | 37 AppModalDialogQueue::AppModalDialogQueue() |
| 38 : active_dialog_(NULL), showing_modal_dialog_(false) { | 38 : active_dialog_(NULL), showing_modal_dialog_(false) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 60 AppModalDialog* AppModalDialogQueue::GetNextDialog() { | 60 AppModalDialog* AppModalDialogQueue::GetNextDialog() { |
| 61 while (!app_modal_dialog_queue_.empty()) { | 61 while (!app_modal_dialog_queue_.empty()) { |
| 62 AppModalDialog* dialog = app_modal_dialog_queue_.front(); | 62 AppModalDialog* dialog = app_modal_dialog_queue_.front(); |
| 63 app_modal_dialog_queue_.pop_front(); | 63 app_modal_dialog_queue_.pop_front(); |
| 64 if (dialog->IsValid()) | 64 if (dialog->IsValid()) |
| 65 return dialog; | 65 return dialog; |
| 66 delete dialog; | 66 delete dialog; |
| 67 } | 67 } |
| 68 return NULL; | 68 return NULL; |
| 69 } | 69 } |
| OLD | NEW |