Compute if a layer is clipped outside CalcDrawProps
[chromium-blink-merge.git] / components / app_modal / app_modal_dialog_queue.h
blob9fbf143d0b91991b2cdaa5a783cdadda5cdba309
1 // Copyright (c) 2012 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.
5 #ifndef COMPONENTS_APP_MODAL_APP_MODAL_DIALOG_QUEUE_H_
6 #define COMPONENTS_APP_MODAL_APP_MODAL_DIALOG_QUEUE_H_
8 #include <deque>
10 #include "base/basictypes.h"
12 template <typename T> struct DefaultSingletonTraits;
14 namespace app_modal {
16 class AppModalDialog;
18 // Keeps a queue of AppModalDialogs, making sure only one app modal
19 // dialog is shown at a time.
20 // This class is a singleton.
21 class AppModalDialogQueue {
22 public:
23 typedef std::deque<AppModalDialog*>::iterator iterator;
25 // Returns the singleton instance.
26 static AppModalDialogQueue* GetInstance();
28 // Adds a modal dialog to the queue. If there are no other dialogs in the
29 // queue, the dialog will be shown immediately. Once it is shown, the
30 // most recently active browser window (or whichever is currently active)
31 // will be app modal, meaning it will be activated if the user tries to
32 // activate any other browser windows.
33 // Note: The AppModalDialog |dialog| must be window modal before it
34 // can be added as app modal.
35 void AddDialog(AppModalDialog* dialog);
37 // Removes the current dialog in the queue (the one that is being shown).
38 // Shows the next dialog in the queue, if any is present. This does not
39 // ensure that the currently showing dialog is closed, it just makes it no
40 // longer app modal.
41 void ShowNextDialog();
43 // Activates and shows the current dialog, if the user clicks on one of the
44 // windows disabled by the presence of an app modal dialog. This forces
45 // the window to be visible on the display even if desktop manager software
46 // opened the dialog on another virtual desktop. Assumes there is currently a
47 // dialog being shown. (Call BrowserList::IsShowingAppModalDialog to test
48 // this condition).
49 void ActivateModalDialog();
51 // Returns true if there is currently an active app modal dialog box.
52 bool HasActiveDialog() const;
54 AppModalDialog* active_dialog() { return active_dialog_; }
56 // Iterators to walk the queue. The queue does not include the currently
57 // active app modal dialog box.
58 iterator begin() { return app_modal_dialog_queue_.begin(); }
59 iterator end() { return app_modal_dialog_queue_.end(); }
61 private:
62 friend struct DefaultSingletonTraits<AppModalDialogQueue>;
64 AppModalDialogQueue();
65 ~AppModalDialogQueue();
67 // Shows |dialog| and notifies the BrowserList that a modal dialog is showing.
68 void ShowModalDialog(AppModalDialog* dialog);
70 // Returns the next dialog to show. This removes entries from
71 // app_modal_dialog_queue_ until one is valid or the queue is empty. This
72 // returns NULL if there are no more dialogs, or all the dialogs in the queue
73 // are not valid.
74 AppModalDialog* GetNextDialog();
76 // Contains all app modal dialogs which are waiting to be shown. The currently
77 // active modal dialog is not included.
78 std::deque<AppModalDialog*> app_modal_dialog_queue_;
80 // The currently active app-modal dialog box's delegate. NULL if there is no
81 // active app-modal dialog box.
82 AppModalDialog* active_dialog_;
84 // Stores if |ShowModalDialog()| is currently being called on an app-modal
85 // dialog.
86 bool showing_modal_dialog_;
88 DISALLOW_COPY_AND_ASSIGN(AppModalDialogQueue);
91 } // namespace app_modal
93 #endif // COMPONENTS_APP_MODAL_APP_MODAL_DIALOG_QUEUE_H_