Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(116)

Side by Side Diff: chrome/browser/chromeos/system/input_device_settings.cc

Issue 1412623006: Developer Feature: Add Debug Accelerators to Toggle Touchscreen/Touchpad On or Off (CrOS) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix actions.xml. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/base/touch/touch_enabled.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
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() {
230 bool touch_screen_status = true;
231 bool touch_pad_status = true;
232
233 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
234 if (local_state) {
235 if (local_state->HasPrefPath(::prefs::kTouchScreenEnabled)) {
236 touch_screen_status =
237 local_state->GetBoolean(::prefs::kTouchScreenEnabled);
238 }
239
240 if (local_state->HasPrefPath(::prefs::kTouchPadEnabled))
241 touch_pad_status = local_state->GetBoolean(::prefs::kTouchPadEnabled);
242 }
243
244 ui::SetTouchEventsEnabled(touch_screen_status);
245 SetInternalTouchpadEnabled(touch_pad_status);
246 }
247
248 void InputDeviceSettings::ToggleTouchscreen() {
249 PrefService* local_state = g_browser_process->local_state();
250 if (!local_state)
251 return;
252
253 bool touch_screen_status = true;
254 if (local_state->HasPrefPath(::prefs::kTouchScreenEnabled))
255 touch_screen_status = local_state->GetBoolean(::prefs::kTouchScreenEnabled);
256
257 local_state->SetBoolean(::prefs::kTouchScreenEnabled, !touch_screen_status);
258 ui::SetTouchEventsEnabled(!touch_screen_status);
259 }
260
261 void InputDeviceSettings::ToggleTouchpad() {
262 PrefService* local_state = g_browser_process->local_state();
263 if (!local_state)
264 return;
265
266 bool touch_pad_status = true;
267 if (local_state->HasPrefPath(::prefs::kTouchPadEnabled))
268 touch_pad_status = local_state->GetBoolean(::prefs::kTouchPadEnabled);
269
270 local_state->SetBoolean(::prefs::kTouchPadEnabled, !touch_pad_status);
271 SetInternalTouchpadEnabled(!touch_pad_status);
272 }
273
219 } // namespace system 274 } // namespace system
220 } // namespace chromeos 275 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698