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