OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/toolbar/test_toolbar_action_view_controller.h" | 5 #include "chrome/browser/ui/toolbar/test_toolbar_action_view_controller.h" |
6 | 6 |
7 #include "base/strings/string16.h" | 7 #include "base/strings/string16.h" |
8 #include "chrome/browser/ui/toolbar/toolbar_action_view_delegate.h" | 8 #include "chrome/browser/ui/toolbar/toolbar_action_view_delegate.h" |
9 #include "ui/gfx/image/image.h" | 9 #include "ui/gfx/image/image.h" |
10 #include "ui/gfx/image/image_skia.h" | 10 #include "ui/gfx/image/image_skia.h" |
11 | 11 |
12 TestToolbarActionViewController::TestToolbarActionViewController( | 12 TestToolbarActionViewController::TestToolbarActionViewController( |
13 const std::string& id) | 13 const std::string& id) |
14 : id_(id), | 14 : id_(id), |
15 delegate_(nullptr), | 15 delegate_(nullptr), |
16 is_enabled_(true), | 16 is_enabled_(true), |
17 wants_to_run_(false), | 17 wants_to_run_(false), |
| 18 disabled_click_opens_menu_(false), |
18 execute_action_count_(0) { | 19 execute_action_count_(0) { |
19 } | 20 } |
20 | 21 |
21 TestToolbarActionViewController::~TestToolbarActionViewController() { | 22 TestToolbarActionViewController::~TestToolbarActionViewController() { |
22 } | 23 } |
23 | 24 |
24 const std::string& TestToolbarActionViewController::GetId() const { | 25 const std::string& TestToolbarActionViewController::GetId() const { |
25 return id_; | 26 return id_; |
26 } | 27 } |
27 | 28 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 | 84 |
84 bool TestToolbarActionViewController::ExecuteAction(bool by_user) { | 85 bool TestToolbarActionViewController::ExecuteAction(bool by_user) { |
85 ++execute_action_count_; | 86 ++execute_action_count_; |
86 return false; | 87 return false; |
87 } | 88 } |
88 | 89 |
89 void TestToolbarActionViewController::UpdateState() { | 90 void TestToolbarActionViewController::UpdateState() { |
90 UpdateDelegate(); | 91 UpdateDelegate(); |
91 } | 92 } |
92 | 93 |
| 94 bool TestToolbarActionViewController::DisabledClickOpensMenu() const { |
| 95 return disabled_click_opens_menu_; |
| 96 } |
| 97 |
93 void TestToolbarActionViewController::ShowPopup(bool by_user) { | 98 void TestToolbarActionViewController::ShowPopup(bool by_user) { |
94 delegate_->OnPopupShown(by_user); | 99 delegate_->OnPopupShown(by_user); |
95 } | 100 } |
96 | 101 |
97 void TestToolbarActionViewController::SetAccessibleName( | 102 void TestToolbarActionViewController::SetAccessibleName( |
98 const base::string16& name) { | 103 const base::string16& name) { |
99 accessible_name_ = name; | 104 accessible_name_ = name; |
100 UpdateDelegate(); | 105 UpdateDelegate(); |
101 } | 106 } |
102 | 107 |
103 void TestToolbarActionViewController::SetTooltip( | 108 void TestToolbarActionViewController::SetTooltip( |
104 const base::string16& tooltip) { | 109 const base::string16& tooltip) { |
105 tooltip_ = tooltip; | 110 tooltip_ = tooltip; |
106 UpdateDelegate(); | 111 UpdateDelegate(); |
107 } | 112 } |
108 | 113 |
109 void TestToolbarActionViewController::SetEnabled(bool is_enabled) { | 114 void TestToolbarActionViewController::SetEnabled(bool is_enabled) { |
110 is_enabled_ = is_enabled; | 115 is_enabled_ = is_enabled; |
111 UpdateDelegate(); | 116 UpdateDelegate(); |
112 } | 117 } |
113 | 118 |
114 void TestToolbarActionViewController::SetWantsToRun(bool wants_to_run) { | 119 void TestToolbarActionViewController::SetWantsToRun(bool wants_to_run) { |
115 wants_to_run_ = wants_to_run; | 120 wants_to_run_ = wants_to_run; |
116 UpdateDelegate(); | 121 UpdateDelegate(); |
117 } | 122 } |
118 | 123 |
| 124 void TestToolbarActionViewController::SetDisabledClickOpensMenu( |
| 125 bool disabled_click_opens_menu) { |
| 126 disabled_click_opens_menu_ = disabled_click_opens_menu; |
| 127 UpdateDelegate(); |
| 128 } |
| 129 |
119 void TestToolbarActionViewController::UpdateDelegate() { | 130 void TestToolbarActionViewController::UpdateDelegate() { |
120 if (delegate_) | 131 if (delegate_) |
121 delegate_->UpdateState(); | 132 delegate_->UpdateState(); |
122 } | 133 } |
OLD | NEW |