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 "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" |
| 14 #include "ui/events/base_event_utils.h" | |
| 11 | 15 |
| 12 namespace chromeos { | 16 namespace chromeos { |
| 13 namespace system { | 17 namespace system { |
| 14 | 18 |
| 15 TouchpadSettings::TouchpadSettings() { | 19 TouchpadSettings::TouchpadSettings() { |
| 16 } | 20 } |
| 17 | 21 |
| 18 TouchpadSettings& TouchpadSettings::operator=(const TouchpadSettings& other) { | 22 TouchpadSettings& TouchpadSettings::operator=(const TouchpadSettings& other) { |
| 19 if (&other != this) { | 23 if (&other != this) { |
| 20 sensitivity_ = other.sensitivity_; | 24 sensitivity_ = other.sensitivity_; |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 209 | 213 |
| 210 bool keyboard_driven = false; | 214 bool keyboard_driven = false; |
| 211 if (chromeos::system::StatisticsProvider::GetInstance()->GetMachineFlag( | 215 if (chromeos::system::StatisticsProvider::GetInstance()->GetMachineFlag( |
| 212 kOemKeyboardDrivenOobeKey, &keyboard_driven)) { | 216 kOemKeyboardDrivenOobeKey, &keyboard_driven)) { |
| 213 return keyboard_driven; | 217 return keyboard_driven; |
| 214 } | 218 } |
| 215 | 219 |
| 216 return false; | 220 return false; |
| 217 } | 221 } |
| 218 | 222 |
| 223 // static | |
| 224 void InputDeviceSettings::RegisterPrefs(PrefRegistrySimple* registry) { | |
| 225 registry->RegisterBooleanPref(::prefs::kTouchScreenEnabled, true); | |
| 226 registry->RegisterBooleanPref(::prefs::kTouchPadEnabled, true); | |
| 227 } | |
| 228 | |
| 229 void InputDeviceSettings::InitTouchDevicesStatusFromLocalPrefs() { | |
|
sadrul
2015/11/03 19:09:26
Should we really store developer-only flags in the
afakhry
2015/11/04 02:28:21
It's one of the requirements for this feature is t
| |
| 230 PrefService* local_state = g_browser_process->local_state(); | |
| 231 DCHECK(local_state); | |
| 232 | |
| 233 const bool touch_screen_status = | |
| 234 local_state->HasPrefPath(::prefs::kTouchScreenEnabled) ? | |
| 235 local_state->GetBoolean(::prefs::kTouchScreenEnabled) : true; | |
| 236 | |
| 237 const bool touch_pad_status = | |
| 238 local_state->HasPrefPath(::prefs::kTouchPadEnabled) ? | |
| 239 local_state->GetBoolean(::prefs::kTouchPadEnabled) : true; | |
| 240 | |
| 241 ui::SetTouchEventsEnabled(touch_screen_status); | |
| 242 SetInternalTouchpadEnabled(touch_pad_status); | |
| 243 } | |
| 244 | |
| 245 void InputDeviceSettings::ToggleTouchscreen() { | |
| 246 PrefService* local_state = g_browser_process->local_state(); | |
| 247 DCHECK(local_state); | |
| 248 | |
| 249 const bool touch_screen_status = | |
| 250 local_state->HasPrefPath(::prefs::kTouchScreenEnabled) ? | |
| 251 local_state->GetBoolean(::prefs::kTouchScreenEnabled) : true; | |
| 252 | |
| 253 local_state->SetBoolean(::prefs::kTouchScreenEnabled, !touch_screen_status); | |
| 254 ui::SetTouchEventsEnabled(!touch_screen_status); | |
| 255 } | |
| 256 | |
| 257 void InputDeviceSettings::ToggleTouchpad() { | |
| 258 PrefService* local_state = g_browser_process->local_state(); | |
| 259 DCHECK(local_state); | |
| 260 | |
| 261 const bool touch_pad_status = | |
| 262 local_state->HasPrefPath(::prefs::kTouchPadEnabled) ? | |
| 263 local_state->GetBoolean(::prefs::kTouchPadEnabled) : true; | |
| 264 | |
| 265 local_state->SetBoolean(::prefs::kTouchPadEnabled, !touch_pad_status); | |
| 266 SetInternalTouchpadEnabled(!touch_pad_status); | |
| 267 } | |
| 268 | |
| 219 } // namespace system | 269 } // namespace system |
| 220 } // namespace chromeos | 270 } // namespace chromeos |
| OLD | NEW |