| Index: components/bubble/bubble_manager.cc
|
| diff --git a/components/bubble/bubble_manager.cc b/components/bubble/bubble_manager.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..a224aa46e956cf2f4cd3842b3853fb3286f85757
|
| --- /dev/null
|
| +++ b/components/bubble/bubble_manager.cc
|
| @@ -0,0 +1,58 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "components/bubble/bubble_manager.h"
|
| +
|
| +#include "components/bubble/bubble_delegate.h"
|
| +
|
| +BubbleManager::BubbleManager() {}
|
| +
|
| +BubbleManager::~BubbleManager() {
|
| + // The delegate should NOT outlive the manager. When a delegate is destroyed
|
| + // it should hide itself. This means that when the bubble manager is being
|
| + // destroyed there should be no visible bubbles.
|
| + DCHECK_EQ(controllers_.size(), 0);
|
| +}
|
| +
|
| +void BubbleManager::ShowBubble(BubbleDelegate* bubble) {
|
| + // TODO(hcarmona): how to test this?
|
| + scoped_ptr<BubbleController> controller(new BubbleController(this, bubble));
|
| +
|
| + controller->Show();
|
| + controllers_.push_back(controller.Pass());
|
| +
|
| + // TODO(hcarmona): log that bubble was shown.
|
| +}
|
| +
|
| +void BubbleManager::HideBubble(BubbleDelegate* delegate) {
|
| + for (auto iter = controllers_.begin(); iter != controllers_.end(); ++iter) {
|
| + if ((*iter)->IsOwnerOf(delegate)) {
|
| + (*iter)->Hide(BUBBLE_CLOSE_IGNORE);
|
| + return;
|
| + }
|
| + }
|
| +
|
| + // Hidden/unmanaged bubbles should not be hidden: this could indicate a bug.
|
| + NOTREACHED();
|
| +}
|
| +
|
| +bool BubbleManager::IsBubbleVisible(BubbleDelegate* bubble) {
|
| + // TODO(hcarmona): fix this.
|
| + return false;
|
| +}
|
| +
|
| +void BubbleManager::UpdateBubblePosition(BubbleDelegate* bubble) {
|
| + // TODO(hcarmona): fix this.
|
| +}
|
| +
|
| +void BubbleManager::NotifyBubbleHidden(BubbleController* controller,
|
| + BubbleCloseReason reason) {
|
| + // TODO(hcarmona): log the reason the bubble was closed.
|
| + // TODO(hcarmona): log the amount of time the bubble was shown.
|
| +
|
| + // TODO(hcarmona): Should controllers die here?
|
| + ScopedVector<BubbleController>::iterator iter =
|
| + std::find(controllers_.begin(), controllers_.end(), controller);
|
| + controllers_.erase(iter);
|
| +}
|
|
|