| 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_manager.h" |
| 6 |
| 7 #include "components/bubble/bubble_delegate.h" |
| 8 |
| 9 BubbleManager::BubbleManager(BubbleController::Factory controller_factory) |
| 10 : controller_factory_(controller_factory) {} |
| 11 |
| 12 BubbleManager::~BubbleManager() { |
| 13 // The delegate should NOT outlive the manager. When a delegate is destroyed |
| 14 // it should hide itself. This means that when the bubble manager is being |
| 15 // destroyed there should be no visible bubbles. |
| 16 DCHECK_EQ(controllers_.size(), 0); |
| 17 } |
| 18 |
| 19 void BubbleManager::ShowBubble(BubbleDelegate* bubble) { |
| 20 scoped_ptr<BubbleController> controller = |
| 21 controller_factory_.Run(this, bubble); |
| 22 |
| 23 controller->Show(); |
| 24 controllers_.push_back(controller.Pass()); |
| 25 |
| 26 // TODO(hcarmona): log that bubble was shown. |
| 27 } |
| 28 |
| 29 void BubbleManager::HideBubble(BubbleDelegate* delegate) { |
| 30 for (auto iter = controllers_.begin(); iter != controllers_.end(); ++iter) { |
| 31 if ((*iter)->IsOwnerOf(delegate)) { |
| 32 (*iter)->Hide(BUBBLE_CLOSE_IGNORE); |
| 33 return; |
| 34 } |
| 35 } |
| 36 |
| 37 // Hidden/unmanaged bubbles should not be hidden: this could indicate a bug. |
| 38 NOTREACHED(); |
| 39 } |
| 40 |
| 41 bool BubbleManager::IsBubbleVisible(BubbleDelegate* bubble) { |
| 42 // TODO(hcarmona): fix this. |
| 43 return false; |
| 44 } |
| 45 |
| 46 void BubbleManager::UpdateBubblePosition(BubbleDelegate* bubble) { |
| 47 // TODO(hcarmona): fix this. |
| 48 } |
| 49 |
| 50 void BubbleManager::NotifyBubbleHidden(BubbleController* controller, |
| 51 BubbleCloseReason reason) { |
| 52 // TODO(hcarmona): log the reason the bubble was closed. |
| 53 // TODO(hcarmona): log the amount of time the bubble was shown. |
| 54 |
| 55 // TODO(hcarmona): Should controllers die here? |
| 56 ScopedVector<BubbleController>::iterator iter = |
| 57 std::find(controllers_.begin(), controllers_.end(), controller); |
| 58 controllers_.erase(iter); |
| 59 } |
| OLD | NEW |