OLD | NEW |
(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 "chrome/browser/ui/toolbar/test_toolbar_actions_bar_bubble_delegate.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 |
| 9 class TestToolbarActionsBarBubbleDelegate::DelegateImpl |
| 10 : public ToolbarActionsBarBubbleDelegate { |
| 11 public: |
| 12 explicit DelegateImpl(TestToolbarActionsBarBubbleDelegate* parent) |
| 13 : parent_(parent) {} |
| 14 ~DelegateImpl() override {} |
| 15 |
| 16 private: |
| 17 base::string16 GetHeadingText() override { return parent_->heading_; } |
| 18 base::string16 GetBodyText() override { return parent_->body_; } |
| 19 base::string16 GetActionButtonText() override { return parent_->action_; } |
| 20 base::string16 GetDismissButtonText() override { return parent_->dismiss_; } |
| 21 base::string16 GetLearnMoreButtonText() override { |
| 22 return parent_->learn_more_; |
| 23 } |
| 24 void OnBubbleShown() override { |
| 25 CHECK(!parent_->shown_); |
| 26 parent_->shown_ = true; |
| 27 } |
| 28 void OnBubbleClosed(CloseAction action) override { |
| 29 CHECK(!parent_->close_action_); |
| 30 parent_->close_action_.reset(new CloseAction(action)); |
| 31 } |
| 32 |
| 33 TestToolbarActionsBarBubbleDelegate* parent_; |
| 34 |
| 35 DISALLOW_COPY_AND_ASSIGN(DelegateImpl); |
| 36 }; |
| 37 |
| 38 TestToolbarActionsBarBubbleDelegate::TestToolbarActionsBarBubbleDelegate( |
| 39 const base::string16& heading, |
| 40 const base::string16& body, |
| 41 const base::string16& action) |
| 42 : shown_(false), |
| 43 heading_(heading), |
| 44 body_(body), |
| 45 action_(action) { |
| 46 } |
| 47 |
| 48 TestToolbarActionsBarBubbleDelegate::~TestToolbarActionsBarBubbleDelegate() { |
| 49 // If the bubble didn't close, it means that it still owns the DelegateImpl, |
| 50 // which has a weak ptr to this object. Make sure that this class always |
| 51 // outlives the bubble. |
| 52 CHECK(close_action_); |
| 53 } |
| 54 |
| 55 scoped_ptr<ToolbarActionsBarBubbleDelegate> |
| 56 TestToolbarActionsBarBubbleDelegate::GetDelegate() { |
| 57 return scoped_ptr<ToolbarActionsBarBubbleDelegate>(new DelegateImpl(this)); |
| 58 } |
OLD | NEW |