Revert of Remove OneClickSigninHelper since it is no longer used. (patchset #5 id...
[chromium-blink-merge.git] / chrome / browser / ui / toolbar / test_toolbar_action_view_controller.cc
blobc6c910750b84822cb6cfa3f11a94c233482d3b94
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.
5 #include "chrome/browser/ui/toolbar/test_toolbar_action_view_controller.h"
7 #include "base/strings/string16.h"
8 #include "chrome/browser/ui/toolbar/toolbar_action_view_delegate.h"
9 #include "ui/gfx/image/image.h"
10 #include "ui/gfx/image/image_skia.h"
12 TestToolbarActionViewController::TestToolbarActionViewController(
13 const std::string& id)
14 : id_(id),
15 delegate_(nullptr),
16 is_enabled_(true),
17 wants_to_run_(false),
18 execute_action_count_(0) {
21 TestToolbarActionViewController::~TestToolbarActionViewController() {
24 const std::string& TestToolbarActionViewController::GetId() const {
25 return id_;
28 void TestToolbarActionViewController::SetDelegate(
29 ToolbarActionViewDelegate* delegate) {
30 delegate_ = delegate;
33 gfx::Image TestToolbarActionViewController::GetIcon(
34 content::WebContents* web_contents) {
35 return gfx::Image();
38 gfx::ImageSkia TestToolbarActionViewController::GetIconWithBadge() {
39 return gfx::ImageSkia();
42 base::string16 TestToolbarActionViewController::GetActionName() const {
43 return base::string16();
46 base::string16 TestToolbarActionViewController::GetAccessibleName(
47 content::WebContents* web_contents) const {
48 return accessible_name_;
51 base::string16 TestToolbarActionViewController::GetTooltip(
52 content::WebContents* web_contents) const {
53 return tooltip_;
56 bool TestToolbarActionViewController::IsEnabled(
57 content::WebContents* web_contents) const {
58 return is_enabled_;
61 bool TestToolbarActionViewController::WantsToRun(
62 content::WebContents* web_contents) const {
63 return wants_to_run_;
66 bool TestToolbarActionViewController::HasPopup(
67 content::WebContents* web_contents) const {
68 return true;
71 void TestToolbarActionViewController::HidePopup() {
72 delegate_->OnPopupClosed();
75 gfx::NativeView TestToolbarActionViewController::GetPopupNativeView() {
76 return nullptr;
79 ui::MenuModel* TestToolbarActionViewController::GetContextMenu() {
80 return nullptr;
83 bool TestToolbarActionViewController::IsMenuRunning() const {
84 return false;
87 bool TestToolbarActionViewController::CanDrag() const {
88 return false;
91 bool TestToolbarActionViewController::ExecuteAction(bool by_user) {
92 ++execute_action_count_;
93 return false;
96 void TestToolbarActionViewController::UpdateState() {
97 UpdateDelegate();
100 void TestToolbarActionViewController::ShowPopup(bool by_user) {
101 delegate_->OnPopupShown(by_user);
104 void TestToolbarActionViewController::SetAccessibleName(
105 const base::string16& name) {
106 accessible_name_ = name;
107 UpdateDelegate();
110 void TestToolbarActionViewController::SetTooltip(
111 const base::string16& tooltip) {
112 tooltip_ = tooltip;
113 UpdateDelegate();
116 void TestToolbarActionViewController::SetEnabled(bool is_enabled) {
117 is_enabled_ = is_enabled;
118 UpdateDelegate();
121 void TestToolbarActionViewController::SetWantsToRun(bool wants_to_run) {
122 wants_to_run_ = wants_to_run;
123 UpdateDelegate();
126 void TestToolbarActionViewController::UpdateDelegate() {
127 if (delegate_)
128 delegate_->UpdateState();