Infobar material design refresh: layout
[chromium-blink-merge.git] / chrome / browser / ui / toolbar / test_toolbar_action_view_controller.cc
blobfc92e67c8612db0c30566e4e45f244e986d4ffca
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 disabled_click_opens_menu_(false),
19 execute_action_count_(0) {
22 TestToolbarActionViewController::~TestToolbarActionViewController() {
25 std::string TestToolbarActionViewController::GetId() const {
26 return id_;
29 void TestToolbarActionViewController::SetDelegate(
30 ToolbarActionViewDelegate* delegate) {
31 delegate_ = delegate;
34 gfx::Image TestToolbarActionViewController::GetIcon(
35 content::WebContents* web_contents,
36 const gfx::Size& size) {
37 return gfx::Image();
40 base::string16 TestToolbarActionViewController::GetActionName() const {
41 return base::string16();
44 base::string16 TestToolbarActionViewController::GetAccessibleName(
45 content::WebContents* web_contents) const {
46 return accessible_name_;
49 base::string16 TestToolbarActionViewController::GetTooltip(
50 content::WebContents* web_contents) const {
51 return tooltip_;
54 bool TestToolbarActionViewController::IsEnabled(
55 content::WebContents* web_contents) const {
56 return is_enabled_;
59 bool TestToolbarActionViewController::WantsToRun(
60 content::WebContents* web_contents) const {
61 return wants_to_run_;
64 bool TestToolbarActionViewController::HasPopup(
65 content::WebContents* web_contents) const {
66 return true;
69 void TestToolbarActionViewController::HidePopup() {
70 delegate_->OnPopupClosed();
73 gfx::NativeView TestToolbarActionViewController::GetPopupNativeView() {
74 return nullptr;
77 ui::MenuModel* TestToolbarActionViewController::GetContextMenu() {
78 return nullptr;
81 bool TestToolbarActionViewController::ExecuteAction(bool by_user) {
82 ++execute_action_count_;
83 return false;
86 void TestToolbarActionViewController::UpdateState() {
87 UpdateDelegate();
90 bool TestToolbarActionViewController::DisabledClickOpensMenu() const {
91 return disabled_click_opens_menu_;
94 void TestToolbarActionViewController::ShowPopup(bool by_user) {
95 delegate_->OnPopupShown(by_user);
98 void TestToolbarActionViewController::SetAccessibleName(
99 const base::string16& name) {
100 accessible_name_ = name;
101 UpdateDelegate();
104 void TestToolbarActionViewController::SetTooltip(
105 const base::string16& tooltip) {
106 tooltip_ = tooltip;
107 UpdateDelegate();
110 void TestToolbarActionViewController::SetEnabled(bool is_enabled) {
111 is_enabled_ = is_enabled;
112 UpdateDelegate();
115 void TestToolbarActionViewController::SetWantsToRun(bool wants_to_run) {
116 wants_to_run_ = wants_to_run;
117 UpdateDelegate();
120 void TestToolbarActionViewController::SetDisabledClickOpensMenu(
121 bool disabled_click_opens_menu) {
122 disabled_click_opens_menu_ = disabled_click_opens_menu;
123 UpdateDelegate();
126 void TestToolbarActionViewController::UpdateDelegate() {
127 if (delegate_)
128 delegate_->UpdateState();