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] | 0bfa713f | 2009-04-07 20:18:28 | [diff] [blame] | 10 | std::queue<AppModalDialog*>* |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 11 | AppModalDialogQueue::app_modal_dialog_queue_ = NULL; |
[email protected] | 0bfa713f | 2009-04-07 20:18:28 | [diff] [blame] | 12 | AppModalDialog* AppModalDialogQueue::active_dialog_ = NULL; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 13 | |
14 | // static | ||||
[email protected] | 0bfa713f | 2009-04-07 20:18:28 | [diff] [blame] | 15 | void AppModalDialogQueue::AddDialog(AppModalDialog* dialog) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 16 | if (!app_modal_dialog_queue_) { |
[email protected] | 0bfa713f | 2009-04-07 20:18:28 | [diff] [blame] | 17 | app_modal_dialog_queue_ = new std::queue<AppModalDialog*>; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 18 | ShowModalDialog(dialog); |
19 | } | ||||
20 | |||||
[email protected] | a91ba0e | 2009-04-06 23:10:37 | [diff] [blame] | 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); | ||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 25 | } |
26 | |||||
27 | // static | ||||
28 | void AppModalDialogQueue::ShowNextDialog() { | ||||
29 | app_modal_dialog_queue_->pop(); | ||||
[email protected] | b6ad1cab | 2009-01-16 22:41:42 | [diff] [blame] | 30 | active_dialog_ = NULL; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 31 | if (!app_modal_dialog_queue_->empty()) { |
32 | ShowModalDialog(app_modal_dialog_queue_->front()); | ||||
33 | } else { | ||||
34 | delete app_modal_dialog_queue_; | ||||
35 | app_modal_dialog_queue_ = NULL; | ||||
36 | } | ||||
37 | } | ||||
38 | |||||
39 | // static | ||||
40 | void AppModalDialogQueue::ActivateModalDialog() { | ||||
41 | if (!app_modal_dialog_queue_->empty()) | ||||
42 | app_modal_dialog_queue_->front()->ActivateModalDialog(); | ||||
43 | } | ||||
44 | |||||
45 | // static | ||||
[email protected] | 0bfa713f | 2009-04-07 20:18:28 | [diff] [blame] | 46 | void AppModalDialogQueue::ShowModalDialog(AppModalDialog* dialog) { |
[email protected] | a91ba0e | 2009-04-06 23:10:37 | [diff] [blame] | 47 | // ShowModalDialog can wind up calling ShowNextDialog in some cases, |
48 | // which will wind up calling this method recursively, so active_dialog_ | ||||
49 | // must be set first. | ||||
[email protected] | b6ad1cab | 2009-01-16 22:41:42 | [diff] [blame] | 50 | active_dialog_ = dialog; |
[email protected] | a91ba0e | 2009-04-06 23:10:37 | [diff] [blame] | 51 | dialog->ShowModalDialog(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 52 | } |