blob: bfe755cb02baff0ef90b2240f9915d25f0e4fde7 [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#ifndef CHROME_BROWSER_APP_MODAL_DIALOG_QUEUE_H__
6#define CHROME_BROWSER_APP_MODAL_DIALOG_QUEUE_H__
7
8#include <queue>
9
[email protected]0bfa713f2009-04-07 20:18:2810#include "chrome/browser/app_modal_dialog.h"
initial.commit09911bf2008-07-26 23:55:2911
[email protected]0bfa713f2009-04-07 20:18:2812// Keeps a queue of AppModalDialogs, making sure only one app modal
initial.commit09911bf2008-07-26 23:55:2913// dialog is shown at a time.
14class AppModalDialogQueue {
15 public:
16 // Adds a modal dialog to the queue, if there are no other dialogs in the
17 // queue, the dialog will be shown immediately. Once it is shown, the
18 // most recently active browser window (or whichever is currently active)
19 // will be app modal, meaning it will be activated if the user tries to
20 // activate any other browser windows. So the dialog being shown should
21 // assure it is the child of BrowserList::GetLastActive() so that it is
22 // activated as well. See browser_list.h for more notes about our somewhat
23 // sloppy app modality.
[email protected]0bfa713f2009-04-07 20:18:2824 // Note: The AppModalDialog |dialog| must be window modal before it
initial.commit09911bf2008-07-26 23:55:2925 // can be added as app modal.
[email protected]0bfa713f2009-04-07 20:18:2826 static void AddDialog(AppModalDialog* dialog);
initial.commit09911bf2008-07-26 23:55:2927
28 // Removes the current dialog in the queue (the one that is being shown).
29 // Shows the next dialog in the queue, if any is present. This does not
30 // ensure that the currently showing dialog is closed, it just makes it no
31 // longer app modal.
32 static void ShowNextDialog();
33
34 // Activates and shows the current dialog, if the user clicks on one of the
35 // windows disabled by the presence of an app modal dialog. This forces
36 // the window to be visible on the display even if desktop manager software
37 // opened the dialog on another virtual desktop. Assumes there is currently a
38 // dialog being shown. (Call BrowserList::IsShowingAppModalDialog to test
39 // this condition).
40 static void ActivateModalDialog();
41
[email protected]b6ad1cab2009-01-16 22:41:4242 // Returns true if there is currently an active app modal dialog box.
43 static bool HasActiveDialog() {
44 return active_dialog_ != NULL;
45 }
46
47 // Accessor for |active_dialog_|.
[email protected]0bfa713f2009-04-07 20:18:2848 static AppModalDialog* active_dialog() {
[email protected]b3a70332009-02-25 02:40:5049 return active_dialog_;
50 }
[email protected]b6ad1cab2009-01-16 22:41:4251
initial.commit09911bf2008-07-26 23:55:2952 private:
53 // Shows |dialog| and notifies the BrowserList that a modal dialog is showing.
[email protected]0bfa713f2009-04-07 20:18:2854 static void ShowModalDialog(AppModalDialog* dialog);
initial.commit09911bf2008-07-26 23:55:2955
56 // Contains all app modal dialogs which are waiting to be shown, with the
57 // currently modal dialog at the front of the queue.
[email protected]0bfa713f2009-04-07 20:18:2858 static std::queue<AppModalDialog*>* app_modal_dialog_queue_;
[email protected]b6ad1cab2009-01-16 22:41:4259
60 // The currently active app-modal dialog box's delegate. NULL if there is no
61 // active app-modal dialog box.
[email protected]0bfa713f2009-04-07 20:18:2862 static AppModalDialog* active_dialog_;
initial.commit09911bf2008-07-26 23:55:2963};
64
65#endif // CHROME_BROWSER_APP_MODAL_DIALOG_QUEUE_H__