blob: e24a7b0474a1a625a6e51ea31aec0c606dc8eb64 [file] [log] [blame]
license.botbf09a502008-08-24 00:55:551// 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.commit09911bf2008-07-26 23:55:294
5#include "chrome/browser/app_modal_dialog_queue.h"
6
7#include "chrome/browser/browser_list.h"
8
9// static
[email protected]0bfa713f2009-04-07 20:18:2810std::queue<AppModalDialog*>*
initial.commit09911bf2008-07-26 23:55:2911 AppModalDialogQueue::app_modal_dialog_queue_ = NULL;
[email protected]0bfa713f2009-04-07 20:18:2812AppModalDialog* AppModalDialogQueue::active_dialog_ = NULL;
initial.commit09911bf2008-07-26 23:55:2913
14// static
[email protected]0bfa713f2009-04-07 20:18:2815void AppModalDialogQueue::AddDialog(AppModalDialog* dialog) {
initial.commit09911bf2008-07-26 23:55:2916 if (!app_modal_dialog_queue_) {
[email protected]0bfa713f2009-04-07 20:18:2817 app_modal_dialog_queue_ = new std::queue<AppModalDialog*>;
initial.commit09911bf2008-07-26 23:55:2918 ShowModalDialog(dialog);
19 }
20
[email protected]a91ba0e2009-04-06 23:10:3721 // 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.commit09911bf2008-07-26 23:55:2925}
26
27// static
28void AppModalDialogQueue::ShowNextDialog() {
29 app_modal_dialog_queue_->pop();
[email protected]b6ad1cab2009-01-16 22:41:4230 active_dialog_ = NULL;
initial.commit09911bf2008-07-26 23:55:2931 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
40void AppModalDialogQueue::ActivateModalDialog() {
41 if (!app_modal_dialog_queue_->empty())
42 app_modal_dialog_queue_->front()->ActivateModalDialog();
43}
44
45// static
[email protected]0bfa713f2009-04-07 20:18:2846void AppModalDialogQueue::ShowModalDialog(AppModalDialog* dialog) {
[email protected]a91ba0e2009-04-06 23:10:3747 // 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]b6ad1cab2009-01-16 22:41:4250 active_dialog_ = dialog;
[email protected]a91ba0e2009-04-06 23:10:3751 dialog->ShowModalDialog();
initial.commit09911bf2008-07-26 23:55:2952}