Chromium Code Reviews| Index: chrome/browser/chromeos/system/input_device_settings.cc |
| diff --git a/chrome/browser/chromeos/system/input_device_settings.cc b/chrome/browser/chromeos/system/input_device_settings.cc |
| index eb941053623c398f05500578868c35f5f357ae43..1cf3c4ffe77f89ac10fc79bcc006a8e99ce2f84c 100644 |
| --- a/chrome/browser/chromeos/system/input_device_settings.cc |
| +++ b/chrome/browser/chromeos/system/input_device_settings.cc |
| @@ -234,42 +234,69 @@ bool InputDeviceSettings::ForceKeyboardDrivenUINavigation() { |
| } |
| // static |
| +void InputDeviceSettings::RegisterPrefs(PrefRegistrySimple* registry) { |
| + registry->RegisterBooleanPref(::prefs::kLocalTouchscreenEnabled, true); |
| +} |
| + |
| +// static |
| void InputDeviceSettings::RegisterProfilePrefs(PrefRegistrySimple* registry) { |
| - registry->RegisterBooleanPref(::prefs::kTouchScreenEnabled, true); |
| - registry->RegisterBooleanPref(::prefs::kTouchPadEnabled, true); |
| + registry->RegisterBooleanPref(::prefs::kTouchscreenEnabled, true); |
| + registry->RegisterBooleanPref(::prefs::kTouchpadEnabled, true); |
| } |
| -void InputDeviceSettings::UpdateTouchDevicesStatusFromActiveProfilePrefs() { |
| +void InputDeviceSettings::UpdateTouchDevicesStatusFromPrefs() { |
| + UpdateTouchscreenStatusFromPrefs(); |
| + |
| PrefService* user_prefs = GetActiveProfilePrefs(); |
| if (!user_prefs) |
| return; |
| - const bool touch_screen_status = |
| - user_prefs->HasPrefPath(::prefs::kTouchScreenEnabled) |
| - ? user_prefs->GetBoolean(::prefs::kTouchScreenEnabled) |
| - : true; |
| - |
| 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.
|
| - user_prefs->HasPrefPath(::prefs::kTouchPadEnabled) |
| - ? user_prefs->GetBoolean(::prefs::kTouchPadEnabled) |
| + user_prefs->HasPrefPath(::prefs::kTouchpadEnabled) |
| + ? user_prefs->GetBoolean(::prefs::kTouchpadEnabled) |
| : true; |
| - |
| - SetTouchscreensEnabled(touch_screen_status); |
| SetInternalTouchpadEnabled(touch_pad_status); |
| } |
| -void InputDeviceSettings::ToggleTouchscreen() { |
| - PrefService* user_prefs = GetActiveProfilePrefs(); |
| - if (!user_prefs) |
| - return; |
| +bool InputDeviceSettings::IsTouchscreenEnabledInPrefs( |
| + bool use_local_state) const { |
| + if (use_local_state) { |
| + PrefService* local_state = g_browser_process->local_state(); |
| + DCHECK(local_state); |
| - const bool touch_screen_status = |
| - user_prefs->HasPrefPath(::prefs::kTouchScreenEnabled) |
| - ? user_prefs->GetBoolean(::prefs::kTouchScreenEnabled) |
| - : true; |
| + return local_state->HasPrefPath(::prefs::kLocalTouchscreenEnabled) |
| + ? local_state->GetBoolean(::prefs::kLocalTouchscreenEnabled) |
| + : true; |
| + } else { |
| + PrefService* user_prefs = GetActiveProfilePrefs(); |
| + if (!user_prefs) |
| + return true; |
| + |
| + return user_prefs->HasPrefPath(::prefs::kTouchscreenEnabled) |
| + ? user_prefs->GetBoolean(::prefs::kTouchscreenEnabled) |
| + : true; |
| + } |
| +} |
| + |
| +void InputDeviceSettings::SetTouchscreenEnabledInPrefs(bool enabled, |
| + bool use_local_state) { |
| + if (use_local_state) { |
| + PrefService* local_state = g_browser_process->local_state(); |
| + DCHECK(local_state); |
| + local_state->SetBoolean(::prefs::kLocalTouchscreenEnabled, enabled); |
| + } else { |
| + PrefService* user_prefs = GetActiveProfilePrefs(); |
| + if (!user_prefs) |
| + return; |
| + |
| + user_prefs->SetBoolean(::prefs::kTouchscreenEnabled, enabled); |
| + } |
| +} |
| - user_prefs->SetBoolean(::prefs::kTouchScreenEnabled, !touch_screen_status); |
| - SetTouchscreensEnabled(!touch_screen_status); |
| +void InputDeviceSettings::UpdateTouchscreenStatusFromPrefs() { |
| + bool enabled_in_local_state = IsTouchscreenEnabledInPrefs(true); |
| + bool enabled_in_user_prefs = IsTouchscreenEnabledInPrefs(false); |
| + SetTouchscreensEnabled(enabled_in_local_state && enabled_in_user_prefs); |
| } |
| void InputDeviceSettings::ToggleTouchpad() { |
| @@ -278,11 +305,11 @@ void InputDeviceSettings::ToggleTouchpad() { |
| return; |
| const bool touch_pad_status = |
| - user_prefs->HasPrefPath(::prefs::kTouchPadEnabled) |
| - ? user_prefs->GetBoolean(::prefs::kTouchPadEnabled) |
| + user_prefs->HasPrefPath(::prefs::kTouchpadEnabled) |
| + ? user_prefs->GetBoolean(::prefs::kTouchpadEnabled) |
| : true; |
| - user_prefs->SetBoolean(::prefs::kTouchPadEnabled, !touch_pad_status); |
| + user_prefs->SetBoolean(::prefs::kTouchpadEnabled, !touch_pad_status); |
| SetInternalTouchpadEnabled(!touch_pad_status); |
| } |