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

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: TESTS! 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..88dde9d05da356f94fee595c70073150a1d62722
--- /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"
+
+class BubbleController;
+
+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.
msw 2015/08/21 01:48:31 nit: // Notify a specific bubble of an event that
hcarmona 2015/08/25 02:13:37 Done.
+ // 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();
+
+ protected:
+ BubbleManager();
+
+ // Notify all bubbles of a potential close event.
msw 2015/08/21 01:48:31 // Notify all bubbles of an event that might trigg
hcarmona 2015/08/25 02:13:37 Done.
+ void CloseAllBubbles(BubbleCloseReason reason);
+
+ private:
+ // Show any bubbles that were added to show_queue_.
msw 2015/08/21 01:48:31 nit: |show_queue_|
hcarmona 2015/08/25 02:13:37 Done.
+ void ShowPendingBubbles();
+
+ // This will be false once the BubbleManager is being destroyed to prevent
msw 2015/08/21 01:48:31 nit: consider something like "A flag used to delay
hcarmona 2015/08/25 02:13:37 Renamed to |manager_state_| and updated the commen
+ // bubbles from adding additional bubbles when they're being cleaned up.
+ bool can_show_bubbles_;
+
+ // The bubbles that are being managed.
+ ScopedVector<BubbleController> controllers_;
+
+ // If a closing bubble needs to show another bubble, it will go here.
msw 2015/08/21 01:48:31 nit: // The bubbles queued to be shown when possib
hcarmona 2015/08/25 02:13:37 Done.
+ scoped_ptr<ScopedVector<BubbleController>> show_queue_;
msw 2015/08/21 01:48:31 Consider keeping this as a ScopedVector that's alw
hcarmona 2015/08/25 02:13:37 Done.
+
+ DISALLOW_COPY_AND_ASSIGN(BubbleManager);
+};
+
+#endif // COMPONENTS_BUBBLE_BUBBLE_MANAGER_H_

Powered by Google App Engine
This is Rietveld 408576698