blob: e24a7b0474a1a625a6e51ea31aec0c606dc8eb64 [file] [log] [blame]
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/app_modal_dialog_queue.h"
#include "chrome/browser/browser_list.h"
// static
std::queue<AppModalDialog*>*
AppModalDialogQueue::app_modal_dialog_queue_ = NULL;
AppModalDialog* AppModalDialogQueue::active_dialog_ = NULL;
// static
void AppModalDialogQueue::AddDialog(AppModalDialog* dialog) {
if (!app_modal_dialog_queue_) {
app_modal_dialog_queue_ = new std::queue<AppModalDialog*>;
ShowModalDialog(dialog);
}
// ShowModalDialog can wind up calling ShowNextDialog in some cases, which
// can then make app_modal_dialog_queue_ NULL.
if (app_modal_dialog_queue_)
app_modal_dialog_queue_->push(dialog);
}
// static
void AppModalDialogQueue::ShowNextDialog() {
app_modal_dialog_queue_->pop();
active_dialog_ = NULL;
if (!app_modal_dialog_queue_->empty()) {
ShowModalDialog(app_modal_dialog_queue_->front());
} else {
delete app_modal_dialog_queue_;
app_modal_dialog_queue_ = NULL;
}
}
// static
void AppModalDialogQueue::ActivateModalDialog() {
if (!app_modal_dialog_queue_->empty())
app_modal_dialog_queue_->front()->ActivateModalDialog();
}
// static
void AppModalDialogQueue::ShowModalDialog(AppModalDialog* dialog) {
// ShowModalDialog can wind up calling ShowNextDialog in some cases,
// which will wind up calling this method recursively, so active_dialog_
// must be set first.
active_dialog_ = dialog;
dialog->ShowModalDialog();
}