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

Unified Diff: components/bubble/bubble_manager.cc

Issue 1251633002: Add BubbleManager to manage bubbles and ChromeBubbleManager for events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Kill views_bubble_controller Created 5 years, 5 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.cc
diff --git a/components/bubble/bubble_manager.cc b/components/bubble/bubble_manager.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a224aa46e956cf2f4cd3842b3853fb3286f85757
--- /dev/null
+++ b/components/bubble/bubble_manager.cc
@@ -0,0 +1,58 @@
+// 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.
+
+#include "components/bubble/bubble_manager.h"
+
+#include "components/bubble/bubble_delegate.h"
+
+BubbleManager::BubbleManager() {}
+
+BubbleManager::~BubbleManager() {
+ // The delegate should NOT outlive the manager. When a delegate is destroyed
+ // it should hide itself. This means that when the bubble manager is being
+ // destroyed there should be no visible bubbles.
+ DCHECK_EQ(controllers_.size(), 0);
+}
+
+void BubbleManager::ShowBubble(BubbleDelegate* bubble) {
+ // TODO(hcarmona): how to test this?
+ scoped_ptr<BubbleController> controller(new BubbleController(this, bubble));
+
+ controller->Show();
+ controllers_.push_back(controller.Pass());
+
+ // TODO(hcarmona): log that bubble was shown.
+}
+
+void BubbleManager::HideBubble(BubbleDelegate* delegate) {
+ for (auto iter = controllers_.begin(); iter != controllers_.end(); ++iter) {
+ if ((*iter)->IsOwnerOf(delegate)) {
+ (*iter)->Hide(BUBBLE_CLOSE_IGNORE);
+ return;
+ }
+ }
+
+ // Hidden/unmanaged bubbles should not be hidden: this could indicate a bug.
+ NOTREACHED();
+}
+
+bool BubbleManager::IsBubbleVisible(BubbleDelegate* bubble) {
+ // TODO(hcarmona): fix this.
+ return false;
+}
+
+void BubbleManager::UpdateBubblePosition(BubbleDelegate* bubble) {
+ // TODO(hcarmona): fix this.
+}
+
+void BubbleManager::NotifyBubbleHidden(BubbleController* controller,
+ BubbleCloseReason reason) {
+ // TODO(hcarmona): log the reason the bubble was closed.
+ // TODO(hcarmona): log the amount of time the bubble was shown.
+
+ // TODO(hcarmona): Should controllers die here?
+ ScopedVector<BubbleController>::iterator iter =
+ std::find(controllers_.begin(), controllers_.end(), controller);
+ controllers_.erase(iter);
+}

Powered by Google App Engine
This is Rietveld 408576698