| OLD | NEW |
| 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 "chrome/browser/ui/toolbar/test_toolbar_actions_bar_bubble_delegate.h" | 5 #include "chrome/browser/ui/toolbar/test_toolbar_actions_bar_bubble_delegate.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/ptr_util.h" |
| 9 | 10 |
| 10 class TestToolbarActionsBarBubbleDelegate::DelegateImpl | 11 class TestToolbarActionsBarBubbleDelegate::DelegateImpl |
| 11 : public ToolbarActionsBarBubbleDelegate { | 12 : public ToolbarActionsBarBubbleDelegate { |
| 12 public: | 13 public: |
| 13 explicit DelegateImpl(TestToolbarActionsBarBubbleDelegate* parent) | 14 explicit DelegateImpl(TestToolbarActionsBarBubbleDelegate* parent) |
| 14 : parent_(parent) {} | 15 : parent_(parent) {} |
| 15 ~DelegateImpl() override {} | 16 ~DelegateImpl() override {} |
| 16 | 17 |
| 17 private: | 18 private: |
| 18 bool ShouldShow() override { return true; } | 19 bool ShouldShow() override { return true; } |
| 19 bool ShouldCloseOnDeactivate() override { | 20 bool ShouldCloseOnDeactivate() override { |
| 20 return parent_->close_on_deactivate_; | 21 return parent_->close_on_deactivate_; |
| 21 } | 22 } |
| 22 base::string16 GetHeadingText() override { return parent_->heading_; } | 23 base::string16 GetHeadingText() override { return parent_->heading_; } |
| 23 base::string16 GetBodyText(bool anchored_to_action) override { | 24 base::string16 GetBodyText(bool anchored_to_action) override { |
| 24 return parent_->body_; | 25 return parent_->body_; |
| 25 } | 26 } |
| 26 base::string16 GetItemListText() override { return parent_->item_list_; } | 27 base::string16 GetItemListText() override { return parent_->item_list_; } |
| 27 base::string16 GetActionButtonText() override { return parent_->action_; } | 28 base::string16 GetActionButtonText() override { return parent_->action_; } |
| 28 base::string16 GetDismissButtonText() override { return parent_->dismiss_; } | 29 base::string16 GetDismissButtonText() override { return parent_->dismiss_; } |
| 29 base::string16 GetLearnMoreButtonText() override { | 30 base::string16 GetLearnMoreButtonText() override { |
| 30 return parent_->learn_more_; | 31 return parent_->learn_more_; |
| 31 } | 32 } |
| 33 std::unique_ptr<ToolbarActionsBarBubbleDelegate::ExtraViewInfo> |
| 34 GetExtraViewInfo() override { |
| 35 return base::MakeUnique<ExtraViewInfo>(parent_->extra_view_info_); |
| 36 } |
| 32 std::string GetAnchorActionId() override { return std::string(); } | 37 std::string GetAnchorActionId() override { return std::string(); } |
| 33 void OnBubbleShown() override { | 38 void OnBubbleShown() override { |
| 34 CHECK(!parent_->shown_); | 39 CHECK(!parent_->shown_); |
| 35 parent_->shown_ = true; | 40 parent_->shown_ = true; |
| 36 } | 41 } |
| 37 void OnBubbleClosed(CloseAction action) override { | 42 void OnBubbleClosed(CloseAction action) override { |
| 38 CHECK(!parent_->close_action_); | 43 CHECK(!parent_->close_action_); |
| 39 parent_->close_action_.reset(new CloseAction(action)); | 44 parent_->close_action_.reset(new CloseAction(action)); |
| 40 } | 45 } |
| 41 | 46 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 60 // which has a weak ptr to this object. Make sure that this class always | 65 // which has a weak ptr to this object. Make sure that this class always |
| 61 // outlives the bubble. | 66 // outlives the bubble. |
| 62 CHECK(close_action_); | 67 CHECK(close_action_); |
| 63 } | 68 } |
| 64 | 69 |
| 65 std::unique_ptr<ToolbarActionsBarBubbleDelegate> | 70 std::unique_ptr<ToolbarActionsBarBubbleDelegate> |
| 66 TestToolbarActionsBarBubbleDelegate::GetDelegate() { | 71 TestToolbarActionsBarBubbleDelegate::GetDelegate() { |
| 67 return std::unique_ptr<ToolbarActionsBarBubbleDelegate>( | 72 return std::unique_ptr<ToolbarActionsBarBubbleDelegate>( |
| 68 new DelegateImpl(this)); | 73 new DelegateImpl(this)); |
| 69 } | 74 } |
| OLD | NEW |