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

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

Issue 1310483003: Add ability for a BubbleReference to update the BubbleUI. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bm-reference-own-file.gitbr
Patch Set: Created 5 years, 3 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/bubble/bubble_controller.h" 5 #include "components/bubble/bubble_controller.h"
6 6
7 #include "components/bubble/bubble_delegate.h" 7 #include "components/bubble/bubble_delegate.h"
8 #include "components/bubble/bubble_manager.h" 8 #include "components/bubble/bubble_manager.h"
9 #include "components/bubble/bubble_ui.h" 9 #include "components/bubble/bubble_ui.h"
10 10
11 BubbleController::BubbleController(BubbleManager* manager, 11 BubbleController::BubbleController(BubbleManager* manager,
12 scoped_ptr<BubbleDelegate> delegate) 12 scoped_ptr<BubbleDelegate> delegate)
13 : manager_(manager), delegate_(delegate.Pass()) { 13 : manager_(manager), delegate_(delegate.Pass()) {
14 DCHECK(manager_); 14 DCHECK(manager_);
15 DCHECK(delegate_); 15 DCHECK(delegate_);
16 } 16 }
17 17
18 BubbleController::~BubbleController() { 18 BubbleController::~BubbleController() {
19 if (bubble_ui_) 19 if (bubble_ui_)
20 ShouldClose(BUBBLE_CLOSE_FORCED); 20 ShouldClose(BUBBLE_CLOSE_FORCED);
21 } 21 }
22 22
23 bool BubbleController::CloseBubble(BubbleCloseReason reason) { 23 bool BubbleController::CloseBubble(BubbleCloseReason reason) {
24 return manager_->CloseBubble(this->AsWeakPtr(), reason); 24 return manager_->CloseBubble(this->AsWeakPtr(), reason);
25 } 25 }
26 26
27 bool BubbleController::UpdateBubbleUI() {
28 return manager_->UpdateBubbleUI(this->AsWeakPtr());
groby-ooo-7-16 2015/09/03 17:30:01 Does this need to flow through the manager? Who us
hcarmona 2015/09/03 18:05:53 Going through the manager ensures that we stay on
groby-ooo-7-16 2015/09/03 19:13:58 Do we _need_ to ensure that? And if we do, let's e
29 }
30
27 void BubbleController::Show() { 31 void BubbleController::Show() {
28 DCHECK(!bubble_ui_); 32 DCHECK(!bubble_ui_);
29 bubble_ui_ = delegate_->BuildBubbleUI(); 33 bubble_ui_ = delegate_->BuildBubbleUI();
30 DCHECK(bubble_ui_); 34 DCHECK(bubble_ui_);
31 bubble_ui_->Show(AsWeakPtr()); 35 bubble_ui_->Show(AsWeakPtr());
32 // TODO(hcarmona): log that bubble was shown. 36 // TODO(hcarmona): log that bubble was shown.
33 } 37 }
34 38
35 void BubbleController::UpdateAnchorPosition() { 39 void BubbleController::UpdateAnchorPosition() {
36 DCHECK(bubble_ui_); 40 DCHECK(bubble_ui_);
37 bubble_ui_->UpdateAnchorPosition(); 41 bubble_ui_->UpdateAnchorPosition();
38 } 42 }
39 43
40 bool BubbleController::ShouldClose(BubbleCloseReason reason) { 44 bool BubbleController::ShouldClose(BubbleCloseReason reason) {
41 DCHECK(bubble_ui_); 45 DCHECK(bubble_ui_);
42 if (delegate_->ShouldClose(reason) || reason == BUBBLE_CLOSE_FORCED) { 46 if (delegate_->ShouldClose(reason) || reason == BUBBLE_CLOSE_FORCED) {
43 bubble_ui_->Close(); 47 bubble_ui_->Close();
44 bubble_ui_.reset(); 48 bubble_ui_.reset();
45 // TODO(hcarmona): log that bubble was hidden. 49 // TODO(hcarmona): log that bubble was hidden.
46 return true; 50 return true;
47 } 51 }
48 return false; 52 return false;
49 } 53 }
54
55 bool BubbleController::UpdateBubbleUIInternal() {
groby-ooo-7-16 2015/09/03 17:30:01 I decidedly dislike "Internal" functions. If we do
hcarmona 2015/09/03 18:05:53 Done.
56 if (!bubble_ui_)
57 return false;
58 return delegate_->UpdateBubbleUI(bubble_ui_.get());
59 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698