| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_APP_MODAL_DIALOG_QUEUE_H__ | 5 #ifndef CHROME_BROWSER_APP_MODAL_DIALOG_QUEUE_H__ |
| 6 #define CHROME_BROWSER_APP_MODAL_DIALOG_QUEUE_H__ | 6 #define CHROME_BROWSER_APP_MODAL_DIALOG_QUEUE_H__ |
| 7 | 7 |
| 8 #include <queue> | 8 #include <queue> |
| 9 | 9 |
| 10 #include "chrome/views/window/app_modal_dialog_delegate.h" | 10 #include "chrome/browser/app_modal_dialog.h" |
| 11 | 11 |
| 12 // Keeps a queue of AppModalDialogDelegates, making sure only one app modal | 12 // Keeps a queue of AppModalDialogs, making sure only one app modal |
| 13 // dialog is shown at a time. | 13 // dialog is shown at a time. |
| 14 class AppModalDialogQueue { | 14 class AppModalDialogQueue { |
| 15 public: | 15 public: |
| 16 // Adds a modal dialog to the queue, if there are no other dialogs in the | 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 | 17 // queue, the dialog will be shown immediately. Once it is shown, the |
| 18 // most recently active browser window (or whichever is currently active) | 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 | 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 | 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 | 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 | 22 // activated as well. See browser_list.h for more notes about our somewhat |
| 23 // sloppy app modality. | 23 // sloppy app modality. |
| 24 // Note: The AppModalDialogDelegate |dialog| must be window modal before it | 24 // Note: The AppModalDialog |dialog| must be window modal before it |
| 25 // can be added as app modal. | 25 // can be added as app modal. |
| 26 static void AddDialog(views::AppModalDialogDelegate* dialog); | 26 static void AddDialog(AppModalDialog* dialog); |
| 27 | 27 |
| 28 // Removes the current dialog in the queue (the one that is being shown). | 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 | 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 | 30 // ensure that the currently showing dialog is closed, it just makes it no |
| 31 // longer app modal. | 31 // longer app modal. |
| 32 static void ShowNextDialog(); | 32 static void ShowNextDialog(); |
| 33 | 33 |
| 34 // Activates and shows the current dialog, if the user clicks on one of the | 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 | 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 | 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 | 37 // opened the dialog on another virtual desktop. Assumes there is currently a |
| 38 // dialog being shown. (Call BrowserList::IsShowingAppModalDialog to test | 38 // dialog being shown. (Call BrowserList::IsShowingAppModalDialog to test |
| 39 // this condition). | 39 // this condition). |
| 40 static void ActivateModalDialog(); | 40 static void ActivateModalDialog(); |
| 41 | 41 |
| 42 // Returns true if there is currently an active app modal dialog box. | 42 // Returns true if there is currently an active app modal dialog box. |
| 43 static bool HasActiveDialog() { | 43 static bool HasActiveDialog() { |
| 44 return active_dialog_ != NULL; | 44 return active_dialog_ != NULL; |
| 45 } | 45 } |
| 46 | 46 |
| 47 // Accessor for |active_dialog_|. | 47 // Accessor for |active_dialog_|. |
| 48 static views::AppModalDialogDelegate* active_dialog() { | 48 static AppModalDialog* active_dialog() { |
| 49 return active_dialog_; | 49 return active_dialog_; |
| 50 } | 50 } |
| 51 | 51 |
| 52 private: | 52 private: |
| 53 // Shows |dialog| and notifies the BrowserList that a modal dialog is showing. | 53 // Shows |dialog| and notifies the BrowserList that a modal dialog is showing. |
| 54 static void ShowModalDialog(views::AppModalDialogDelegate* dialog); | 54 static void ShowModalDialog(AppModalDialog* dialog); |
| 55 | 55 |
| 56 // Contains all app modal dialogs which are waiting to be shown, with the | 56 // Contains all app modal dialogs which are waiting to be shown, with the |
| 57 // currently modal dialog at the front of the queue. | 57 // currently modal dialog at the front of the queue. |
| 58 static std::queue<views::AppModalDialogDelegate*>* | 58 static std::queue<AppModalDialog*>* app_modal_dialog_queue_; |
| 59 app_modal_dialog_queue_; | |
| 60 | 59 |
| 61 // The currently active app-modal dialog box's delegate. NULL if there is no | 60 // The currently active app-modal dialog box's delegate. NULL if there is no |
| 62 // active app-modal dialog box. | 61 // active app-modal dialog box. |
| 63 static views::AppModalDialogDelegate* active_dialog_; | 62 static AppModalDialog* active_dialog_; |
| 64 }; | 63 }; |
| 65 | 64 |
| 66 #endif // CHROME_BROWSER_APP_MODAL_DIALOG_QUEUE_H__ | 65 #endif // CHROME_BROWSER_APP_MODAL_DIALOG_QUEUE_H__ |
| OLD | NEW |