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 #include "components/bubble/bubble_ui.h" | |
| 10 | |
| 11 BubbleController::BubbleController(BubbleManager* manager, | |
| 12 scoped_ptr<BubbleDelegate> delegate) | |
| 13 : manager_(manager), delegate_(delegate.Pass()) { | |
| 14 DCHECK(manager_); | |
| 15 DCHECK(delegate_); | |
| 16 } | |
| 17 | |
| 18 BubbleController::~BubbleController() { | |
| 19 if (bubble_ui_) | |
| 20 ShouldClose(BUBBLE_CLOSE_FORCED); | |
| 21 } | |
| 22 | |
| 23 bool BubbleController::CloseBubble(BubbleCloseReason reason) { | |
| 24 return manager_->CloseBubble(this->AsWeakPtr(), reason); | |
| 25 } | |
| 26 | |
| 27 void BubbleController::Show() { | |
| 28 DCHECK(!bubble_ui_); | |
| 29 bubble_ui_ = delegate_->BuildBubbleUI(); | |
| 30 DCHECK(bubble_ui_); | |
| 31 bubble_ui_->Show(); | |
| 32 // TODO(hcarmona): log that bubble was shown. | |
| 33 } | |
| 34 | |
| 35 void BubbleController::UpdateAnchorPosition() { | |
| 36 DCHECK(bubble_ui_); | |
| 37 bubble_ui_->UpdateAnchorPosition(); | |
| 38 } | |
| 39 | |
| 40 bool BubbleController::ShouldClose(BubbleCloseReason reason) { | |
| 41 DCHECK(bubble_ui_); | |
| 42 if (delegate_->ShouldClose(reason) || reason == BUBBLE_CLOSE_FORCED) { | |
| 43 bubble_ui_->Close(); | |
|
msw
2015/08/26 01:42:36
I wonder if BubbleUI::Close is needed or if its dt
hcarmona
2015/08/26 17:25:58
I like having both |Close| and |Show| because it m
msw
2015/08/26 20:29:09
Acknowledged.
| |
| 44 bubble_ui_.reset(); | |
| 45 // TODO(hcarmona): log that bubble was hidden. | |
| 46 return true; | |
| 47 } | |
| 48 return false; | |
| 49 } | |
| OLD | NEW |