OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/chromeos/system/input_device_settings.h" | 5 #include "chrome/browser/chromeos/system/input_device_settings.h" |
6 | 6 |
| 7 #include "base/prefs/pref_registry_simple.h" |
| 8 #include "base/prefs/pref_service.h" |
7 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
8 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 10 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
9 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" | 11 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" |
| 12 #include "chrome/common/pref_names.h" |
10 #include "chromeos/system/statistics_provider.h" | 13 #include "chromeos/system/statistics_provider.h" |
11 | 14 |
12 namespace chromeos { | 15 namespace chromeos { |
13 namespace system { | 16 namespace system { |
14 | 17 |
15 TouchpadSettings::TouchpadSettings() { | 18 TouchpadSettings::TouchpadSettings() { |
16 } | 19 } |
17 | 20 |
18 TouchpadSettings& TouchpadSettings::operator=(const TouchpadSettings& other) { | 21 TouchpadSettings& TouchpadSettings::operator=(const TouchpadSettings& other) { |
19 if (&other != this) { | 22 if (&other != this) { |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 | 212 |
210 bool keyboard_driven = false; | 213 bool keyboard_driven = false; |
211 if (chromeos::system::StatisticsProvider::GetInstance()->GetMachineFlag( | 214 if (chromeos::system::StatisticsProvider::GetInstance()->GetMachineFlag( |
212 kOemKeyboardDrivenOobeKey, &keyboard_driven)) { | 215 kOemKeyboardDrivenOobeKey, &keyboard_driven)) { |
213 return keyboard_driven; | 216 return keyboard_driven; |
214 } | 217 } |
215 | 218 |
216 return false; | 219 return false; |
217 } | 220 } |
218 | 221 |
| 222 // static |
| 223 void InputDeviceSettings::RegisterPrefs(PrefRegistrySimple* registry) { |
| 224 registry->RegisterBooleanPref(::prefs::kTouchScreenEnabled, true); |
| 225 registry->RegisterBooleanPref(::prefs::kTouchPadEnabled, true); |
| 226 } |
| 227 |
| 228 void InputDeviceSettings::InitTouchDevicesStatusFromLocalPrefs() { |
| 229 PrefService* local_state = g_browser_process->local_state(); |
| 230 DCHECK(local_state); |
| 231 |
| 232 const bool touch_screen_status = |
| 233 local_state->HasPrefPath(::prefs::kTouchScreenEnabled) |
| 234 ? local_state->GetBoolean(::prefs::kTouchScreenEnabled) |
| 235 : true; |
| 236 |
| 237 const bool touch_pad_status = |
| 238 local_state->HasPrefPath(::prefs::kTouchPadEnabled) |
| 239 ? local_state->GetBoolean(::prefs::kTouchPadEnabled) |
| 240 : true; |
| 241 |
| 242 SetTouchscreensEnabled(touch_screen_status); |
| 243 SetInternalTouchpadEnabled(touch_pad_status); |
| 244 } |
| 245 |
| 246 void InputDeviceSettings::ToggleTouchscreen() { |
| 247 PrefService* local_state = g_browser_process->local_state(); |
| 248 DCHECK(local_state); |
| 249 |
| 250 const bool touch_screen_status = |
| 251 local_state->HasPrefPath(::prefs::kTouchScreenEnabled) |
| 252 ? local_state->GetBoolean(::prefs::kTouchScreenEnabled) |
| 253 : true; |
| 254 |
| 255 local_state->SetBoolean(::prefs::kTouchScreenEnabled, !touch_screen_status); |
| 256 SetTouchscreensEnabled(!touch_screen_status); |
| 257 } |
| 258 |
| 259 void InputDeviceSettings::ToggleTouchpad() { |
| 260 PrefService* local_state = g_browser_process->local_state(); |
| 261 DCHECK(local_state); |
| 262 |
| 263 const bool touch_pad_status = |
| 264 local_state->HasPrefPath(::prefs::kTouchPadEnabled) |
| 265 ? local_state->GetBoolean(::prefs::kTouchPadEnabled) |
| 266 : true; |
| 267 |
| 268 local_state->SetBoolean(::prefs::kTouchPadEnabled, !touch_pad_status); |
| 269 SetInternalTouchpadEnabled(!touch_pad_status); |
| 270 } |
| 271 |
219 } // namespace system | 272 } // namespace system |
220 } // namespace chromeos | 273 } // namespace chromeos |
OLD | NEW |