license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 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 | ||||
3 | // found in the LICENSE file. | ||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4 | |
5 | #include "chrome/browser/app_modal_dialog_queue.h" | ||||
6 | |||||
7 | #include "chrome/browser/browser_list.h" | ||||
8 | |||||
9 | // static | ||||
[email protected] | c2dacc9 | 2008-10-16 23:51:38 | [diff] [blame] | 10 | std::queue<views::AppModalDialogDelegate*>* |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 11 | AppModalDialogQueue::app_modal_dialog_queue_ = NULL; |
[email protected] | b6ad1cab | 2009-01-16 22:41:42 | [diff] [blame^] | 12 | views::AppModalDialogDelegate* AppModalDialogQueue::active_dialog_ = NULL; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 13 | |
14 | // static | ||||
[email protected] | c2dacc9 | 2008-10-16 23:51:38 | [diff] [blame] | 15 | void AppModalDialogQueue::AddDialog(views::AppModalDialogDelegate* dialog) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 16 | DCHECK(dialog->IsModal()); |
17 | if (!app_modal_dialog_queue_) { | ||||
[email protected] | c2dacc9 | 2008-10-16 23:51:38 | [diff] [blame] | 18 | app_modal_dialog_queue_ = new std::queue<views::AppModalDialogDelegate*>; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 19 | ShowModalDialog(dialog); |
20 | } | ||||
21 | |||||
22 | app_modal_dialog_queue_->push(dialog); | ||||
23 | } | ||||
24 | |||||
25 | // static | ||||
26 | void AppModalDialogQueue::ShowNextDialog() { | ||||
27 | app_modal_dialog_queue_->pop(); | ||||
[email protected] | b6ad1cab | 2009-01-16 22:41:42 | [diff] [blame^] | 28 | active_dialog_ = NULL; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 29 | if (!app_modal_dialog_queue_->empty()) { |
30 | ShowModalDialog(app_modal_dialog_queue_->front()); | ||||
31 | } else { | ||||
32 | delete app_modal_dialog_queue_; | ||||
33 | app_modal_dialog_queue_ = NULL; | ||||
34 | } | ||||
35 | } | ||||
36 | |||||
37 | // static | ||||
38 | void AppModalDialogQueue::ActivateModalDialog() { | ||||
39 | if (!app_modal_dialog_queue_->empty()) | ||||
40 | app_modal_dialog_queue_->front()->ActivateModalDialog(); | ||||
41 | } | ||||
42 | |||||
43 | // static | ||||
44 | void AppModalDialogQueue::ShowModalDialog( | ||||
[email protected] | c2dacc9 | 2008-10-16 23:51:38 | [diff] [blame] | 45 | views::AppModalDialogDelegate* dialog) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 46 | dialog->ShowModalDialog(); |
[email protected] | b6ad1cab | 2009-01-16 22:41:42 | [diff] [blame^] | 47 | active_dialog_ = dialog; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 48 | } |