| 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 | 9 // static |
| 10 std::queue<views::AppModalDialogDelegate*>* | 10 std::queue<AppModalDialog*>* |
| 11 AppModalDialogQueue::app_modal_dialog_queue_ = NULL; | 11 AppModalDialogQueue::app_modal_dialog_queue_ = NULL; |
| 12 views::AppModalDialogDelegate* AppModalDialogQueue::active_dialog_ = NULL; | 12 AppModalDialog* AppModalDialogQueue::active_dialog_ = NULL; |
| 13 | 13 |
| 14 // static | 14 // static |
| 15 void AppModalDialogQueue::AddDialog(views::AppModalDialogDelegate* dialog) { | 15 void AppModalDialogQueue::AddDialog(AppModalDialog* dialog) { |
| 16 DCHECK(dialog->IsModal()); | |
| 17 if (!app_modal_dialog_queue_) { | 16 if (!app_modal_dialog_queue_) { |
| 18 app_modal_dialog_queue_ = new std::queue<views::AppModalDialogDelegate*>; | 17 app_modal_dialog_queue_ = new std::queue<AppModalDialog*>; |
| 19 ShowModalDialog(dialog); | 18 ShowModalDialog(dialog); |
| 20 } | 19 } |
| 21 | 20 |
| 22 // ShowModalDialog can wind up calling ShowNextDialog in some cases, which | 21 // ShowModalDialog can wind up calling ShowNextDialog in some cases, which |
| 23 // can then make app_modal_dialog_queue_ NULL. | 22 // can then make app_modal_dialog_queue_ NULL. |
| 24 if (app_modal_dialog_queue_) | 23 if (app_modal_dialog_queue_) |
| 25 app_modal_dialog_queue_->push(dialog); | 24 app_modal_dialog_queue_->push(dialog); |
| 26 } | 25 } |
| 27 | 26 |
| 28 // static | 27 // static |
| 29 void AppModalDialogQueue::ShowNextDialog() { | 28 void AppModalDialogQueue::ShowNextDialog() { |
| 30 app_modal_dialog_queue_->pop(); | 29 app_modal_dialog_queue_->pop(); |
| 31 active_dialog_ = NULL; | 30 active_dialog_ = NULL; |
| 32 if (!app_modal_dialog_queue_->empty()) { | 31 if (!app_modal_dialog_queue_->empty()) { |
| 33 ShowModalDialog(app_modal_dialog_queue_->front()); | 32 ShowModalDialog(app_modal_dialog_queue_->front()); |
| 34 } else { | 33 } else { |
| 35 delete app_modal_dialog_queue_; | 34 delete app_modal_dialog_queue_; |
| 36 app_modal_dialog_queue_ = NULL; | 35 app_modal_dialog_queue_ = NULL; |
| 37 } | 36 } |
| 38 } | 37 } |
| 39 | 38 |
| 40 // static | 39 // static |
| 41 void AppModalDialogQueue::ActivateModalDialog() { | 40 void AppModalDialogQueue::ActivateModalDialog() { |
| 42 if (!app_modal_dialog_queue_->empty()) | 41 if (!app_modal_dialog_queue_->empty()) |
| 43 app_modal_dialog_queue_->front()->ActivateModalDialog(); | 42 app_modal_dialog_queue_->front()->ActivateModalDialog(); |
| 44 } | 43 } |
| 45 | 44 |
| 46 // static | 45 // static |
| 47 void AppModalDialogQueue::ShowModalDialog( | 46 void AppModalDialogQueue::ShowModalDialog(AppModalDialog* dialog) { |
| 48 views::AppModalDialogDelegate* dialog) { | |
| 49 // ShowModalDialog can wind up calling ShowNextDialog in some cases, | 47 // ShowModalDialog can wind up calling ShowNextDialog in some cases, |
| 50 // which will wind up calling this method recursively, so active_dialog_ | 48 // which will wind up calling this method recursively, so active_dialog_ |
| 51 // must be set first. | 49 // must be set first. |
| 52 active_dialog_ = dialog; | 50 active_dialog_ = dialog; |
| 53 dialog->ShowModalDialog(); | 51 dialog->ShowModalDialog(); |
| 54 } | 52 } |
| OLD | NEW |