Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Side by Side Diff: chrome/browser/app_modal_dialog_queue.h

Issue 113932: Clean-up of the app modal dialog queue (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/app_modal_dialog.cc ('k') | chrome/browser/app_modal_dialog_queue.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/singleton.h"
10 #include "chrome/browser/app_modal_dialog.h" 11 #include "chrome/browser/app_modal_dialog.h"
11 12
12 // Keeps a queue of AppModalDialogs, making sure only one app modal 13 // Keeps a queue of AppModalDialogs, making sure only one app modal
13 // dialog is shown at a time. 14 // dialog is shown at a time.
15 // This class is a singleton.
14 class AppModalDialogQueue { 16 class AppModalDialogQueue {
15 public: 17 public:
16 // Adds a modal dialog to the queue, if there are no other dialogs in the 18 // 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 19 // queue, the dialog will be shown immediately. Once it is shown, the
18 // most recently active browser window (or whichever is currently active) 20 // 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 21 // 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 22 // activate any other browser windows. So the dialog being shown should
21 // assure it is the child of BrowserList::GetLastActive() so that it is 23 // 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 24 // activated as well. See browser_list.h for more notes about our somewhat
23 // sloppy app modality. 25 // sloppy app modality.
24 // Note: The AppModalDialog |dialog| must be window modal before it 26 // Note: The AppModalDialog |dialog| must be window modal before it
25 // can be added as app modal. 27 // can be added as app modal.
26 static void AddDialog(AppModalDialog* dialog); 28 void AddDialog(AppModalDialog* dialog);
27 29
28 // Removes the current dialog in the queue (the one that is being shown). 30 // 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 31 // 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 32 // ensure that the currently showing dialog is closed, it just makes it no
31 // longer app modal. 33 // longer app modal.
32 static void ShowNextDialog(); 34 void ShowNextDialog();
33 35
34 // Activates and shows the current dialog, if the user clicks on one of the 36 // 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 37 // 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 38 // 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 39 // opened the dialog on another virtual desktop. Assumes there is currently a
38 // dialog being shown. (Call BrowserList::IsShowingAppModalDialog to test 40 // dialog being shown. (Call BrowserList::IsShowingAppModalDialog to test
39 // this condition). 41 // this condition).
40 static void ActivateModalDialog(); 42 void ActivateModalDialog();
41 43
42 // Returns true if there is currently an active app modal dialog box. 44 // Returns true if there is currently an active app modal dialog box.
43 static bool HasActiveDialog() { 45 bool HasActiveDialog() {
44 return active_dialog_ != NULL; 46 return active_dialog_ != NULL;
45 } 47 }
46 48
47 // Accessor for |active_dialog_|. 49 // Accessor for |active_dialog_|.
48 static AppModalDialog* active_dialog() { 50 AppModalDialog* active_dialog() {
49 return active_dialog_; 51 return active_dialog_;
50 } 52 }
51 53
52 private: 54 private:
55 friend struct DefaultSingletonTraits<AppModalDialogQueue>;
56
57 AppModalDialogQueue() : active_dialog_(NULL) { }
58
53 // Shows |dialog| and notifies the BrowserList that a modal dialog is showing. 59 // Shows |dialog| and notifies the BrowserList that a modal dialog is showing.
54 static void ShowModalDialog(AppModalDialog* dialog); 60 void ShowModalDialog(AppModalDialog* dialog);
55 61
56 // Contains all app modal dialogs which are waiting to be shown, with the 62 // Contains all app modal dialogs which are waiting to be shown, with the
57 // currently modal dialog at the front of the queue. 63 // currently modal dialog at the front of the queue.
58 static std::queue<AppModalDialog*>* app_modal_dialog_queue_; 64 std::queue<AppModalDialog*> app_modal_dialog_queue_;
59 65
60 // The currently active app-modal dialog box's delegate. NULL if there is no 66 // The currently active app-modal dialog box's delegate. NULL if there is no
61 // active app-modal dialog box. 67 // active app-modal dialog box.
62 static AppModalDialog* active_dialog_; 68 AppModalDialog* active_dialog_;
69
70 DISALLOW_COPY_AND_ASSIGN(AppModalDialogQueue);
63 }; 71 };
64 72
65 #endif // CHROME_BROWSER_APP_MODAL_DIALOG_QUEUE_H__ 73 #endif // CHROME_BROWSER_APP_MODAL_DIALOG_QUEUE_H__
OLDNEW
« no previous file with comments | « chrome/browser/app_modal_dialog.cc ('k') | chrome/browser/app_modal_dialog_queue.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698