Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Side by Side Diff: components/bubble/bubble_manager.cc

Issue 1251633002: Add BubbleManager to manage bubbles and ChromeBubbleManager for events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Work in Progress Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698