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

Unified Diff: components/bubble/bubble_manager.h

Issue 1251633002: Add BubbleManager to manage bubbles and ChromeBubbleManager for events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mac Changes to test trybots Created 5 years, 4 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/bubble/bubble_manager.h
diff --git a/components/bubble/bubble_manager.h b/components/bubble/bubble_manager.h
new file mode 100644
index 0000000000000000000000000000000000000000..0a7ada341e39bd734c8747aa27886e675fa58500
--- /dev/null
+++ b/components/bubble/bubble_manager.h
@@ -0,0 +1,60 @@
+// Copyright 2015 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_BUBBLE_BUBBLE_MANAGER_H_
+#define COMPONENTS_BUBBLE_BUBBLE_MANAGER_H_
+
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/scoped_vector.h"
+#include "base/memory/weak_ptr.h"
+#include "components/bubble/bubble_delegate.h"
msw 2015/08/18 17:26:20 nit: forward declare BubbleDelegate instead.
hcarmona 2015/08/18 23:08:48 Including b/c of enum BubbleCloseReason.
msw 2015/08/19 00:18:11 Acknowledged.
+
+class BubbleController;
+
+// TODO(hcarmona): Don't expose BubbleController functions to users of this API.
msw 2015/08/18 17:26:20 nit: add warnings to the BubbleController function
hcarmona 2015/08/18 23:08:48 Done.
+typedef base::WeakPtr<BubbleController> BubbleReference;
+
+// Inherit from BubbleManager to show, update, and close bubbles.
+// Any class that inherits from BubbleManager should capture any events that
+// should dismiss a bubble or update its anchor point.
+// This class assumes that we won't be showing a lot of bubbles simultaneously.
+// TODO(hcarmona): Handle simultaneous bubbles. http://crbug.com/366937
+class BubbleManager {
+ public:
+ virtual ~BubbleManager();
+
+ // Shows a specific bubble and returns a reference to it.
+ // This reference should be used through the BubbleManager.
+ BubbleReference ShowBubble(scoped_ptr<BubbleDelegate> bubble);
+
+ // Close a specific bubble with a given reason.
+ // Returns true if the bubble was actually closed.
+ bool CloseBubble(BubbleReference bubble, BubbleCloseReason reason);
+
+ // Notify all bubbles that their anchor or parent may have changed.
+ void UpdateAllBubbleAnchors();
msw 2015/08/18 17:26:20 I think this should also be protected (that should
hcarmona 2015/08/18 23:08:48 Still needs to be public because we need to notify
msw 2015/08/19 00:18:11 Acknowledged.
+
+ protected:
+ BubbleManager();
+
+ // Notify all bubbles of a potential close event.
+ void CloseAllBubbles(BubbleCloseReason reason);
+
+ // Show a specific bubble.
+ virtual void ShowBubbleUI(base::WeakPtr<BubbleController> controller);
+
+ // Close a specific bubble.
+ virtual bool ShouldClose(base::WeakPtr<BubbleController> controller,
+ BubbleCloseReason reason);
+
+ // Update a specific bubble's anchor position.
+ virtual void UpdateAnchorPosition(base::WeakPtr<BubbleController> controller);
+
+ private:
+ ScopedVector<BubbleController> controllers_;
+
+ DISALLOW_COPY_AND_ASSIGN(BubbleManager);
+};
+
+#endif // COMPONENTS_BUBBLE_BUBBLE_MANAGER_H_

Powered by Google App Engine
This is Rietveld 408576698