OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 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. |
| 4 |
| 5 #ifndef CHROME_BROWSER_UI_VIEWS_BROWSER_MODAL_DIALOG_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_BROWSER_MODAL_DIALOG_H_ |
| 7 |
| 8 #include <list> |
| 9 #include <memory> |
| 10 |
| 11 #include "base/macros.h" |
| 12 |
| 13 namespace base { |
| 14 template <typename T> |
| 15 struct DefaultSingletonTraits; |
| 16 } // namespace base |
| 17 |
| 18 class AppModalDialogQueueWrapper; |
| 19 class Browser; |
| 20 |
| 21 // BrowserModalDialog prevents all browser windows from being actived. If there |
| 22 // are multiple BrowserModalDialog, only the browser window owns the oldest |
| 23 // dialog will get focus. Note that this dialog doesn't block other |
| 24 // non-browser windows like app window. |
| 25 class BrowserModalDialog { |
| 26 public: |
| 27 BrowserModalDialog(); |
| 28 virtual ~BrowserModalDialog(); |
| 29 |
| 30 // Activates the modal dialog when the window of |browser| tries to get focus. |
| 31 virtual void ActivateModalDialog(Browser* browser) = 0; |
| 32 |
| 33 // Returns true if modal dialog is visible. |
| 34 virtual bool IsShowing() = 0; |
| 35 }; |
| 36 |
| 37 // The list of BrowserModalDialogs. |
| 38 class BrowserModalDialogList { |
| 39 public: |
| 40 static BrowserModalDialogList* GetInstance(); |
| 41 |
| 42 // BrowserModalDialogList will not take the ownership of the dialog instance. |
| 43 void AddDialog(BrowserModalDialog* dialog); |
| 44 |
| 45 void RemoveDialog(BrowserModalDialog* dialog); |
| 46 |
| 47 // Activates the oldest BrowserModalDialog when the window of |browser| tries |
| 48 // to get focus. |
| 49 void ActivateModalDialog(Browser* browser); |
| 50 |
| 51 // Returns true if any BrowserModalDialogs are visible. |
| 52 bool IsShowing(); |
| 53 |
| 54 private: |
| 55 friend struct base::DefaultSingletonTraits<BrowserModalDialogList>; |
| 56 |
| 57 BrowserModalDialogList(); |
| 58 ~BrowserModalDialogList(); |
| 59 |
| 60 std::list<BrowserModalDialog*> dialogs_; |
| 61 std::unique_ptr<AppModalDialogQueueWrapper> wrapper_; |
| 62 |
| 63 DISALLOW_COPY_AND_ASSIGN(BrowserModalDialogList); |
| 64 }; |
| 65 |
| 66 #endif // CHROME_BROWSER_UI_VIEWS_BROWSER_MODAL_DIALOG_H_ |
OLD | NEW |