Chromium Code Reviews| 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; |
| +} |