Chromium Code Reviews| Index: components/web_modal/popup_manager.h |
| diff --git a/components/web_modal/popup_manager.h b/components/web_modal/popup_manager.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..3f7e6d7c80e483ac1ca5c068e0888b9184dc3ba2 |
| --- /dev/null |
| +++ b/components/web_modal/popup_manager.h |
| @@ -0,0 +1,82 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef COMPONENTS_WEB_MODAL_POPUP_MANAGER_H_ |
| +#define COMPONENTS_WEB_MODAL_POPUP_MANAGER_H_ |
| + |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "components/web_modal/single_popup_manager.h" |
| + |
| +namespace content { |
| +class WebContents; |
| +} |
| + |
| +namespace gfx { |
| +class Size; |
| +} |
| + |
| +namespace web_modal { |
| + |
| +class WebContentsModalDialogHost; |
| + |
| +// Per-Browser class to manage popups (bubbles, web-modal dialogs). |
| +class PopupManager : public SinglePopupManagerDelegate { |
| + public: |
| + PopupManager(WebContentsModalDialogHost* host); |
| + |
| + virtual ~PopupManager(); |
| + |
| + // Returns the native view which will be the parent of managed popups. |
| + virtual gfx::NativeView GetHostView() const; |
| + |
| + // Schedules a popup governed by the |manager| to be shown. The popup |
| + // may be shown inline with this call, at a later time, or not at all. |
| + virtual void ShowPopup(scoped_ptr<SinglePopupManager> manager); |
| + |
| + // Temporary method: Provides compatibility with existing |
| + // WebContentsModalDialogManager code. |
| + virtual void ShowModalDialog(NativePopup popup, |
| + content::WebContents* web_contents); |
| + |
| + // Returns true if a web modal dialog is active and not closed in the |
| + // given |web_contents|. Note: this is intended for legacy use only; it will |
| + // be deleted at some point -- new code shouldn't use it. |
| + virtual bool IsWebModalDialogActive( |
| + const content::WebContents* web_contents) const; |
| + |
| + // Called when a NativePopup we own is about to be closed. |
| + virtual void WillClose(NativePopup popup) OVERRIDE; |
| + |
| + // Called by views code to re-activate popups anchored to a particular tab |
| + // when that tab gets focus. Note that depending on the situation, more than |
| + // one popup may actually be shown (depending on overlappability). The |
| + // semantics are that the popups that would have been displayed had the tab |
| + // never lost focus are re-focused when tab focus is regained. |
| + virtual void WasFocused(const content::WebContents* web_contents); |
| + |
| + // WebContentsUserData-alike API for retrieving the associated window |
| + // PopupManager from a |web_contents|. Any window which doesn't have a popup |
| + // manager associated will return null -- popups should not be issued against |
| + // that window. |
| + static PopupManager* FromWebContents(content::WebContents* web_contents); |
| + |
| + // Should not be called except by WebContents-owning class; not by clients. |
| + void RegisterWith(content::WebContents* web_contents); |
| + void UnregisterWith(content::WebContents* web_contents); |
|
benwells
2014/07/02 05:16:30
Please explain when you should and shouldn't unreg
Greg Billock
2014/07/02 15:44:12
You mean for clients? You shouldn't.
The reason t
|
| + |
| + // DEPRECATED. |
|
benwells
2014/07/02 05:16:30
Why is there a deprecated function in new code?
Greg Billock
2014/07/02 15:44:12
We're inheriting a bunch of code from WebContentsM
|
| + virtual void CloseAllDialogsForTesting(content::WebContents* web_contents); |
| + |
| + private: |
| + WebContentsModalDialogHost* host_; |
| + |
| + base::WeakPtrFactory<PopupManager> weak_factory_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(PopupManager); |
| +}; |
| + |
| +} // namespace web_modal |
| + |
| +#endif // COMPONENTS_WEB_MODAL_POPUP_MANAGER_H_ |