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..f62408f24aacff37ca4cff4fe65e0616019c6f5a |
| --- /dev/null |
| +++ b/components/web_modal/popup_manager.h |
| @@ -0,0 +1,90 @@ |
| +// 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 <deque> |
| + |
| +#include "base/memory/scoped_ptr.h" |
| +#include "components/web_modal/single_popup_manager.h" |
| +#include "content/public/browser/web_contents_user_data.h" |
| +#include "ui/gfx/native_widget_types.h" |
| + |
| +namespace content { |
| +class FrameNavigateParams; |
| +struct LoadCommittedDetails; |
| +class WebContents; |
| +} |
| + |
| +namespace web_modal { |
| + |
| +// Per-Browser class to manage popups (bubbles, web-modal dialogs). |
| +class PopupManager : public SinglePopupManagerDelegate { |
|
Finnur
2014/05/16 12:38:14
What is the scope/lifetime of this object?
Greg Billock
2014/05/16 15:49:56
Good question. I'm not sure how to manage creation
|
| + public: |
| + virtual ~PopupManager(); |
| + |
| + // Schedules a popup governed by the |manager| to be shown. The popup |
| + // may not be shown inline with this call, at a later asynchronous time, |
|
Finnur
2014/05/16 12:38:14
s/not// ?
s/asynchronous// ?
Greg Billock
2014/05/20 19:27:55
Done.
|
| + // or not at all. |
| + void ShowPopup(scoped_ptr<SinglePopupManager> manager); |
| + |
| + // Returns true if any popups are active and not closed in the |
| + // currently-visible WebContents. |
| + bool IsPopupActiveInCurrentWebContents() const; |
|
Finnur
2014/05/16 12:38:14
The WebContents association here I found a bit sur
Greg Billock
2014/05/16 15:49:56
I don't know that this method survives. The intent
msw
2014/05/16 17:10:57
This part of the API could be more agnostic about
Greg Billock
2014/05/16 23:28:39
That sounds good to me. We could also just wait to
msw
2014/05/22 04:08:45
Even if it doesn't make sense to replace this with
Greg Billock
2014/05/22 18:25:47
reworked this substantially
|
| + |
| + // Focus the topmost popup. IsPopupActiveInCurrentWebContents() must be true |
| + // when calling this function. |
|
Finnur
2014/05/16 12:38:14
From purely an API standpoint (not looking at the
Greg Billock
2014/05/16 15:49:56
This is in the per-WC API for use by the WC view d
Mike Wittman
2014/05/16 20:35:40
The purpose of this function on the WCMD side is t
Greg Billock
2014/05/16 23:28:39
Overall, do you think it should be a design goal t
Mike Wittman
2014/05/17 00:24:06
Yes, I'd prefer to see this encompass the WCMDM fu
msw
2014/05/20 16:51:32
I'd also like this class to replace WCMDM, but per
Greg Billock
2014/05/20 19:27:55
No. I'm planning on this CL basically being a plac
|
| + void FocusTopmostPopup(); |
|
Finnur
2014/05/16 12:38:14
This function is not called at the moment. Who do
Greg Billock
2014/05/22 18:25:47
added call site to cl
|
| + |
| + // Called when a NativePopup we own is about to be closed. |
| + virtual void WillClose(NativePopup popup) OVERRIDE; |
|
Finnur
2014/05/16 12:38:14
At the moment only called by the test, which is al
Greg Billock
2014/05/16 15:49:56
Right. This is the main entry point for SinglePopu
msw
2014/05/16 17:10:57
Can't notifications of closure be handled through
Mike Wittman
2014/05/16 20:35:40
That's how it's currently done for WCMDs: the View
Greg Billock
2014/05/16 23:28:39
That's correct. If we had a cross-platform "Widget
|
| + |
| + private: |
| + friend class PopupManagerTest; |
| + |
| + explicit PopupManager(); |
|
Finnur
2014/05/16 12:38:14
nit: explicit?
Greg Billock
2014/05/20 19:27:55
Done.
|
| + |
| + struct PopupState { |
| + PopupState(NativePopup popup, scoped_ptr<SinglePopupManager> manager); |
| + ~PopupState(); |
| + |
| + NativePopup popup; |
| + scoped_ptr<SinglePopupManager> manager; |
| + bool close_on_interstitial_webui; |
| + }; |
| + |
| + typedef std::deque<PopupState*> PopupList; |
| + |
| + // Utility function to get the state for a popup. |
| + PopupList::iterator FindPopupState(NativePopup popup); |
| + |
| + // Blocks/unblocks interaction with renderer process. |
| + void BlockWebContentsInteraction(bool blocked); |
| + |
| + void CloseAllPopups(); |
|
Finnur
2014/05/16 12:38:14
This is currently private. Won't this need to be p
Greg Billock
2014/05/16 15:49:56
Shouldn't need to be. It isn't in the current WCMD
|
| + |
| + // Notified from content::WebContentsObserver: |
| + void DidNavigateMainFrame( |
| + content::WebContents* web_contents, |
| + const content::LoadCommittedDetails& details, |
| + const content::FrameNavigateParams& params); |
| + void DidGetIgnoredUIEvent(content::WebContents* web_contents); |
| + void WasShown(content::WebContents* web_contents); |
| + void WasHidden(content::WebContents* web_contents); |
| + void WebContentsDestroyed(content::WebContents* web_contents); |
| + void DidAttachInterstitialPage(content::WebContents* web_contents); |
| + |
| + // All active popups. |
| + PopupList child_dialogs_; |
|
Finnur
2014/05/16 12:38:14
We seem to be conflating dialogs and popups (bubbl
Greg Billock
2014/05/16 15:49:56
Yeah, I thought I got them all in the .h file, but
Greg Billock
2014/05/20 19:27:55
Done.
|
| + |
| + // True while closing all popups. |
| + bool closing_all_popups_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(PopupManager); |
| +}; |
| + |
| +} // namespace web_modal |
| + |
| +#endif // COMPONENTS_WEB_MODAL_POPUP_MANAGER_H_ |