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

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: Apply Feedback 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_manager.h"
9
10 BubbleController::BubbleController(BubbleManager* manager,
11 scoped_ptr<BubbleDelegate> delegate)
12 : manager_(manager), delegate_(delegate.Pass()), bubble_ui_(nullptr) {
13 DCHECK(manager_);
14 DCHECK(delegate_);
15 }
16
17 BubbleController::~BubbleController() {}
18
19 void BubbleController::Show() {
20 if (bubble_ui_)
21 return;
22
23 bubble_ui_ = delegate_->BuildBubbleUI();
24
25 DCHECK(bubble_ui_);
26 bubble_ui_->Show();
27 }
28
29 void BubbleController::Hide(BubbleCloseReason reason) {
30 if (!bubble_ui_)
groby-ooo-7-16 2015/08/06 21:32:56 Wait, we don't seem to handle CloseOnHide?
hcarmona 2015/08/07 02:12:59 It's handled in the manager.
31 return;
32
33 bubble_ui_->Hide();
34 bubble_ui_.reset();
35 }
36
37 void BubbleController::UpdateAnchorPosition() {
38 DCHECK(bubble_ui_);
39 bubble_ui_->UpdateAnchorPosition();
40 }
41
42 bool BubbleController::ShouldClose() {
43 return delegate_->CloseOnHide();
44 }
45
46 void BubbleController::Close() {
47 delegate_->weak_ptr_factory.InvalidateWeakPtrs();
48 delegate_->Finalize();
49 }
50
51 bool BubbleController::IsOwnerOf(BubbleDelegate* delegate) {
52 return delegate == delegate_.get();
53 }
54
55 bool BubbleController::MatchesContext(void* context) {
56 return delegate_->GetContext() == context;
57 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698