Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / components / web_modal / single_popup_manager.h
blob4ce762aa47c8afbb7380cb9b94d215b90ed0fc41
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.
5 #ifndef COMPONENTS_WEB_MODAL_SINGLE_POPUP_MANAGER_H_
6 #define COMPONENTS_WEB_MODAL_SINGLE_POPUP_MANAGER_H_
8 #include "components/web_modal/native_web_contents_modal_dialog.h"
10 namespace content {
11 class WebContents;
14 namespace web_modal {
16 // Interface from SinglePopupManager to PopupManager.
17 class SinglePopupManagerDelegate {
18 public:
19 SinglePopupManagerDelegate() {}
20 virtual ~SinglePopupManagerDelegate() {}
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;
26 private:
27 DISALLOW_COPY_AND_ASSIGN(SinglePopupManagerDelegate);
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.)
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() {}
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;
46 // Makes the popup visible.
47 virtual void Show() = 0;
49 // Hides the popup without closing it.
50 virtual void Hide() = 0;
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;
58 // Sets focus on the popup.
59 virtual void Focus() = 0;
61 // Pulsates the popup to draw the user's attention to it.
62 virtual void Pulse() = 0;
64 // Returns the popup under management by this object.
65 virtual NativePopup popup() = 0;
67 // Returns true if the popup under management was initiated by a user
68 // gesture. When this is true, the popup manager will hide any existing
69 // popups and move the newly-created NativePopup to the top of the display
70 // queue.
71 virtual bool HasUserGesture() = 0;
73 // Returns true if the popup under management is tolerant of being overlapped
74 // by other popups. This may be true for large web-modals which cover most of
75 // the window real estate (e.g. print preview).
76 virtual bool MayBeOverlapped() = 0;
78 // Returns true if the popup under management should close if there is a
79 // navigation underneath it, including the showing of any interstitial
80 // content. Popups which relate to the web content being displayed will
81 // ordinarily set this to true.
82 // TODO(gbillock): should be generalized in code location or by splitting
83 // the API to support the same-origin logic in WCMDM::DidNavigateMainFrame.
84 // TBD right now because we're not sure which knobs need to be set here.
85 virtual bool ShouldCloseOnNavigation() = 0;
87 protected:
88 SinglePopupManager() {}
90 private:
91 DISALLOW_COPY_AND_ASSIGN(SinglePopupManager);
94 } // namespace web_modal
96 #endif // COMPONENTS_WEB_MODAL_SINGLE_POPUP_MANAGER_H_