Update broken references to image assets
[chromium-blink-merge.git] / chrome / browser / chromeos / system / input_device_settings.cc
blobbb738b57681c8996b87d0c9c3d2bfc4ba4dd9334
1 // Copyright (c) 2012 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/chromeos/system/input_device_settings.h"
7 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
9 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h"
10 #include "chromeos/system/statistics_provider.h"
12 namespace chromeos {
13 namespace system {
15 TouchpadSettings::TouchpadSettings() {
18 TouchpadSettings& TouchpadSettings::operator=(const TouchpadSettings& other) {
19 if (&other != this) {
20 sensitivity_ = other.sensitivity_;
21 tap_to_click_ = other.tap_to_click_;
22 three_finger_click_ = other.three_finger_click_;
23 tap_dragging_ = other.tap_dragging_;
24 natural_scroll_ = other.natural_scroll_;
26 return *this;
29 void TouchpadSettings::SetSensitivity(int value) {
30 sensitivity_.Set(value);
33 int TouchpadSettings::GetSensitivity() const {
34 return sensitivity_.value();
37 bool TouchpadSettings::IsSensitivitySet() const {
38 return sensitivity_.is_set();
41 void TouchpadSettings::SetTapToClick(bool enabled) {
42 tap_to_click_.Set(enabled);
45 bool TouchpadSettings::GetTapToClick() const {
46 return tap_to_click_.value();
49 bool TouchpadSettings::IsTapToClickSet() const {
50 return tap_to_click_.is_set();
53 void TouchpadSettings::SetNaturalScroll(bool enabled) {
54 natural_scroll_.Set(enabled);
57 bool TouchpadSettings::GetNaturalScroll() const {
58 return natural_scroll_.value();
61 bool TouchpadSettings::IsNaturalScrollSet() const {
62 return natural_scroll_.is_set();
65 void TouchpadSettings::SetThreeFingerClick(bool enabled) {
66 three_finger_click_.Set(enabled);
69 bool TouchpadSettings::GetThreeFingerClick() const {
70 return three_finger_click_.value();
73 bool TouchpadSettings::IsThreeFingerClickSet() const {
74 return three_finger_click_.is_set();
77 void TouchpadSettings::SetTapDragging(bool enabled) {
78 tap_dragging_.Set(enabled);
81 bool TouchpadSettings::GetTapDragging() const {
82 return tap_dragging_.value();
85 bool TouchpadSettings::IsTapDraggingSet() const {
86 return tap_dragging_.is_set();
89 bool TouchpadSettings::Update(const TouchpadSettings& settings) {
90 bool updated = false;
91 if (sensitivity_.Update(settings.sensitivity_))
92 updated = true;
93 if (tap_to_click_.Update(settings.tap_to_click_))
94 updated = true;
95 if (three_finger_click_.Update(settings.three_finger_click_))
96 updated = true;
97 if (tap_dragging_.Update(settings.tap_dragging_))
98 updated = true;
99 natural_scroll_.Update(settings.natural_scroll_);
100 // Always send natural scrolling to the shell command, as a workaround.
101 // See crbug.com/406480
102 if (natural_scroll_.is_set())
103 updated = true;
104 return updated;
107 // static
108 void TouchpadSettings::Apply(const TouchpadSettings& touchpad_settings,
109 InputDeviceSettings* input_device_settings) {
110 if (!input_device_settings)
111 return;
112 if (touchpad_settings.sensitivity_.is_set()) {
113 input_device_settings->SetTouchpadSensitivity(
114 touchpad_settings.sensitivity_.value());
116 if (touchpad_settings.tap_to_click_.is_set()) {
117 input_device_settings->SetTapToClick(
118 touchpad_settings.tap_to_click_.value());
120 if (touchpad_settings.three_finger_click_.is_set()) {
121 input_device_settings->SetThreeFingerClick(
122 touchpad_settings.three_finger_click_.value());
124 if (touchpad_settings.tap_dragging_.is_set()) {
125 input_device_settings->SetTapDragging(
126 touchpad_settings.tap_dragging_.value());
128 if (touchpad_settings.natural_scroll_.is_set()) {
129 input_device_settings->SetNaturalScroll(
130 touchpad_settings.natural_scroll_.value());
134 MouseSettings::MouseSettings() {
137 MouseSettings& MouseSettings::operator=(const MouseSettings& other) {
138 if (&other != this) {
139 sensitivity_ = other.sensitivity_;
140 primary_button_right_ = other.primary_button_right_;
142 return *this;
145 void MouseSettings::SetSensitivity(int value) {
146 sensitivity_.Set(value);
149 int MouseSettings::GetSensitivity() const {
150 return sensitivity_.value();
153 bool MouseSettings::IsSensitivitySet() const {
154 return sensitivity_.is_set();
157 void MouseSettings::SetPrimaryButtonRight(bool right) {
158 primary_button_right_.Set(right);
161 bool MouseSettings::GetPrimaryButtonRight() const {
162 return primary_button_right_.value();
165 bool MouseSettings::IsPrimaryButtonRightSet() const {
166 return primary_button_right_.is_set();
169 bool MouseSettings::Update(const MouseSettings& settings) {
170 bool updated = false;
171 if (sensitivity_.Update(settings.sensitivity_))
172 updated = true;
173 if (primary_button_right_.Update(settings.primary_button_right_))
174 updated = true;
175 return updated;
178 // static
179 void MouseSettings::Apply(const MouseSettings& mouse_settings,
180 InputDeviceSettings* input_device_settings) {
181 if (!input_device_settings)
182 return;
183 if (mouse_settings.sensitivity_.is_set()) {
184 input_device_settings->SetMouseSensitivity(
185 mouse_settings.sensitivity_.value());
187 if (mouse_settings.primary_button_right_.is_set()) {
188 input_device_settings->SetPrimaryButtonRight(
189 mouse_settings.primary_button_right_.value());
193 // static
194 bool InputDeviceSettings::ForceKeyboardDrivenUINavigation() {
195 policy::BrowserPolicyConnectorChromeOS* connector =
196 g_browser_process->platform_part()->browser_policy_connector_chromeos();
197 if (!connector)
198 return false;
200 policy::DeviceCloudPolicyManagerChromeOS* policy_manager =
201 connector->GetDeviceCloudPolicyManager();
202 if (!policy_manager)
203 return false;
205 if (policy_manager->IsRemoraRequisition() ||
206 policy_manager->IsSharkRequisition()) {
207 return true;
210 bool keyboard_driven = false;
211 if (chromeos::system::StatisticsProvider::GetInstance()->GetMachineFlag(
212 kOemKeyboardDrivenOobeKey, &keyboard_driven)) {
213 return keyboard_driven;
216 return false;
219 } // namespace system
220 } // namespace chromeos