OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 COMPONENTS_WEB_MODAL_POPUP_MANAGER_H_ | 5 #ifndef COMPONENTS_WEB_MODAL_POPUP_MANAGER_H_ |
6 #define COMPONENTS_WEB_MODAL_POPUP_MANAGER_H_ | 6 #define COMPONENTS_WEB_MODAL_POPUP_MANAGER_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "components/web_modal/single_popup_manager.h" | 10 #include "components/web_modal/single_popup_manager.h" |
11 | 11 |
12 namespace content { | 12 namespace content { |
13 class WebContents; | 13 class WebContents; |
14 } | 14 } |
15 | 15 |
16 namespace gfx { | 16 namespace gfx { |
17 class Size; | 17 class Size; |
18 } | 18 } |
19 | 19 |
20 namespace web_modal { | 20 namespace web_modal { |
21 | 21 |
22 class WebContentsModalDialogHost; | 22 class WebContentsModalDialogHost; |
23 | 23 |
24 // Per-Browser class to manage popups (bubbles, web-modal dialogs). | 24 // Per-Browser class to manage popups (bubbles, web-modal dialogs). |
25 class PopupManager : public SinglePopupManagerDelegate { | 25 class PopupManager : public SinglePopupManagerDelegate { |
26 public: | 26 public: |
27 // |host| may be null. | 27 // |host| may be null. |
28 PopupManager(WebContentsModalDialogHost* host); | 28 PopupManager(WebContentsModalDialogHost* host); |
29 | 29 |
30 virtual ~PopupManager(); | 30 ~PopupManager() override; |
31 | 31 |
32 // Returns the native view which will be the parent of managed popups. | 32 // Returns the native view which will be the parent of managed popups. |
33 virtual gfx::NativeView GetHostView() const; | 33 virtual gfx::NativeView GetHostView() const; |
34 | 34 |
35 // Schedules a popup governed by the |manager| to be shown. The popup | 35 // Schedules a popup governed by the |manager| to be shown. The popup |
36 // may be shown inline with this call, at a later time, or not at all. | 36 // may be shown inline with this call, at a later time, or not at all. |
37 virtual void ShowPopup(scoped_ptr<SinglePopupManager> manager); | 37 virtual void ShowPopup(scoped_ptr<SinglePopupManager> manager); |
38 | 38 |
39 // Temporary method: Provides compatibility with existing | 39 // Temporary method: Provides compatibility with existing |
40 // WebContentsModalDialogManager code. | 40 // WebContentsModalDialogManager code. |
41 virtual void ShowModalDialog(NativePopup popup, | 41 virtual void ShowModalDialog(NativePopup popup, |
42 content::WebContents* web_contents); | 42 content::WebContents* web_contents); |
43 | 43 |
44 // Returns true if a web modal dialog is active and not closed in the | 44 // Returns true if a web modal dialog is active and not closed in the |
45 // given |web_contents|. Note: this is intended for legacy use only; it will | 45 // given |web_contents|. Note: this is intended for legacy use only; it will |
46 // be deleted at some point -- new code shouldn't use it. | 46 // be deleted at some point -- new code shouldn't use it. |
47 virtual bool IsWebModalDialogActive( | 47 virtual bool IsWebModalDialogActive( |
48 const content::WebContents* web_contents) const; | 48 const content::WebContents* web_contents) const; |
49 | 49 |
50 // Called when a NativePopup we own is about to be closed. | 50 // Called when a NativePopup we own is about to be closed. |
51 virtual void WillClose(NativePopup popup) override; | 51 void WillClose(NativePopup popup) override; |
52 | 52 |
53 // Called by views code to re-activate popups anchored to a particular tab | 53 // Called by views code to re-activate popups anchored to a particular tab |
54 // when that tab gets focus. Note that depending on the situation, more than | 54 // when that tab gets focus. Note that depending on the situation, more than |
55 // one popup may actually be shown (depending on overlappability). The | 55 // one popup may actually be shown (depending on overlappability). The |
56 // semantics are that the popups that would have been displayed had the tab | 56 // semantics are that the popups that would have been displayed had the tab |
57 // never lost focus are re-focused when tab focus is regained. | 57 // never lost focus are re-focused when tab focus is regained. |
58 virtual void WasFocused(const content::WebContents* web_contents); | 58 virtual void WasFocused(const content::WebContents* web_contents); |
59 | 59 |
60 // WebContentsUserData-alike API for retrieving the associated window | 60 // WebContentsUserData-alike API for retrieving the associated window |
61 // PopupManager from a |web_contents|. Any window which doesn't have a popup | 61 // PopupManager from a |web_contents|. Any window which doesn't have a popup |
(...skipping 12 matching lines...) Expand all Loading... |
74 WebContentsModalDialogHost* host_; | 74 WebContentsModalDialogHost* host_; |
75 | 75 |
76 base::WeakPtrFactory<PopupManager> weak_factory_; | 76 base::WeakPtrFactory<PopupManager> weak_factory_; |
77 | 77 |
78 DISALLOW_COPY_AND_ASSIGN(PopupManager); | 78 DISALLOW_COPY_AND_ASSIGN(PopupManager); |
79 }; | 79 }; |
80 | 80 |
81 } // namespace web_modal | 81 } // namespace web_modal |
82 | 82 |
83 #endif // COMPONENTS_WEB_MODAL_POPUP_MANAGER_H_ | 83 #endif // COMPONENTS_WEB_MODAL_POPUP_MANAGER_H_ |
OLD | NEW |