Chromium Code Reviews| 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 "chrome/browser/browser_process.h" | 7 #include "chrome/browser/browser_process.h" |
| 8 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 8 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
| 9 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" | 9 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" |
| 10 #include "chrome/browser/profiles/profile_manager.h" | 10 #include "chrome/browser/profiles/profile_manager.h" |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 227 bool keyboard_driven = false; | 227 bool keyboard_driven = false; |
| 228 if (chromeos::system::StatisticsProvider::GetInstance()->GetMachineFlag( | 228 if (chromeos::system::StatisticsProvider::GetInstance()->GetMachineFlag( |
| 229 kOemKeyboardDrivenOobeKey, &keyboard_driven)) { | 229 kOemKeyboardDrivenOobeKey, &keyboard_driven)) { |
| 230 return keyboard_driven; | 230 return keyboard_driven; |
| 231 } | 231 } |
| 232 | 232 |
| 233 return false; | 233 return false; |
| 234 } | 234 } |
| 235 | 235 |
| 236 // static | 236 // static |
| 237 void InputDeviceSettings::RegisterPrefs(PrefRegistrySimple* registry) { | |
| 238 registry->RegisterBooleanPref(::prefs::kLocalTouchscreenEnabled, true); | |
| 239 } | |
| 240 | |
| 241 // static | |
| 237 void InputDeviceSettings::RegisterProfilePrefs(PrefRegistrySimple* registry) { | 242 void InputDeviceSettings::RegisterProfilePrefs(PrefRegistrySimple* registry) { |
| 238 registry->RegisterBooleanPref(::prefs::kTouchScreenEnabled, true); | 243 registry->RegisterBooleanPref(::prefs::kTouchscreenEnabled, true); |
| 239 registry->RegisterBooleanPref(::prefs::kTouchPadEnabled, true); | 244 registry->RegisterBooleanPref(::prefs::kTouchpadEnabled, true); |
| 240 } | 245 } |
| 241 | 246 |
| 242 void InputDeviceSettings::UpdateTouchDevicesStatusFromActiveProfilePrefs() { | 247 void InputDeviceSettings::UpdateTouchDevicesStatusFromPrefs() { |
| 248 UpdateTouchscreenStatusFromPrefs(); | |
| 249 | |
| 243 PrefService* user_prefs = GetActiveProfilePrefs(); | 250 PrefService* user_prefs = GetActiveProfilePrefs(); |
| 244 if (!user_prefs) | 251 if (!user_prefs) |
| 245 return; | 252 return; |
| 246 | 253 |
| 247 const bool touch_screen_status = | 254 const bool touch_pad_status = |
|
Daniel Erat
2016/12/03 00:08:44
nit: s/touch_pad/touchpad/
Qiang(Joe) Xu
2016/12/03 01:02:44
Done.
| |
| 248 user_prefs->HasPrefPath(::prefs::kTouchScreenEnabled) | 255 user_prefs->HasPrefPath(::prefs::kTouchpadEnabled) |
| 249 ? user_prefs->GetBoolean(::prefs::kTouchScreenEnabled) | 256 ? user_prefs->GetBoolean(::prefs::kTouchpadEnabled) |
| 250 : true; | 257 : true; |
| 251 | |
| 252 const bool touch_pad_status = | |
| 253 user_prefs->HasPrefPath(::prefs::kTouchPadEnabled) | |
| 254 ? user_prefs->GetBoolean(::prefs::kTouchPadEnabled) | |
| 255 : true; | |
| 256 | |
| 257 SetTouchscreensEnabled(touch_screen_status); | |
| 258 SetInternalTouchpadEnabled(touch_pad_status); | 258 SetInternalTouchpadEnabled(touch_pad_status); |
| 259 } | 259 } |
| 260 | 260 |
| 261 void InputDeviceSettings::ToggleTouchscreen() { | 261 bool InputDeviceSettings::IsTouchscreenEnabledInPrefs( |
| 262 PrefService* user_prefs = GetActiveProfilePrefs(); | 262 bool use_local_state) const { |
| 263 if (!user_prefs) | 263 if (use_local_state) { |
| 264 return; | 264 PrefService* local_state = g_browser_process->local_state(); |
| 265 DCHECK(local_state); | |
| 265 | 266 |
| 266 const bool touch_screen_status = | 267 return local_state->HasPrefPath(::prefs::kLocalTouchscreenEnabled) |
| 267 user_prefs->HasPrefPath(::prefs::kTouchScreenEnabled) | 268 ? local_state->GetBoolean(::prefs::kLocalTouchscreenEnabled) |
| 268 ? user_prefs->GetBoolean(::prefs::kTouchScreenEnabled) | 269 : true; |
| 269 : true; | 270 } else { |
| 271 PrefService* user_prefs = GetActiveProfilePrefs(); | |
| 272 if (!user_prefs) | |
| 273 return true; | |
| 270 | 274 |
| 271 user_prefs->SetBoolean(::prefs::kTouchScreenEnabled, !touch_screen_status); | 275 return user_prefs->HasPrefPath(::prefs::kTouchscreenEnabled) |
| 272 SetTouchscreensEnabled(!touch_screen_status); | 276 ? user_prefs->GetBoolean(::prefs::kTouchscreenEnabled) |
| 277 : true; | |
| 278 } | |
| 279 } | |
| 280 | |
| 281 void InputDeviceSettings::SetTouchscreenEnabledInPrefs(bool enabled, | |
| 282 bool use_local_state) { | |
| 283 if (use_local_state) { | |
| 284 PrefService* local_state = g_browser_process->local_state(); | |
| 285 DCHECK(local_state); | |
| 286 local_state->SetBoolean(::prefs::kLocalTouchscreenEnabled, enabled); | |
| 287 } else { | |
| 288 PrefService* user_prefs = GetActiveProfilePrefs(); | |
| 289 if (!user_prefs) | |
| 290 return; | |
| 291 | |
| 292 user_prefs->SetBoolean(::prefs::kTouchscreenEnabled, enabled); | |
| 293 } | |
| 294 } | |
| 295 | |
| 296 void InputDeviceSettings::UpdateTouchscreenStatusFromPrefs() { | |
| 297 bool enabled_in_local_state = IsTouchscreenEnabledInPrefs(true); | |
| 298 bool enabled_in_user_prefs = IsTouchscreenEnabledInPrefs(false); | |
| 299 SetTouchscreensEnabled(enabled_in_local_state && enabled_in_user_prefs); | |
| 273 } | 300 } |
| 274 | 301 |
| 275 void InputDeviceSettings::ToggleTouchpad() { | 302 void InputDeviceSettings::ToggleTouchpad() { |
| 276 PrefService* user_prefs = GetActiveProfilePrefs(); | 303 PrefService* user_prefs = GetActiveProfilePrefs(); |
| 277 if (!user_prefs) | 304 if (!user_prefs) |
| 278 return; | 305 return; |
| 279 | 306 |
| 280 const bool touch_pad_status = | 307 const bool touch_pad_status = |
| 281 user_prefs->HasPrefPath(::prefs::kTouchPadEnabled) | 308 user_prefs->HasPrefPath(::prefs::kTouchpadEnabled) |
| 282 ? user_prefs->GetBoolean(::prefs::kTouchPadEnabled) | 309 ? user_prefs->GetBoolean(::prefs::kTouchpadEnabled) |
| 283 : true; | 310 : true; |
| 284 | 311 |
| 285 user_prefs->SetBoolean(::prefs::kTouchPadEnabled, !touch_pad_status); | 312 user_prefs->SetBoolean(::prefs::kTouchpadEnabled, !touch_pad_status); |
| 286 SetInternalTouchpadEnabled(!touch_pad_status); | 313 SetInternalTouchpadEnabled(!touch_pad_status); |
| 287 } | 314 } |
| 288 | 315 |
| 289 } // namespace system | 316 } // namespace system |
| 290 } // namespace chromeos | 317 } // namespace chromeos |
| OLD | NEW |