Apply _RELATIVE relocations ahead of others.
[chromium-blink-merge.git] / components / web_modal / popup_manager.h
blob9d0c9fb7216e3af5bdb04295be6be9f7815a09fe
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_POPUP_MANAGER_H_
6 #define COMPONENTS_WEB_MODAL_POPUP_MANAGER_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/weak_ptr.h"
10 #include "components/web_modal/single_popup_manager.h"
12 namespace content {
13 class WebContents;
16 namespace gfx {
17 class Size;
20 namespace web_modal {
22 class WebContentsModalDialogHost;
24 // Per-Browser class to manage popups (bubbles, web-modal dialogs).
25 class PopupManager : public SinglePopupManagerDelegate {
26 public:
27 // |host| may be null.
28 PopupManager(WebContentsModalDialogHost* host);
30 ~PopupManager() override;
32 // Returns the native view which will be the parent of managed popups.
33 virtual gfx::NativeView GetHostView() const;
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.
37 virtual void ShowPopup(scoped_ptr<SinglePopupManager> manager);
39 // Temporary method: Provides compatibility with existing
40 // WebContentsModalDialogManager code.
41 virtual void ShowModalDialog(NativePopup popup,
42 content::WebContents* web_contents);
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
46 // be deleted at some point -- new code shouldn't use it.
47 virtual bool IsWebModalDialogActive(
48 const content::WebContents* web_contents) const;
50 // Called when a NativePopup we own is about to be closed.
51 void WillClose(NativePopup popup) override;
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
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
57 // never lost focus are re-focused when tab focus is regained.
58 virtual void WasFocused(const content::WebContents* web_contents);
60 // WebContentsUserData-alike API for retrieving the associated window
61 // PopupManager from a |web_contents|. Any window which doesn't have a popup
62 // manager associated will return null -- popups should not be issued against
63 // that window.
64 static PopupManager* FromWebContents(content::WebContents* web_contents);
66 // Should not be called except by WebContents-owning class; not by clients.
67 void RegisterWith(content::WebContents* web_contents);
68 void UnregisterWith(content::WebContents* web_contents);
70 // DEPRECATED.
71 virtual void CloseAllDialogsForTesting(content::WebContents* web_contents);
73 private:
74 WebContentsModalDialogHost* host_;
76 base::WeakPtrFactory<PopupManager> weak_factory_;
78 DISALLOW_COPY_AND_ASSIGN(PopupManager);
81 } // namespace web_modal
83 #endif // COMPONENTS_WEB_MODAL_POPUP_MANAGER_H_