blob: aa169c5fb0da022b9880fafdb1bdf85bd915d928 [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
[email protected]11f4857282009-11-13 19:56:175#ifndef CHROME_BROWSER_APP_MODAL_DIALOG_QUEUE_H_
6#define CHROME_BROWSER_APP_MODAL_DIALOG_QUEUE_H_
initial.commit09911bf2008-07-26 23:55:297
8#include <queue>
9
[email protected]1f460072009-05-28 17:02:0710#include "base/singleton.h"
[email protected]0bfa713f2009-04-07 20:18:2811#include "chrome/browser/app_modal_dialog.h"
initial.commit09911bf2008-07-26 23:55:2912
[email protected]0bfa713f2009-04-07 20:18:2813// Keeps a queue of AppModalDialogs, making sure only one app modal
initial.commit09911bf2008-07-26 23:55:2914// dialog is shown at a time.
[email protected]1f460072009-05-28 17:02:0715// This class is a singleton.
initial.commit09911bf2008-07-26 23:55:2916class AppModalDialogQueue {
17 public:
18 // Adds a modal dialog to the queue, if there are no other dialogs in the
19 // queue, the dialog will be shown immediately. Once it is shown, the
20 // most recently active browser window (or whichever is currently active)
21 // will be app modal, meaning it will be activated if the user tries to
22 // activate any other browser windows. So the dialog being shown should
23 // assure it is the child of BrowserList::GetLastActive() so that it is
24 // activated as well. See browser_list.h for more notes about our somewhat
25 // sloppy app modality.
[email protected]0bfa713f2009-04-07 20:18:2826 // Note: The AppModalDialog |dialog| must be window modal before it
initial.commit09911bf2008-07-26 23:55:2927 // can be added as app modal.
[email protected]1f460072009-05-28 17:02:0728 void AddDialog(AppModalDialog* dialog);
initial.commit09911bf2008-07-26 23:55:2929
30 // Removes the current dialog in the queue (the one that is being shown).
31 // Shows the next dialog in the queue, if any is present. This does not
32 // ensure that the currently showing dialog is closed, it just makes it no
33 // longer app modal.
[email protected]1f460072009-05-28 17:02:0734 void ShowNextDialog();
initial.commit09911bf2008-07-26 23:55:2935
36 // Activates and shows the current dialog, if the user clicks on one of the
37 // windows disabled by the presence of an app modal dialog. This forces
38 // the window to be visible on the display even if desktop manager software
39 // opened the dialog on another virtual desktop. Assumes there is currently a
40 // dialog being shown. (Call BrowserList::IsShowingAppModalDialog to test
41 // this condition).
[email protected]1f460072009-05-28 17:02:0742 void ActivateModalDialog();
initial.commit09911bf2008-07-26 23:55:2943
[email protected]b6ad1cab2009-01-16 22:41:4244 // Returns true if there is currently an active app modal dialog box.
[email protected]1f460072009-05-28 17:02:0745 bool HasActiveDialog() {
[email protected]b6ad1cab2009-01-16 22:41:4246 return active_dialog_ != NULL;
47 }
48
49 // Accessor for |active_dialog_|.
[email protected]1f460072009-05-28 17:02:0750 AppModalDialog* active_dialog() {
[email protected]b3a70332009-02-25 02:40:5051 return active_dialog_;
52 }
[email protected]b6ad1cab2009-01-16 22:41:4253
initial.commit09911bf2008-07-26 23:55:2954 private:
[email protected]1f460072009-05-28 17:02:0755 friend struct DefaultSingletonTraits<AppModalDialogQueue>;
56
57 AppModalDialogQueue() : active_dialog_(NULL) { }
58
initial.commit09911bf2008-07-26 23:55:2959 // Shows |dialog| and notifies the BrowserList that a modal dialog is showing.
[email protected]1f460072009-05-28 17:02:0760 void ShowModalDialog(AppModalDialog* dialog);
initial.commit09911bf2008-07-26 23:55:2961
62 // Contains all app modal dialogs which are waiting to be shown, with the
63 // currently modal dialog at the front of the queue.
[email protected]1f460072009-05-28 17:02:0764 std::queue<AppModalDialog*> app_modal_dialog_queue_;
[email protected]b6ad1cab2009-01-16 22:41:4265
66 // The currently active app-modal dialog box's delegate. NULL if there is no
67 // active app-modal dialog box.
[email protected]1f460072009-05-28 17:02:0768 AppModalDialog* active_dialog_;
69
70 DISALLOW_COPY_AND_ASSIGN(AppModalDialogQueue);
initial.commit09911bf2008-07-26 23:55:2971};
72
[email protected]11f4857282009-11-13 19:56:1773#endif // CHROME_BROWSER_APP_MODAL_DIALOG_QUEUE_H_