OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_UI_APP_MODAL_DIALOGS_APP_MODAL_DIALOG_QUEUE_H_ | 5 #ifndef CHROME_BROWSER_UI_APP_MODAL_DIALOGS_APP_MODAL_DIALOG_QUEUE_H_ |
6 #define CHROME_BROWSER_UI_APP_MODAL_DIALOGS_APP_MODAL_DIALOG_QUEUE_H_ | 6 #define CHROME_BROWSER_UI_APP_MODAL_DIALOGS_APP_MODAL_DIALOG_QUEUE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <queue> | 9 #include <deque> |
10 | 10 |
11 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" | 11 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" |
12 | 12 |
13 template <typename T> struct DefaultSingletonTraits; | 13 template <typename T> struct DefaultSingletonTraits; |
14 | 14 |
15 // Keeps a queue of AppModalDialogs, making sure only one app modal | 15 // Keeps a queue of AppModalDialogs, making sure only one app modal |
16 // dialog is shown at a time. | 16 // dialog is shown at a time. |
17 // This class is a singleton. | 17 // This class is a singleton. |
18 class AppModalDialogQueue { | 18 class AppModalDialogQueue { |
19 public: | 19 public: |
(...skipping 29 matching lines...) Expand all Loading... |
49 // Returns true if there is currently an active app modal dialog box. | 49 // Returns true if there is currently an active app modal dialog box. |
50 bool HasActiveDialog() { | 50 bool HasActiveDialog() { |
51 return active_dialog_ != NULL; | 51 return active_dialog_ != NULL; |
52 } | 52 } |
53 | 53 |
54 // Accessor for |active_dialog_|. | 54 // Accessor for |active_dialog_|. |
55 AppModalDialog* active_dialog() { | 55 AppModalDialog* active_dialog() { |
56 return active_dialog_; | 56 return active_dialog_; |
57 } | 57 } |
58 | 58 |
| 59 // Iterators to walk the queue. |
| 60 typedef std::deque<AppModalDialog*>::iterator iterator; |
| 61 iterator begin() { |
| 62 return app_modal_dialog_queue_.begin(); |
| 63 } |
| 64 |
| 65 iterator end() { |
| 66 return app_modal_dialog_queue_.end(); |
| 67 } |
| 68 |
59 private: | 69 private: |
60 friend struct DefaultSingletonTraits<AppModalDialogQueue>; | 70 friend struct DefaultSingletonTraits<AppModalDialogQueue>; |
61 | 71 |
62 AppModalDialogQueue(); | 72 AppModalDialogQueue(); |
63 ~AppModalDialogQueue(); | 73 ~AppModalDialogQueue(); |
64 | 74 |
65 // Shows |dialog| and notifies the BrowserList that a modal dialog is showing. | 75 // Shows |dialog| and notifies the BrowserList that a modal dialog is showing. |
66 void ShowModalDialog(AppModalDialog* dialog); | 76 void ShowModalDialog(AppModalDialog* dialog); |
67 | 77 |
68 // Returns the next dialog to show. This removes entries from | 78 // Returns the next dialog to show. This removes entries from |
69 // app_modal_dialog_queue_ until one is valid or the queue is empty. This | 79 // app_modal_dialog_queue_ until one is valid or the queue is empty. This |
70 // returns NULL if there are no more dialogs, or all the dialogs in the queue | 80 // returns NULL if there are no more dialogs, or all the dialogs in the queue |
71 // are not valid. | 81 // are not valid. |
72 AppModalDialog* GetNextDialog(); | 82 AppModalDialog* GetNextDialog(); |
73 | 83 |
74 // Contains all app modal dialogs which are waiting to be shown, with the | 84 // Contains all app modal dialogs which are waiting to be shown, with the |
75 // currently modal dialog at the front of the queue. | 85 // currently modal dialog at the front of the queue. |
76 std::queue<AppModalDialog*> app_modal_dialog_queue_; | 86 std::deque<AppModalDialog*> app_modal_dialog_queue_; |
77 | 87 |
78 // The currently active app-modal dialog box's delegate. NULL if there is no | 88 // The currently active app-modal dialog box's delegate. NULL if there is no |
79 // active app-modal dialog box. | 89 // active app-modal dialog box. |
80 AppModalDialog* active_dialog_; | 90 AppModalDialog* active_dialog_; |
81 | 91 |
82 // Stores if |ShowModalDialog()| is currently being called on an app-modal | 92 // Stores if |ShowModalDialog()| is currently being called on an app-modal |
83 // dialog. | 93 // dialog. |
84 bool showing_modal_dialog_; | 94 bool showing_modal_dialog_; |
85 | 95 |
86 DISALLOW_COPY_AND_ASSIGN(AppModalDialogQueue); | 96 DISALLOW_COPY_AND_ASSIGN(AppModalDialogQueue); |
87 }; | 97 }; |
88 | 98 |
89 #endif // CHROME_BROWSER_UI_APP_MODAL_DIALOGS_APP_MODAL_DIALOG_QUEUE_H_ | 99 #endif // CHROME_BROWSER_UI_APP_MODAL_DIALOGS_APP_MODAL_DIALOG_QUEUE_H_ |
OLD | NEW |