| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/bubble/bubble_controller.h" | 5 #include "components/bubble/bubble_controller.h" |
| 6 | 6 |
| 7 #include "components/bubble/bubble_delegate.h" | 7 #include "components/bubble/bubble_delegate.h" |
| 8 #include "components/bubble/bubble_manager.h" | 8 #include "components/bubble/bubble_manager.h" |
| 9 #include "components/bubble/bubble_ui.h" | 9 #include "components/bubble/bubble_ui.h" |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 } | 21 } |
| 22 | 22 |
| 23 bool BubbleController::CloseBubble(BubbleCloseReason reason) { | 23 bool BubbleController::CloseBubble(BubbleCloseReason reason) { |
| 24 return manager_->CloseBubble(this->AsWeakPtr(), reason); | 24 return manager_->CloseBubble(this->AsWeakPtr(), reason); |
| 25 } | 25 } |
| 26 | 26 |
| 27 void BubbleController::Show() { | 27 void BubbleController::Show() { |
| 28 DCHECK(!bubble_ui_); | 28 DCHECK(!bubble_ui_); |
| 29 bubble_ui_ = delegate_->BuildBubbleUI(); | 29 bubble_ui_ = delegate_->BuildBubbleUI(); |
| 30 DCHECK(bubble_ui_); | 30 DCHECK(bubble_ui_); |
| 31 bubble_ui_->Show(); | 31 bubble_ui_->Show(AsWeakPtr()); |
| 32 // TODO(hcarmona): log that bubble was shown. | 32 // TODO(hcarmona): log that bubble was shown. |
| 33 } | 33 } |
| 34 | 34 |
| 35 void BubbleController::UpdateAnchorPosition() { | 35 void BubbleController::UpdateAnchorPosition() { |
| 36 DCHECK(bubble_ui_); | 36 DCHECK(bubble_ui_); |
| 37 bubble_ui_->UpdateAnchorPosition(); | 37 bubble_ui_->UpdateAnchorPosition(); |
| 38 } | 38 } |
| 39 | 39 |
| 40 bool BubbleController::ShouldClose(BubbleCloseReason reason) { | 40 bool BubbleController::ShouldClose(BubbleCloseReason reason) { |
| 41 DCHECK(bubble_ui_); | 41 DCHECK(bubble_ui_); |
| 42 if (delegate_->ShouldClose(reason) || reason == BUBBLE_CLOSE_FORCED) { | 42 if (delegate_->ShouldClose(reason) || reason == BUBBLE_CLOSE_FORCED) { |
| 43 bubble_ui_->Close(); | 43 bubble_ui_->Close(); |
| 44 bubble_ui_.reset(); | 44 bubble_ui_.reset(); |
| 45 // TODO(hcarmona): log that bubble was hidden. | 45 // TODO(hcarmona): log that bubble was hidden. |
| 46 return true; | 46 return true; |
| 47 } | 47 } |
| 48 return false; | 48 return false; |
| 49 } | 49 } |
| OLD | NEW |