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

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

Issue 2533373002: Enabled/disable touch screen in TabletPowerButtonController (Closed)
Patch Set: nits 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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 bool keyboard_driven = false; 227 bool keyboard_driven = false;
228 if (chromeos::system::StatisticsProvider::GetInstance()->GetMachineFlag( 228 if (chromeos::system::StatisticsProvider::GetInstance()->GetMachineFlag(
229 kOemKeyboardDrivenOobeKey, &keyboard_driven)) { 229 kOemKeyboardDrivenOobeKey, &keyboard_driven)) {
230 return keyboard_driven; 230 return keyboard_driven;
231 } 231 }
232 232
233 return false; 233 return false;
234 } 234 }
235 235
236 // static 236 // static
237 void InputDeviceSettings::RegisterPrefs(PrefRegistrySimple* registry) {
238 registry->RegisterBooleanPref(::prefs::kTouchscreenEnabledLocal, true);
239 }
240
241 // static
237 void InputDeviceSettings::RegisterProfilePrefs(PrefRegistrySimple* registry) { 242 void InputDeviceSettings::RegisterProfilePrefs(PrefRegistrySimple* registry) {
238 registry->RegisterBooleanPref(::prefs::kTouchScreenEnabled, true); 243 registry->RegisterBooleanPref(::prefs::kTouchscreenEnabled, true);
239 registry->RegisterBooleanPref(::prefs::kTouchPadEnabled, true); 244 registry->RegisterBooleanPref(::prefs::kTouchpadEnabled, true);
240 } 245 }
241 246
242 void InputDeviceSettings::UpdateTouchDevicesStatusFromActiveProfilePrefs() { 247 void InputDeviceSettings::UpdateTouchDevicesStatusFromPrefs() {
248 UpdateTouchscreenStatusFromPrefs();
249
243 PrefService* user_prefs = GetActiveProfilePrefs(); 250 PrefService* user_prefs = GetActiveProfilePrefs();
244 if (!user_prefs) 251 if (!user_prefs)
245 return; 252 return;
246 253
247 const bool touch_screen_status = 254 const bool touchpad_status =
248 user_prefs->HasPrefPath(::prefs::kTouchScreenEnabled) 255 user_prefs->HasPrefPath(::prefs::kTouchpadEnabled)
249 ? user_prefs->GetBoolean(::prefs::kTouchScreenEnabled) 256 ? user_prefs->GetBoolean(::prefs::kTouchpadEnabled)
250 : true; 257 : true;
251 258 SetInternalTouchpadEnabled(touchpad_status);
252 const bool touch_pad_status =
253 user_prefs->HasPrefPath(::prefs::kTouchPadEnabled)
254 ? user_prefs->GetBoolean(::prefs::kTouchPadEnabled)
255 : true;
256
257 SetTouchscreensEnabled(touch_screen_status);
258 SetInternalTouchpadEnabled(touch_pad_status);
259 } 259 }
260 260
261 void InputDeviceSettings::ToggleTouchscreen() { 261 bool InputDeviceSettings::IsTouchscreenEnabledInPrefs(
262 PrefService* user_prefs = GetActiveProfilePrefs(); 262 bool use_local_state) const {
263 if (!user_prefs) 263 if (use_local_state) {
264 return; 264 PrefService* local_state = g_browser_process->local_state();
265 DCHECK(local_state);
265 266
266 const bool touch_screen_status = 267 return local_state->HasPrefPath(::prefs::kTouchscreenEnabledLocal)
267 user_prefs->HasPrefPath(::prefs::kTouchScreenEnabled) 268 ? local_state->GetBoolean(::prefs::kTouchscreenEnabledLocal)
268 ? user_prefs->GetBoolean(::prefs::kTouchScreenEnabled) 269 : true;
269 : true; 270 } else {
271 PrefService* user_prefs = GetActiveProfilePrefs();
272 if (!user_prefs)
273 return true;
270 274
271 user_prefs->SetBoolean(::prefs::kTouchScreenEnabled, !touch_screen_status); 275 return user_prefs->HasPrefPath(::prefs::kTouchscreenEnabled)
272 SetTouchscreensEnabled(!touch_screen_status); 276 ? user_prefs->GetBoolean(::prefs::kTouchscreenEnabled)
277 : true;
278 }
279 }
280
281 void InputDeviceSettings::SetTouchscreenEnabledInPrefs(bool enabled,
282 bool use_local_state) {
283 if (use_local_state) {
284 PrefService* local_state = g_browser_process->local_state();
285 DCHECK(local_state);
286 local_state->SetBoolean(::prefs::kTouchscreenEnabledLocal, enabled);
287 } else {
288 PrefService* user_prefs = GetActiveProfilePrefs();
289 if (!user_prefs)
290 return;
291
292 user_prefs->SetBoolean(::prefs::kTouchscreenEnabled, enabled);
293 }
294 }
295
296 void InputDeviceSettings::UpdateTouchscreenStatusFromPrefs() {
297 bool enabled_in_local_state = IsTouchscreenEnabledInPrefs(true);
298 bool enabled_in_user_prefs = IsTouchscreenEnabledInPrefs(false);
299 SetTouchscreensEnabled(enabled_in_local_state && enabled_in_user_prefs);
273 } 300 }
274 301
275 void InputDeviceSettings::ToggleTouchpad() { 302 void InputDeviceSettings::ToggleTouchpad() {
276 PrefService* user_prefs = GetActiveProfilePrefs(); 303 PrefService* user_prefs = GetActiveProfilePrefs();
277 if (!user_prefs) 304 if (!user_prefs)
278 return; 305 return;
279 306
280 const bool touch_pad_status = 307 const bool touchpad_status =
281 user_prefs->HasPrefPath(::prefs::kTouchPadEnabled) 308 user_prefs->HasPrefPath(::prefs::kTouchpadEnabled)
282 ? user_prefs->GetBoolean(::prefs::kTouchPadEnabled) 309 ? user_prefs->GetBoolean(::prefs::kTouchpadEnabled)
283 : true; 310 : true;
284 311
285 user_prefs->SetBoolean(::prefs::kTouchPadEnabled, !touch_pad_status); 312 user_prefs->SetBoolean(::prefs::kTouchpadEnabled, !touchpad_status);
286 SetInternalTouchpadEnabled(!touch_pad_status); 313 SetInternalTouchpadEnabled(!touchpad_status);
287 } 314 }
288 315
289 } // namespace system 316 } // namespace system
290 } // namespace chromeos 317 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/system/input_device_settings.h ('k') | chrome/browser/prefs/browser_prefs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698