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

Unified Diff: components/bubble/bubble_controller.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: Partial Feedback 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_controller.cc
diff --git a/components/bubble/bubble_controller.cc b/components/bubble/bubble_controller.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e9ba3a6f74b24c12d1b93f717d941adf3fcc3305
--- /dev/null
+++ b/components/bubble/bubble_controller.cc
@@ -0,0 +1,57 @@
+// 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_controller.h"
+
+#include "components/bubble/bubble_delegate.h"
+#include "components/bubble/bubble_manager.h"
+
+BubbleController::BubbleController(BubbleManager* manager,
+ scoped_ptr<BubbleDelegate> delegate)
+ : manager_(manager), delegate_(delegate.Pass()), bubble_ui_(nullptr) {
+ DCHECK(manager_);
+ DCHECK(delegate_);
+}
+
+BubbleController::~BubbleController() {}
+
+void BubbleController::Show() {
+ if (bubble_ui_)
+ return;
+
+ bubble_ui_ = delegate_->BuildBubbleUI();
+
+ DCHECK(bubble_ui_);
+ bubble_ui_->Show();
+}
+
+void BubbleController::Hide(BubbleCloseReason reason) {
+ if (!bubble_ui_)
+ return;
+
+ bubble_ui_->Hide();
+ bubble_ui_.reset();
+}
+
+void BubbleController::UpdateAnchorPosition() {
+ DCHECK(bubble_ui_);
+ bubble_ui_->UpdateAnchorPosition();
+}
+
+bool BubbleController::ShouldClose() {
+ return delegate_->CloseOnHide();
+}
+
+void BubbleController::Close() {
+ delegate_->weak_ptr_factory.InvalidateWeakPtrs();
please use gerrit instead 2015/08/07 23:02:27 not super happy about reaching into delegate's fac
hcarmona 2015/08/11 02:35:46 No longer necessary! Factory has moved to this cla
+ delegate_->Finalize();
+}
+
+bool BubbleController::IsOwnerOf(BubbleDelegate* delegate) {
please use gerrit instead 2015/08/07 23:02:27 const *
+ return delegate == delegate_.get();
+}
+
+bool BubbleController::MatchesContext(void* context) {
+ return delegate_->GetContext() == context;
+}

Powered by Google App Engine
This is Rietveld 408576698