| 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_ui.h" |
| 9 |
| 10 BubbleController::BubbleController(scoped_ptr<BubbleDelegate> delegate) |
| 11 : delegate_(delegate.Pass()) { |
| 12 DCHECK(delegate_); |
| 13 } |
| 14 |
| 15 BubbleController::~BubbleController() { |
| 16 if (bubble_ui_) |
| 17 ShouldClose(BUBBLE_CLOSE_FORCED); |
| 18 } |
| 19 |
| 20 void BubbleController::Show() { |
| 21 DCHECK(!bubble_ui_); |
| 22 bubble_ui_ = delegate_->BuildBubbleUI(); |
| 23 DCHECK(bubble_ui_); |
| 24 bubble_ui_->Show(); |
| 25 // TODO(hcarmona): log that bubble was shown. |
| 26 } |
| 27 |
| 28 void BubbleController::UpdateAnchorPosition() { |
| 29 DCHECK(bubble_ui_); |
| 30 bubble_ui_->UpdateAnchorPosition(); |
| 31 } |
| 32 |
| 33 bool BubbleController::ShouldClose(BubbleCloseReason reason) { |
| 34 DCHECK(bubble_ui_); |
| 35 if (delegate_->ShouldClose(reason) || reason == BUBBLE_CLOSE_FORCED) { |
| 36 bubble_ui_->Close(); |
| 37 bubble_ui_.reset(); |
| 38 // TODO(hcarmona): log that bubble was hidden. |
| 39 return true; |
| 40 } |
| 41 return false; |
| 42 } |
| OLD | NEW |