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

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: Add UI thread checks to controller 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
« no previous file with comments | « components/bubble/bubble_controller.h ('k') | components/bubble/bubble_delegate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 DCHECK(thread_checker_.CalledOnValidThread());
24 return manager_->CloseBubble(this->AsWeakPtr(), reason); 25 return manager_->CloseBubble(this->AsWeakPtr(), reason);
25 } 26 }
26 27
28 bool BubbleController::UpdateBubbleUi() {
29 DCHECK(thread_checker_.CalledOnValidThread());
30 if (!bubble_ui_)
31 return false;
32 return delegate_->UpdateBubbleUi(bubble_ui_.get());
33 }
34
27 void BubbleController::Show() { 35 void BubbleController::Show() {
28 DCHECK(!bubble_ui_); 36 DCHECK(!bubble_ui_);
29 bubble_ui_ = delegate_->BuildBubbleUI(); 37 bubble_ui_ = delegate_->BuildBubbleUi();
30 DCHECK(bubble_ui_); 38 DCHECK(bubble_ui_);
31 bubble_ui_->Show(AsWeakPtr()); 39 bubble_ui_->Show(AsWeakPtr());
32 // TODO(hcarmona): log that bubble was shown. 40 // TODO(hcarmona): log that bubble was shown.
33 } 41 }
34 42
35 void BubbleController::UpdateAnchorPosition() { 43 void BubbleController::UpdateAnchorPosition() {
36 DCHECK(bubble_ui_); 44 DCHECK(bubble_ui_);
37 bubble_ui_->UpdateAnchorPosition(); 45 bubble_ui_->UpdateAnchorPosition();
38 } 46 }
39 47
40 bool BubbleController::ShouldClose(BubbleCloseReason reason) { 48 bool BubbleController::ShouldClose(BubbleCloseReason reason) {
41 DCHECK(bubble_ui_); 49 DCHECK(bubble_ui_);
42 if (delegate_->ShouldClose(reason) || reason == BUBBLE_CLOSE_FORCED) { 50 if (delegate_->ShouldClose(reason) || reason == BUBBLE_CLOSE_FORCED) {
43 bubble_ui_->Close(); 51 bubble_ui_->Close();
44 bubble_ui_.reset(); 52 bubble_ui_.reset();
45 // TODO(hcarmona): log that bubble was hidden. 53 // TODO(hcarmona): log that bubble was hidden.
46 return true; 54 return true;
47 } 55 }
48 return false; 56 return false;
49 } 57 }
OLDNEW
« no previous file with comments | « components/bubble/bubble_controller.h ('k') | components/bubble/bubble_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698