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

Side by Side Diff: components/bubble/bubble_controller.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: TESTS! Created 5 years, 4 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_controller.h"
6
7 #include "components/bubble/bubble_delegate.h"
8 #include "components/bubble/bubble_ui.h"
9
10 BubbleController::BubbleController(scoped_ptr<BubbleDelegate> delegate)
11 : delegate_(delegate.Pass()) {
12 DCHECK(delegate_);
13 }
14
15 BubbleController::~BubbleController() {
16 if (bubble_ui_)
17 ShouldClose(BUBBLE_CLOSE_FORCED);
18 }
19
20 void BubbleController::Show() {
21 DCHECK(!bubble_ui_);
22 bubble_ui_ = delegate_->BuildBubbleUI();
23 DCHECK(bubble_ui_);
24 bubble_ui_->Show();
25 // TODO(hcarmona): log that bubble was shown.
26 }
27
28 void BubbleController::UpdateAnchorPosition() {
29 DCHECK(bubble_ui_);
30 bubble_ui_->UpdateAnchorPosition();
31 }
32
33 bool BubbleController::ShouldClose(BubbleCloseReason reason) {
34 DCHECK(bubble_ui_);
35 if (delegate_->ShouldClose(reason) || reason == BUBBLE_CLOSE_FORCED) {
36 bubble_ui_->Close();
37 bubble_ui_.reset();
38 // TODO(hcarmona): log that bubble was hidden.
39 return true;
40 }
41 return false;
42 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698