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
)
18 disabled_click_opens_menu_(false),
19 execute_action_count_(0) {
22 TestToolbarActionViewController::~TestToolbarActionViewController() {
25 std::string
TestToolbarActionViewController::GetId() const {
29 void TestToolbarActionViewController::SetDelegate(
30 ToolbarActionViewDelegate
* delegate
) {
34 gfx::Image
TestToolbarActionViewController::GetIcon(
35 content::WebContents
* web_contents
,
36 const gfx::Size
& size
) {
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 {
54 bool TestToolbarActionViewController::IsEnabled(
55 content::WebContents
* web_contents
) const {
59 bool TestToolbarActionViewController::WantsToRun(
60 content::WebContents
* web_contents
) const {
64 bool TestToolbarActionViewController::HasPopup(
65 content::WebContents
* web_contents
) const {
69 void TestToolbarActionViewController::HidePopup() {
70 delegate_
->OnPopupClosed();
73 gfx::NativeView
TestToolbarActionViewController::GetPopupNativeView() {
77 ui::MenuModel
* TestToolbarActionViewController::GetContextMenu() {
81 bool TestToolbarActionViewController::ExecuteAction(bool by_user
) {
82 ++execute_action_count_
;
86 void TestToolbarActionViewController::UpdateState() {
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
;
104 void TestToolbarActionViewController::SetTooltip(
105 const base::string16
& tooltip
) {
110 void TestToolbarActionViewController::SetEnabled(bool is_enabled
) {
111 is_enabled_
= is_enabled
;
115 void TestToolbarActionViewController::SetWantsToRun(bool wants_to_run
) {
116 wants_to_run_
= wants_to_run
;
120 void TestToolbarActionViewController::SetDisabledClickOpensMenu(
121 bool disabled_click_opens_menu
) {
122 disabled_click_opens_menu_
= disabled_click_opens_menu
;
126 void TestToolbarActionViewController::UpdateDelegate() {
128 delegate_
->UpdateState();