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

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

Powered by Google App Engine
This is Rietveld 408576698