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 | |
| 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] | 0bfa713f | 2009-04-07 20:18:28 | [diff] [blame^] | 10 | #include "chrome/browser/app_modal_dialog.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 11 | |
[email protected] | 0bfa713f | 2009-04-07 20:18:28 | [diff] [blame^] | 12 | // Keeps a queue of AppModalDialogs, making sure only one app modal |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 13 | // dialog is shown at a time. |
| 14 | class 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] | 0bfa713f | 2009-04-07 20:18:28 | [diff] [blame^] | 24 | // Note: The AppModalDialog |dialog| must be window modal before it |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 25 | // can be added as app modal. |
[email protected] | 0bfa713f | 2009-04-07 20:18:28 | [diff] [blame^] | 26 | static void AddDialog(AppModalDialog* dialog); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 27 | |
| 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] | b6ad1cab | 2009-01-16 22:41:42 | [diff] [blame] | 42 | // 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] | 0bfa713f | 2009-04-07 20:18:28 | [diff] [blame^] | 48 | static AppModalDialog* active_dialog() { |
[email protected] | b3a7033 | 2009-02-25 02:40:50 | [diff] [blame] | 49 | return active_dialog_; |
| 50 | } |
[email protected] | b6ad1cab | 2009-01-16 22:41:42 | [diff] [blame] | 51 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 52 | private: |
| 53 | // Shows |dialog| and notifies the BrowserList that a modal dialog is showing. |
[email protected] | 0bfa713f | 2009-04-07 20:18:28 | [diff] [blame^] | 54 | static void ShowModalDialog(AppModalDialog* dialog); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 55 | |
| 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] | 0bfa713f | 2009-04-07 20:18:28 | [diff] [blame^] | 58 | static std::queue<AppModalDialog*>* app_modal_dialog_queue_; |
[email protected] | b6ad1cab | 2009-01-16 22:41:42 | [diff] [blame] | 59 | |
| 60 | // The currently active app-modal dialog box's delegate. NULL if there is no |
| 61 | // active app-modal dialog box. |
[email protected] | 0bfa713f | 2009-04-07 20:18:28 | [diff] [blame^] | 62 | static AppModalDialog* active_dialog_; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 63 | }; |
| 64 | |
| 65 | #endif // CHROME_BROWSER_APP_MODAL_DIALOG_QUEUE_H__ |