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

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
9 BubbleController::BubbleController(scoped_ptr<BubbleDelegate> delegate)
10 : delegate_(delegate.Pass()), bubble_ui_(nullptr), weak_ptr_factory_(this) {
11 DCHECK(delegate_);
12 }
13
14 BubbleController::~BubbleController() {}
15
16 void BubbleController::Show() {
17 if (bubble_ui_)
18 return;
19
20 // TODO(hcarmona): log that bubble was shown.
21 bubble_ui_ = delegate_->BuildBubbleUI();
22
23 DCHECK(bubble_ui_);
24 bubble_ui_->Show();
25 }
26
27 void BubbleController::Hide(BubbleCloseReason reason) {
msw 2015/08/13 03:37:22 nit: reason isn't used.
hcarmona 2015/08/15 02:03:19 Acknowledged.
28 if (!bubble_ui_)
msw 2015/08/13 03:37:22 nit: should we DCHECK against this?
hcarmona 2015/08/15 02:03:19 Done.
29 return;
30
31 // TODO(hcarmona): log that bubble was hidden.
32 bubble_ui_->Hide();
33 bubble_ui_.reset();
34 }
35
36 void BubbleController::UpdateAnchorPosition() {
37 DCHECK(bubble_ui_);
38 bubble_ui_->UpdateAnchorPosition();
39 }
40
41 bool BubbleController::ShouldUpdateBubble() {
msw 2015/08/13 03:37:22 nit: const?
hcarmona 2015/08/15 02:03:19 Acknowledged.
42 if (!bubble_ui_)
43 return true; // If UI isn't shown, then it can be udpated.
msw 2015/08/13 03:37:22 nit: updated spelling
msw 2015/08/13 03:37:22 Can you elaborate a bit more, how can UI that isn'
hcarmona 2015/08/15 02:03:19 This is specific to the permission bubbles. May no
44 return bubble_ui_->CanAcceptUpdate();
45 }
46
47 bool BubbleController::ShouldClose() const {
48 return delegate_->ShouldCloseOnHide();
49 }
50
51 void BubbleController::Close() {
52 weak_ptr_factory_.InvalidateWeakPtrs();
msw 2015/08/13 03:37:22 Huh? Is this instance going to be torn down now or
hcarmona 2015/08/13 20:50:35 Permission bubbles want to show another bubble whe
msw 2015/08/13 21:41:37 The permission code should attempt to show another
hcarmona 2015/08/15 02:03:19 Moved this to the destructor. Still explicitly cal
53 delegate_->DidClose();
54 }
55
56 bool BubbleController::MatchesContext(void* context) const {
57 return delegate_->GetContext() == context;
58 }
59
60 base::WeakPtr<BubbleController> BubbleController::AsWeakPtr() {
61 return weak_ptr_factory_.GetWeakPtr();
62 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698