OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef COMPONENTS_WEB_MODAL_SINGLE_POPUP_MANAGER_H_ | |
6 #define COMPONENTS_WEB_MODAL_SINGLE_POPUP_MANAGER_H_ | |
7 | |
8 #include "components/web_modal/native_web_contents_modal_dialog.h" | |
9 | |
10 namespace content { | |
11 class WebContents; | |
12 } | |
13 | |
14 namespace web_modal { | |
15 | |
16 // Interface from SinglePopupManager to PopupManager. | |
17 class SinglePopupManagerDelegate { | |
18 public: | |
19 SinglePopupManagerDelegate() {} | |
20 virtual ~SinglePopupManagerDelegate() {} | |
21 | |
22 // Notify the delegate that the dialog is closing. The | |
23 // calling SinglePopupManager will be deleted before the end of this call. | |
24 virtual void WillClose(NativePopup popup) = 0; | |
25 | |
26 private: | |
27 DISALLOW_COPY_AND_ASSIGN(SinglePopupManagerDelegate); | |
28 }; | |
29 | |
30 // Provides an interface for platform-specific UI implementation for popups. | |
31 // Each object will manage a single NativePopup window during its lifecycle. | |
32 // The rule of thumb is that only one popup will be shown at a time per tab. | |
33 // (Exceptions exist.) | |
34 // | |
35 // Implementation classes should accept a NativePopup at construction time | |
36 // and register to be notified when the dialog is closing, so that it can | |
37 // notify its delegate (WillClose method). | |
38 class SinglePopupManager { | |
39 public: | |
40 virtual ~SinglePopupManager() {} | |
41 | |
42 // If the manager returns non-null to this call, it is bound to a particular | |
43 // tab and will be hidden and shown if that tab visibility changes. | |
44 virtual content::WebContents* GetBoundWebContents() = 0; | |
45 | |
46 // Makes the popup visible. | |
47 virtual void Show() = 0; | |
48 | |
49 // Hides the popup without closing it. | |
50 virtual void Hide() = 0; | |
51 | |
52 // Closes the popup. | |
53 // This method must call WillClose() on the delegate. | |
54 // Important note: this object will be deleted at the close of that | |
55 // invocation. | |
56 virtual void Close() = 0; | |
57 | |
58 // Sets focus on the popup. | |
59 virtual void Focus() = 0; | |
60 | |
61 virtual void Pulse() = 0; | |
62 | |
63 // Returns the popup under management by this object. | |
64 virtual NativePopup popup() = 0; | |
65 | |
66 // Returns true if the popup under management was initiated by a user | |
67 // gesture. When this is true, the popup manager will hide any existing | |
68 // popups and move the newly-created NativePopup to the top of the display | |
69 // queue. | |
70 virtual bool HasUserGesture() = 0; | |
71 | |
72 // Returns true if the popup under management is tolerant of being overlapped | |
73 // by other popups. This may be true for large web-modals which cover most of | |
74 // the window real estate (e.g. print preview). | |
75 virtual bool MayBeOverlapped() = 0; | |
76 | |
77 // Returns true if the popup under management should close if there is a | |
78 // navigation underneath it, including the showing of any interstitial | |
79 // content. Popups which relate to the web content being displayed will | |
80 // ordinarily set this to true. | |
81 virtual bool ShouldCloseOnNavigation() = 0; | |
Mike Wittman
2014/05/23 19:02:35
It would be good to eventually generalize this to
Greg Billock
2014/05/27 22:42:03
Yeah, I think that's right. Do you know what other
Mike Wittman
2014/05/28 21:47:09
The cases I'm aware of that result in closing the
| |
82 | |
83 protected: | |
84 SinglePopupManager() {} | |
85 | |
86 private: | |
87 DISALLOW_COPY_AND_ASSIGN(SinglePopupManager); | |
88 }; | |
89 | |
90 } // namespace web_modal | |
91 | |
92 #endif // COMPONENTS_WEB_MODAL_SINGLE_POPUP_MANAGER_H_ | |
OLD | NEW |