summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/toolbar/test_toolbar_action_view_controller.cc
blob: 81a05669d32d36ade6aab85c6c9e44185c9de6ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/ui/toolbar/test_toolbar_action_view_controller.h"

#include "base/strings/string16.h"
#include "chrome/browser/ui/toolbar/toolbar_action_view_delegate.h"
#include "ui/gfx/image/image.h"
#include "ui/gfx/image/image_skia.h"

TestToolbarActionViewController::TestToolbarActionViewController(
    const std::string& id)
    : id_(id),
      delegate_(nullptr),
      is_enabled_(true),
      wants_to_run_(false),
      execute_action_count_(0) {
}

TestToolbarActionViewController::~TestToolbarActionViewController() {
}

const std::string& TestToolbarActionViewController::GetId() const {
  return id_;
}

void TestToolbarActionViewController::SetDelegate(
    ToolbarActionViewDelegate* delegate) {
  delegate_ = delegate;
}

gfx::Image TestToolbarActionViewController::GetIcon(
    content::WebContents* web_contents) {
  return gfx::Image();
}

gfx::ImageSkia TestToolbarActionViewController::GetIconWithBadge() {
  return gfx::ImageSkia();
}

base::string16 TestToolbarActionViewController::GetActionName() const {
  return base::string16();
}

base::string16 TestToolbarActionViewController::GetAccessibleName(
    content::WebContents* web_contents) const {
  return accessible_name_;
}

base::string16 TestToolbarActionViewController::GetTooltip(
    content::WebContents* web_contents) const {
  return tooltip_;
}

bool TestToolbarActionViewController::IsEnabled(
    content::WebContents* web_contents) const {
  return is_enabled_;
}

bool TestToolbarActionViewController::WantsToRun(
    content::WebContents* web_contents) const {
  return wants_to_run_;
}

bool TestToolbarActionViewController::HasPopup(
    content::WebContents* web_contents) const {
  return true;
}

void TestToolbarActionViewController::HidePopup() {
  delegate_->OnPopupClosed();
}

gfx::NativeView TestToolbarActionViewController::GetPopupNativeView() {
  return nullptr;
}

ui::MenuModel* TestToolbarActionViewController::GetContextMenu() {
  return nullptr;
}

bool TestToolbarActionViewController::CanDrag() const {
  return false;
}

bool TestToolbarActionViewController::ExecuteAction(bool by_user) {
  ++execute_action_count_;
  return false;
}

void TestToolbarActionViewController::UpdateState() {
  UpdateDelegate();
}

void TestToolbarActionViewController::ShowPopup(bool by_user) {
  delegate_->OnPopupShown(by_user);
}

void TestToolbarActionViewController::SetAccessibleName(
    const base::string16& name) {
  accessible_name_ = name;
  UpdateDelegate();
}

void TestToolbarActionViewController::SetTooltip(
    const base::string16& tooltip) {
  tooltip_ = tooltip;
  UpdateDelegate();
}

void TestToolbarActionViewController::SetEnabled(bool is_enabled) {
  is_enabled_ = is_enabled;
  UpdateDelegate();
}

void TestToolbarActionViewController::SetWantsToRun(bool wants_to_run) {
  wants_to_run_ = wants_to_run;
  UpdateDelegate();
}

void TestToolbarActionViewController::UpdateDelegate() {
  if (delegate_)
    delegate_->UpdateState();
}