Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(656)

Unified Diff: components/web_modal/popup_manager.h

Issue 287123002: [WebModals] New API for browser-scoped popup management. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..48dd0b3e7236afa3e059a9377305d8a20cd2eef4
--- /dev/null
+++ b/components/web_modal/popup_manager.h
@@ -0,0 +1,89 @@
+// 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 {
+struct FrameNavigateParams;
+struct LoadCommittedDetails;
+class WebContents;
+}
+
+namespace web_modal {
+
+// Per-Browser class to manage popups (bubbles, web-modal dialogs).
+class PopupManager : public SinglePopupManagerDelegate {
+ public:
+ PopupManager();
+
+ virtual ~PopupManager();
+
+ // 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.
+ void ShowPopup(scoped_ptr<SinglePopupManager> manager);
+
+ // Returns true if any popups are active and not closed in the
+ // currently-visible WebContents.
+ bool IsPopupActiveInCurrentWebContents() const;
msw 2014/05/22 04:08:45 As per the older comment thread, consider IsPopupA
Greg Billock 2014/05/22 18:25:47 I've brought call sites into the CL now, and there
msw 2014/05/22 21:40:02 That's totally reasonable, at least for now. If no
Greg Billock 2014/05/27 22:42:02 ok, let's head that direction. Added this API with
+
+ // Focus the topmost popup. IsPopupActiveInCurrentWebContents() must be true
msw 2014/05/22 04:08:45 Perhaps this should just be a no-op if IsPopupActi
Greg Billock 2014/05/22 18:25:47 Agreed.
+ // when calling this function.
+ void FocusTopmostPopup();
msw 2014/05/22 04:08:45 Can you describe what topmost means in the comment
Greg Billock 2014/05/22 18:25:47 I've changed this significantly, updated the comme
msw 2014/05/22 21:40:02 Oh jeez, you mean (1) a wcmd is shown for Tab A (2
Finnur 2014/05/23 15:29:52 This is anecdotal, but I think I've only used bubb
msw 2014/05/23 17:22:42 I'm very much in favor of any effort to reduce the
Greg Billock 2014/05/27 22:42:02 Do we have enough info in the SinglePopupManager t
+
+ // Called when a NativePopup we own is about to be closed.
+ virtual void WillClose(NativePopup popup) OVERRIDE;
+
+ private:
+ friend class PopupManagerTest;
+
+ struct PopupState {
msw 2014/05/22 04:08:45 How does this relate to SinglePopupManager itself?
Greg Billock 2014/05/22 18:25:47 Yeah, that was kind of a long-term plan for WCMDM.
+ PopupState(NativePopup popup, scoped_ptr<SinglePopupManager> manager);
+ ~PopupState();
+
+ NativePopup popup;
+ scoped_ptr<SinglePopupManager> manager;
+ bool close_on_interstitial_webui;
msw 2014/05/22 04:08:45 nit: I removed the corresponding flag from WCMDM's
Greg Billock 2014/05/22 18:25:47 Sensible. I added this as a field of the SinglePop
+ };
+
+ 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();
+
+ // 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_popups_;
+
+ // True while closing all popups.
+ bool closing_all_popups_;
+
+ DISALLOW_COPY_AND_ASSIGN(PopupManager);
+};
+
+} // namespace web_modal
+
+#endif // COMPONENTS_WEB_MODAL_POPUP_MANAGER_H_

Powered by Google App Engine
This is Rietveld 408576698