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 | |
[email protected] | 11f485728 | 2009-11-13 19:56:17 | [diff] [blame] | 5 | #ifndef CHROME_BROWSER_APP_MODAL_DIALOG_QUEUE_H_ |
6 | #define CHROME_BROWSER_APP_MODAL_DIALOG_QUEUE_H_ | ||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 7 | |
8 | #include <queue> | ||||
9 | |||||
[email protected] | 1f46007 | 2009-05-28 17:02:07 | [diff] [blame] | 10 | #include "base/singleton.h" |
[email protected] | 0bfa713f | 2009-04-07 20:18:28 | [diff] [blame] | 11 | #include "chrome/browser/app_modal_dialog.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 12 | |
[email protected] | 0bfa713f | 2009-04-07 20:18:28 | [diff] [blame] | 13 | // Keeps a queue of AppModalDialogs, making sure only one app modal |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 14 | // dialog is shown at a time. |
[email protected] | 1f46007 | 2009-05-28 17:02:07 | [diff] [blame] | 15 | // This class is a singleton. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 16 | class 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] | 0bfa713f | 2009-04-07 20:18:28 | [diff] [blame] | 26 | // Note: The AppModalDialog |dialog| must be window modal before it |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 27 | // can be added as app modal. |
[email protected] | 1f46007 | 2009-05-28 17:02:07 | [diff] [blame] | 28 | void AddDialog(AppModalDialog* dialog); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 29 | |
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] | 1f46007 | 2009-05-28 17:02:07 | [diff] [blame] | 34 | void ShowNextDialog(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 35 | |
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] | 1f46007 | 2009-05-28 17:02:07 | [diff] [blame] | 42 | void ActivateModalDialog(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 43 | |
[email protected] | b6ad1cab | 2009-01-16 22:41:42 | [diff] [blame] | 44 | // Returns true if there is currently an active app modal dialog box. |
[email protected] | 1f46007 | 2009-05-28 17:02:07 | [diff] [blame] | 45 | bool HasActiveDialog() { |
[email protected] | b6ad1cab | 2009-01-16 22:41:42 | [diff] [blame] | 46 | return active_dialog_ != NULL; |
47 | } | ||||
48 | |||||
49 | // Accessor for |active_dialog_|. | ||||
[email protected] | 1f46007 | 2009-05-28 17:02:07 | [diff] [blame] | 50 | AppModalDialog* active_dialog() { |
[email protected] | b3a7033 | 2009-02-25 02:40:50 | [diff] [blame] | 51 | return active_dialog_; |
52 | } | ||||
[email protected] | b6ad1cab | 2009-01-16 22:41:42 | [diff] [blame] | 53 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 54 | private: |
[email protected] | 1f46007 | 2009-05-28 17:02:07 | [diff] [blame] | 55 | friend struct DefaultSingletonTraits<AppModalDialogQueue>; |
56 | |||||
57 | AppModalDialogQueue() : active_dialog_(NULL) { } | ||||
58 | |||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 59 | // Shows |dialog| and notifies the BrowserList that a modal dialog is showing. |
[email protected] | 1f46007 | 2009-05-28 17:02:07 | [diff] [blame] | 60 | void ShowModalDialog(AppModalDialog* dialog); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 61 | |
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] | 1f46007 | 2009-05-28 17:02:07 | [diff] [blame] | 64 | std::queue<AppModalDialog*> app_modal_dialog_queue_; |
[email protected] | b6ad1cab | 2009-01-16 22:41:42 | [diff] [blame] | 65 | |
66 | // The currently active app-modal dialog box's delegate. NULL if there is no | ||||
67 | // active app-modal dialog box. | ||||
[email protected] | 1f46007 | 2009-05-28 17:02:07 | [diff] [blame] | 68 | AppModalDialog* active_dialog_; |
69 | |||||
70 | DISALLOW_COPY_AND_ASSIGN(AppModalDialogQueue); | ||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 71 | }; |
72 | |||||
[email protected] | 11f485728 | 2009-11-13 19:56:17 | [diff] [blame] | 73 | #endif // CHROME_BROWSER_APP_MODAL_DIALOG_QUEUE_H_ |