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 execute_action_count_(0) {
21 TestToolbarActionViewController::~TestToolbarActionViewController() {
24 const std::string
& TestToolbarActionViewController::GetId() const {
28 void TestToolbarActionViewController::SetDelegate(
29 ToolbarActionViewDelegate
* delegate
) {
33 gfx::Image
TestToolbarActionViewController::GetIcon(
34 content::WebContents
* web_contents
) {
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 {
56 bool TestToolbarActionViewController::IsEnabled(
57 content::WebContents
* web_contents
) const {
61 bool TestToolbarActionViewController::WantsToRun(
62 content::WebContents
* web_contents
) const {
66 bool TestToolbarActionViewController::HasPopup(
67 content::WebContents
* web_contents
) const {
71 void TestToolbarActionViewController::HidePopup() {
72 delegate_
->OnPopupClosed();
75 gfx::NativeView
TestToolbarActionViewController::GetPopupNativeView() {
79 ui::MenuModel
* TestToolbarActionViewController::GetContextMenu() {
83 bool TestToolbarActionViewController::IsMenuRunning() const {
87 bool TestToolbarActionViewController::CanDrag() const {
91 bool TestToolbarActionViewController::ExecuteAction(bool by_user
) {
92 ++execute_action_count_
;
96 void TestToolbarActionViewController::UpdateState() {
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
;
110 void TestToolbarActionViewController::SetTooltip(
111 const base::string16
& tooltip
) {
116 void TestToolbarActionViewController::SetEnabled(bool is_enabled
) {
117 is_enabled_
= is_enabled
;
121 void TestToolbarActionViewController::SetWantsToRun(bool wants_to_run
) {
122 wants_to_run_
= wants_to_run
;
126 void TestToolbarActionViewController::UpdateDelegate() {
128 delegate_
->UpdateState();