| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/app_modal_dialog_queue.h" | 5 #include "chrome/browser/app_modal_dialog_queue.h" |
| 6 | 6 |
| 7 #include "chrome/browser/browser_list.h" | 7 #include "chrome/browser/browser_list.h" |
| 8 | 8 |
| 9 // static | |
| 10 std::queue<AppModalDialog*>* | |
| 11 AppModalDialogQueue::app_modal_dialog_queue_ = NULL; | |
| 12 AppModalDialog* AppModalDialogQueue::active_dialog_ = NULL; | |
| 13 | |
| 14 // static | |
| 15 void AppModalDialogQueue::AddDialog(AppModalDialog* dialog) { | 9 void AppModalDialogQueue::AddDialog(AppModalDialog* dialog) { |
| 16 if (!app_modal_dialog_queue_) { | 10 if (!active_dialog_) { |
| 17 app_modal_dialog_queue_ = new std::queue<AppModalDialog*>; | |
| 18 ShowModalDialog(dialog); | 11 ShowModalDialog(dialog); |
| 12 return; |
| 19 } | 13 } |
| 20 | 14 app_modal_dialog_queue_.push(dialog); |
| 21 // ShowModalDialog can wind up calling ShowNextDialog in some cases, which | |
| 22 // can then make app_modal_dialog_queue_ NULL. | |
| 23 if (app_modal_dialog_queue_) | |
| 24 app_modal_dialog_queue_->push(dialog); | |
| 25 } | 15 } |
| 26 | 16 |
| 27 // static | |
| 28 void AppModalDialogQueue::ShowNextDialog() { | 17 void AppModalDialogQueue::ShowNextDialog() { |
| 29 app_modal_dialog_queue_->pop(); | 18 if (!app_modal_dialog_queue_.empty()) { |
| 30 active_dialog_ = NULL; | 19 AppModalDialog* dialog = app_modal_dialog_queue_.front(); |
| 31 if (!app_modal_dialog_queue_->empty()) { | 20 app_modal_dialog_queue_.pop(); |
| 32 ShowModalDialog(app_modal_dialog_queue_->front()); | 21 ShowModalDialog(dialog); |
| 33 } else { | 22 } else { |
| 34 delete app_modal_dialog_queue_; | 23 active_dialog_ = NULL; |
| 35 app_modal_dialog_queue_ = NULL; | |
| 36 } | 24 } |
| 37 } | 25 } |
| 38 | 26 |
| 39 // static | |
| 40 void AppModalDialogQueue::ActivateModalDialog() { | 27 void AppModalDialogQueue::ActivateModalDialog() { |
| 41 if (!app_modal_dialog_queue_->empty()) | 28 if (active_dialog_) |
| 42 app_modal_dialog_queue_->front()->ActivateModalDialog(); | 29 active_dialog_->ActivateModalDialog(); |
| 43 } | 30 } |
| 44 | 31 |
| 45 // static | |
| 46 void AppModalDialogQueue::ShowModalDialog(AppModalDialog* dialog) { | 32 void AppModalDialogQueue::ShowModalDialog(AppModalDialog* dialog) { |
| 47 // ShowModalDialog can wind up calling ShowNextDialog in some cases, | 33 dialog->ShowModalDialog(); |
| 48 // which will wind up calling this method recursively, so active_dialog_ | |
| 49 // must be set first. | |
| 50 active_dialog_ = dialog; | 34 active_dialog_ = dialog; |
| 51 dialog->ShowModalDialog(); | |
| 52 } | 35 } |
| OLD | NEW |