blob: 9fbf143d0b91991b2cdaa5a783cdadda5cdba309 [file] [log] [blame]
[email protected]677b2a02012-06-04 21:54:081// Copyright (c) 2012 The Chromium Authors. All rights reserved.
license.botbf09a502008-08-24 00:55:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
initial.commit09911bf2008-07-26 23:55:294
oshimaf65398422014-11-18 23:30:425#ifndef COMPONENTS_APP_MODAL_APP_MODAL_DIALOG_QUEUE_H_
6#define COMPONENTS_APP_MODAL_APP_MODAL_DIALOG_QUEUE_H_
initial.commit09911bf2008-07-26 23:55:297
[email protected]a1e97f02011-06-30 14:04:348#include <deque>
initial.commit09911bf2008-07-26 23:55:299
[email protected]677b2a02012-06-04 21:54:0810#include "base/basictypes.h"
11
[email protected]d3c6c0d72010-12-09 08:15:0412template <typename T> struct DefaultSingletonTraits;
13
oshima0929be2a2014-11-19 22:21:0314namespace app_modal {
15
16class AppModalDialog;
17
[email protected]0bfa713f2009-04-07 20:18:2818// Keeps a queue of AppModalDialogs, making sure only one app modal
initial.commit09911bf2008-07-26 23:55:2919// dialog is shown at a time.
[email protected]1f460072009-05-28 17:02:0720// This class is a singleton.
initial.commit09911bf2008-07-26 23:55:2921class AppModalDialogQueue {
22 public:
[email protected]677b2a02012-06-04 21:54:0823 typedef std::deque<AppModalDialog*>::iterator iterator;
24
[email protected]d3c6c0d72010-12-09 08:15:0425 // Returns the singleton instance.
26 static AppModalDialogQueue* GetInstance();
27
[email protected]2e5b90c2011-08-16 21:11:5528 // Adds a modal dialog to the queue. If there are no other dialogs in the
initial.commit09911bf2008-07-26 23:55:2929 // 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
[email protected]7e2a3992012-05-22 22:57:1932 // activate any other browser windows.
[email protected]0bfa713f2009-04-07 20:18:2833 // Note: The AppModalDialog |dialog| must be window modal before it
initial.commit09911bf2008-07-26 23:55:2934 // can be added as app modal.
[email protected]1f460072009-05-28 17:02:0735 void AddDialog(AppModalDialog* dialog);
initial.commit09911bf2008-07-26 23:55:2936
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.
[email protected]1f460072009-05-28 17:02:0741 void ShowNextDialog();
initial.commit09911bf2008-07-26 23:55:2942
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).
[email protected]1f460072009-05-28 17:02:0749 void ActivateModalDialog();
initial.commit09911bf2008-07-26 23:55:2950
[email protected]b6ad1cab2009-01-16 22:41:4251 // Returns true if there is currently an active app modal dialog box.
[email protected]677b2a02012-06-04 21:54:0852 bool HasActiveDialog() const;
[email protected]b6ad1cab2009-01-16 22:41:4253
[email protected]677b2a02012-06-04 21:54:0854 AppModalDialog* active_dialog() { return active_dialog_; }
[email protected]b6ad1cab2009-01-16 22:41:4255
[email protected]2e5b90c2011-08-16 21:11:5556 // Iterators to walk the queue. The queue does not include the currently
57 // active app modal dialog box.
[email protected]677b2a02012-06-04 21:54:0858 iterator begin() { return app_modal_dialog_queue_.begin(); }
59 iterator end() { return app_modal_dialog_queue_.end(); }
[email protected]a1e97f02011-06-30 14:04:3460
initial.commit09911bf2008-07-26 23:55:2961 private:
[email protected]1f460072009-05-28 17:02:0762 friend struct DefaultSingletonTraits<AppModalDialogQueue>;
63
[email protected]2858bbf2010-10-05 23:46:0264 AppModalDialogQueue();
65 ~AppModalDialogQueue();
[email protected]1f460072009-05-28 17:02:0766
initial.commit09911bf2008-07-26 23:55:2967 // Shows |dialog| and notifies the BrowserList that a modal dialog is showing.
[email protected]1f460072009-05-28 17:02:0768 void ShowModalDialog(AppModalDialog* dialog);
initial.commit09911bf2008-07-26 23:55:2969
[email protected]1e1baa42010-02-18 03:51:5070 // 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();
75
[email protected]2e5b90c2011-08-16 21:11:5576 // Contains all app modal dialogs which are waiting to be shown. The currently
77 // active modal dialog is not included.
[email protected]a1e97f02011-06-30 14:04:3478 std::deque<AppModalDialog*> app_modal_dialog_queue_;
[email protected]b6ad1cab2009-01-16 22:41:4279
80 // The currently active app-modal dialog box's delegate. NULL if there is no
81 // active app-modal dialog box.
[email protected]1f460072009-05-28 17:02:0782 AppModalDialog* active_dialog_;
83
[email protected]171ae922010-02-24 02:07:0884 // Stores if |ShowModalDialog()| is currently being called on an app-modal
85 // dialog.
86 bool showing_modal_dialog_;
87
[email protected]1f460072009-05-28 17:02:0788 DISALLOW_COPY_AND_ASSIGN(AppModalDialogQueue);
initial.commit09911bf2008-07-26 23:55:2989};
90
oshima0929be2a2014-11-19 22:21:0391} // namespace app_modal
92
oshimaf65398422014-11-18 23:30:4293#endif // COMPONENTS_APP_MODAL_APP_MODAL_DIALOG_QUEUE_H_