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..f8f75e46e0c24653d3f5dc8fe5385e96f28e62cd |
--- /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 wth existing |
Finnur
2014/06/30 13:53:36
typo: s/wth/with/
Greg Billock
2014/07/01 00:53:05
Done.
|
+ // 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); |
Finnur
2014/06/30 13:53:36
There's no subclass overriding this. Do you need |
Greg Billock
2014/07/01 00:53:05
Allows for test mocks to override it. This lets us
|
+ |
+ // SupportsUserData-alike API for retrieving the associated window |
Finnur
2014/06/30 13:53:36
nit: s/SupportsUserData/Supports UserData/
Greg Billock
2014/07/01 00:53:04
Called it WebContentsUserData-alike, which is bett
|
+ // 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); |
+ |
+ // DEPRECATED. |
+ virtual void CloseAllDialogsForTesting(content::WebContents* web_contents); |
Finnur
2014/06/30 13:53:36
Does this need to be virtual?
Greg Billock
2014/07/01 00:53:04
Probably not.
|
+ |
+ private: |
+ WebContentsModalDialogHost* host_; |
+ |
+ base::WeakPtrFactory<PopupManager> weak_factory_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(PopupManager); |
+}; |
+ |
+} // namespace web_modal |
+ |
+#endif // COMPONENTS_WEB_MODAL_POPUP_MANAGER_H_ |