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

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

Issue 2533373002: Enabled/disable touch screen in TabletPowerButtonController (Closed)
Patch Set: add SetTouchscreenEnabled and OnLoginStateChanged Created 4 years 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 "chrome/browser/browser_process.h" 7 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" 8 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
9 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" 9 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h"
10 #include "chrome/browser/profiles/profile_manager.h" 10 #include "chrome/browser/profiles/profile_manager.h"
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 void InputDeviceSettings::RegisterProfilePrefs(PrefRegistrySimple* registry) { 237 void InputDeviceSettings::RegisterProfilePrefs(PrefRegistrySimple* registry) {
238 registry->RegisterBooleanPref(::prefs::kTouchScreenEnabled, true); 238 registry->RegisterBooleanPref(::prefs::kTouchScreenEnabled, true);
239 registry->RegisterBooleanPref(::prefs::kTouchPadEnabled, true); 239 registry->RegisterBooleanPref(::prefs::kTouchPadEnabled, true);
240 } 240 }
241 241
242 void InputDeviceSettings::UpdateTouchDevicesStatusFromActiveProfilePrefs() { 242 void InputDeviceSettings::UpdateTouchDevicesStatusFromActiveProfilePrefs() {
243 PrefService* user_prefs = GetActiveProfilePrefs(); 243 PrefService* user_prefs = GetActiveProfilePrefs();
244 if (!user_prefs) 244 if (!user_prefs)
245 return; 245 return;
246 246
247 const bool touch_screen_status = 247 const bool touch_screen_status = IsTouchscreenEnabled();
Daniel Erat 2016/11/30 22:58:07 mind just inlining this in the SetTouchscreensEnab
Qiang(Joe) Xu 2016/12/02 17:42:52 Done.
248 user_prefs->HasPrefPath(::prefs::kTouchScreenEnabled)
249 ? user_prefs->GetBoolean(::prefs::kTouchScreenEnabled)
250 : true;
251 248
252 const bool touch_pad_status = 249 const bool touch_pad_status =
253 user_prefs->HasPrefPath(::prefs::kTouchPadEnabled) 250 user_prefs->HasPrefPath(::prefs::kTouchPadEnabled)
254 ? user_prefs->GetBoolean(::prefs::kTouchPadEnabled) 251 ? user_prefs->GetBoolean(::prefs::kTouchPadEnabled)
255 : true; 252 : true;
256 253
257 SetTouchscreensEnabled(touch_screen_status); 254 SetTouchscreensEnabled(touch_screen_status);
258 SetInternalTouchpadEnabled(touch_pad_status); 255 SetInternalTouchpadEnabled(touch_pad_status);
259 } 256 }
260 257
261 void InputDeviceSettings::ToggleTouchscreen() { 258 bool InputDeviceSettings::IsTouchscreenEnabled() const {
Daniel Erat 2016/11/30 22:58:07 mind renaming this to IsTouchscreenEnabledInPrefs(
Qiang(Joe) Xu 2016/12/02 17:42:52 Done.
259 PrefService* user_prefs = GetActiveProfilePrefs();
260 if (!user_prefs)
261 return true;
262
263 return user_prefs->HasPrefPath(::prefs::kTouchScreenEnabled)
264 ? user_prefs->GetBoolean(::prefs::kTouchScreenEnabled)
265 : true;
266 }
267
268 void InputDeviceSettings::SetTouchscreenEnabled(bool enabled) {
262 PrefService* user_prefs = GetActiveProfilePrefs(); 269 PrefService* user_prefs = GetActiveProfilePrefs();
263 if (!user_prefs) 270 if (!user_prefs)
264 return; 271 return;
265 272
266 const bool touch_screen_status = 273 user_prefs->SetBoolean(::prefs::kTouchScreenEnabled, enabled);
267 user_prefs->HasPrefPath(::prefs::kTouchScreenEnabled) 274 SetTouchscreensEnabled(enabled);
268 ? user_prefs->GetBoolean(::prefs::kTouchScreenEnabled)
269 : true;
270
271 user_prefs->SetBoolean(::prefs::kTouchScreenEnabled, !touch_screen_status);
272 SetTouchscreensEnabled(!touch_screen_status);
273 } 275 }
274 276
275 void InputDeviceSettings::ToggleTouchpad() { 277 void InputDeviceSettings::ToggleTouchpad() {
276 PrefService* user_prefs = GetActiveProfilePrefs(); 278 PrefService* user_prefs = GetActiveProfilePrefs();
277 if (!user_prefs) 279 if (!user_prefs)
278 return; 280 return;
279 281
280 const bool touch_pad_status = 282 const bool touch_pad_status =
281 user_prefs->HasPrefPath(::prefs::kTouchPadEnabled) 283 user_prefs->HasPrefPath(::prefs::kTouchPadEnabled)
282 ? user_prefs->GetBoolean(::prefs::kTouchPadEnabled) 284 ? user_prefs->GetBoolean(::prefs::kTouchPadEnabled)
283 : true; 285 : true;
284 286
285 user_prefs->SetBoolean(::prefs::kTouchPadEnabled, !touch_pad_status); 287 user_prefs->SetBoolean(::prefs::kTouchPadEnabled, !touch_pad_status);
286 SetInternalTouchpadEnabled(!touch_pad_status); 288 SetInternalTouchpadEnabled(!touch_pad_status);
287 } 289 }
288 290
289 } // namespace system 291 } // namespace system
290 } // namespace chromeos 292 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698