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..bced30d615ae46f9bdccd3750ac38871240d4054 100644 |
| --- a/chrome/browser/chromeos/system/input_device_settings.cc |
| +++ b/chrome/browser/chromeos/system/input_device_settings.cc |
| @@ -234,42 +234,66 @@ 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); |
| } |
| -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 = |
| 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 is_local) const { |
| + if (is_local) { |
| + 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 is_local) { |
| + if (is_local) { |
| + 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() { |
| + SetTouchscreensEnabled(IsTouchscreenEnabledInPrefs(true) == |
| + IsTouchscreenEnabledInPrefs(false)); |
|
afakhry
2016/12/02 20:04:27
I think you need to AND them together.
Qiang(Joe) Xu
2016/12/02 21:23:13
I once thought it should do AND, but then find it
|
| } |
| void InputDeviceSettings::ToggleTouchpad() { |