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 bb738b57681c8996b87d0c9c3d2bfc4ba4dd9334..dfb5d2135b6eb8d0c8faae9eeee0385f6d49dc71 100644 |
| --- a/chrome/browser/chromeos/system/input_device_settings.cc |
| +++ b/chrome/browser/chromeos/system/input_device_settings.cc |
| @@ -4,10 +4,14 @@ |
| #include "chrome/browser/chromeos/system/input_device_settings.h" |
| +#include "base/prefs/pref_registry_simple.h" |
| +#include "base/prefs/pref_service.h" |
| #include "chrome/browser/browser_process.h" |
| #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
| #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" |
| +#include "chrome/common/pref_names.h" |
| #include "chromeos/system/statistics_provider.h" |
| +#include "ui/base/touch/touch_enabled.h" |
| namespace chromeos { |
| namespace system { |
| @@ -216,5 +220,56 @@ bool InputDeviceSettings::ForceKeyboardDrivenUINavigation() { |
| return false; |
| } |
| +// static |
| +void InputDeviceSettings::RegisterPrefs(PrefRegistrySimple* registry) { |
| + registry->RegisterBooleanPref(::prefs::kTouchScreenEnabled, true); |
| + registry->RegisterBooleanPref(::prefs::kTouchPadEnabled, true); |
| +} |
| + |
| +void InputDeviceSettings::InitTouchDevicesStatusFromLocalPrefs() { |
| + bool touch_screen_status = true; |
| + bool touch_pad_status = true; |
| + |
| + PrefService* local_state = g_browser_process->local_state(); |
|
oshima
2015/10/29 23:38:43
can this be null?
afakhry
2015/10/30 05:18:03
I'm not sure. We already have some code that check
|
| + if (local_state) { |
| + if (local_state->HasPrefPath(::prefs::kTouchScreenEnabled)) { |
| + touch_screen_status = |
| + local_state->GetBoolean(::prefs::kTouchScreenEnabled); |
| + } |
| + |
| + if (local_state->HasPrefPath(::prefs::kTouchPadEnabled)) |
| + touch_pad_status = local_state->GetBoolean(::prefs::kTouchPadEnabled); |
| + } |
| + |
| + ui::SetTouchEventsEnabled(touch_screen_status); |
| + SetInternalTouchpadEnabled(touch_pad_status); |
| +} |
| + |
| +void InputDeviceSettings::ToggleTouchscreen() { |
| + PrefService* local_state = g_browser_process->local_state(); |
| + if (!local_state) |
| + return; |
| + |
| + bool touch_screen_status = true; |
| + if (local_state->HasPrefPath(::prefs::kTouchScreenEnabled)) |
| + touch_screen_status = local_state->GetBoolean(::prefs::kTouchScreenEnabled); |
| + |
| + local_state->SetBoolean(::prefs::kTouchScreenEnabled, !touch_screen_status); |
| + ui::SetTouchEventsEnabled(!touch_screen_status); |
| +} |
| + |
| +void InputDeviceSettings::ToggleTouchpad() { |
| + PrefService* local_state = g_browser_process->local_state(); |
| + if (!local_state) |
| + return; |
| + |
| + bool touch_pad_status = true; |
| + if (local_state->HasPrefPath(::prefs::kTouchPadEnabled)) |
| + touch_pad_status = local_state->GetBoolean(::prefs::kTouchPadEnabled); |
| + |
| + local_state->SetBoolean(::prefs::kTouchPadEnabled, !touch_pad_status); |
| + SetInternalTouchpadEnabled(!touch_pad_status); |
| +} |
| + |
| } // namespace system |
| } // namespace chromeos |