| 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/app_modal_dialog_queue.h" | 5 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" |
| 6 | 6 |
| 7 void AppModalDialogQueue::AddDialog(AppModalDialog* dialog) { | 7 void AppModalDialogQueue::AddDialog(AppModalDialog* dialog) { |
| 8 if (!active_dialog_) { | 8 if (!active_dialog_) { |
| 9 ShowModalDialog(dialog); | 9 ShowModalDialog(dialog); |
| 10 return; | 10 return; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 if (active_dialog_) | 31 if (active_dialog_) |
| 32 active_dialog_->ActivateModalDialog(); | 32 active_dialog_->ActivateModalDialog(); |
| 33 } | 33 } |
| 34 | 34 |
| 35 AppModalDialogQueue::AppModalDialogQueue() | 35 AppModalDialogQueue::AppModalDialogQueue() |
| 36 : active_dialog_(NULL), showing_modal_dialog_(false) { | 36 : active_dialog_(NULL), showing_modal_dialog_(false) { |
| 37 } | 37 } |
| 38 | 38 |
| 39 AppModalDialogQueue::~AppModalDialogQueue() {} | 39 AppModalDialogQueue::~AppModalDialogQueue() {} |
| 40 | 40 |
| 41 // static |
| 42 AppModalDialogQueue* AppModalDialogQueue::GetInstance() { |
| 43 return Singleton<AppModalDialogQueue>::get(); |
| 44 } |
| 45 |
| 41 void AppModalDialogQueue::ShowModalDialog(AppModalDialog* dialog) { | 46 void AppModalDialogQueue::ShowModalDialog(AppModalDialog* dialog) { |
| 42 // Be sure and set the active_dialog_ field first, otherwise if | 47 // Be sure and set the active_dialog_ field first, otherwise if |
| 43 // ShowModalDialog triggers a call back to the queue they'll get the old | 48 // ShowModalDialog triggers a call back to the queue they'll get the old |
| 44 // dialog. Also, if the dialog calls |ShowNextDialog()| before returning, that | 49 // dialog. Also, if the dialog calls |ShowNextDialog()| before returning, that |
| 45 // would write NULL into |active_dialog_| and this function would then undo | 50 // would write NULL into |active_dialog_| and this function would then undo |
| 46 // that. | 51 // that. |
| 47 active_dialog_ = dialog; | 52 active_dialog_ = dialog; |
| 48 showing_modal_dialog_ = true; | 53 showing_modal_dialog_ = true; |
| 49 dialog->ShowModalDialog(); | 54 dialog->ShowModalDialog(); |
| 50 showing_modal_dialog_ = false; | 55 showing_modal_dialog_ = false; |
| 51 } | 56 } |
| 52 | 57 |
| 53 AppModalDialog* AppModalDialogQueue::GetNextDialog() { | 58 AppModalDialog* AppModalDialogQueue::GetNextDialog() { |
| 54 while (!app_modal_dialog_queue_.empty()) { | 59 while (!app_modal_dialog_queue_.empty()) { |
| 55 AppModalDialog* dialog = app_modal_dialog_queue_.front(); | 60 AppModalDialog* dialog = app_modal_dialog_queue_.front(); |
| 56 app_modal_dialog_queue_.pop(); | 61 app_modal_dialog_queue_.pop(); |
| 57 if (dialog->IsValid()) | 62 if (dialog->IsValid()) |
| 58 return dialog; | 63 return dialog; |
| 59 delete dialog; | 64 delete dialog; |
| 60 } | 65 } |
| 61 return NULL; | 66 return NULL; |
| 62 } | 67 } |
| OLD | NEW |