Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "components/bubble/bubble_controller.h" | |
| 6 | |
| 7 #include "components/bubble/bubble_delegate.h" | |
| 8 #include "components/bubble/bubble_manager.h" | |
| 9 | |
| 10 BubbleController::BubbleController(BubbleManager* manager, | |
| 11 scoped_ptr<BubbleDelegate> delegate) | |
| 12 : manager_(manager), delegate_(delegate.Pass()), bubble_ui_(nullptr) { | |
| 13 DCHECK(manager_); | |
| 14 DCHECK(delegate_); | |
| 15 } | |
| 16 | |
| 17 BubbleController::~BubbleController() {} | |
| 18 | |
| 19 void BubbleController::Show() { | |
| 20 if (bubble_ui_) | |
| 21 return; | |
| 22 | |
| 23 bubble_ui_ = delegate_->BuildBubbleUI(); | |
| 24 | |
| 25 DCHECK(bubble_ui_); | |
| 26 bubble_ui_->Show(); | |
| 27 } | |
| 28 | |
| 29 void BubbleController::Hide(BubbleCloseReason reason) { | |
| 30 if (!bubble_ui_) | |
| 31 return; | |
| 32 | |
| 33 bubble_ui_->Hide(); | |
| 34 bubble_ui_.reset(); | |
| 35 } | |
| 36 | |
| 37 void BubbleController::UpdateAnchorPosition() { | |
| 38 DCHECK(bubble_ui_); | |
| 39 bubble_ui_->UpdateAnchorPosition(); | |
| 40 } | |
| 41 | |
| 42 bool BubbleController::ShouldClose() { | |
| 43 return delegate_->CloseOnHide(); | |
| 44 } | |
| 45 | |
| 46 void BubbleController::Close() { | |
| 47 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
| |
| 48 delegate_->Finalize(); | |
| 49 } | |
| 50 | |
| 51 bool BubbleController::IsOwnerOf(BubbleDelegate* delegate) { | |
|
please use gerrit instead
2015/08/07 23:02:27
const *
| |
| 52 return delegate == delegate_.get(); | |
| 53 } | |
| 54 | |
| 55 bool BubbleController::MatchesContext(void* context) { | |
| 56 return delegate_->GetContext() == context; | |
| 57 } | |
| OLD | NEW |