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

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

Issue 2467023004: Make the toggle touchscreen/touchpad shortcuts apply per-user (Closed)
Patch Set: Doing the migration right Created 4 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 "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/common/pref_names.h" 11 #include "chrome/common/pref_names.h"
11 #include "chromeos/system/statistics_provider.h" 12 #include "chromeos/system/statistics_provider.h"
12 #include "components/prefs/pref_registry_simple.h" 13 #include "components/prefs/pref_registry_simple.h"
13 #include "components/prefs/pref_service.h" 14 #include "components/prefs/pref_service.h"
14 15
15 namespace chromeos { 16 namespace chromeos {
16 namespace system { 17 namespace system {
17 18
19 namespace {
20
21 PrefService* GetActiveProfilePrefs() {
22 Profile* profile = ProfileManager::GetActiveUserProfile();
23 return profile ? profile->GetPrefs() : nullptr;
24 }
25
26 } // namespace
27
18 TouchpadSettings::TouchpadSettings() { 28 TouchpadSettings::TouchpadSettings() {
19 } 29 }
20 30
21 TouchpadSettings::TouchpadSettings(const TouchpadSettings& other) = default; 31 TouchpadSettings::TouchpadSettings(const TouchpadSettings& other) = default;
22 32
23 TouchpadSettings& TouchpadSettings::operator=(const TouchpadSettings& other) { 33 TouchpadSettings& TouchpadSettings::operator=(const TouchpadSettings& other) {
24 if (&other != this) { 34 if (&other != this) {
25 sensitivity_ = other.sensitivity_; 35 sensitivity_ = other.sensitivity_;
26 tap_to_click_ = other.tap_to_click_; 36 tap_to_click_ = other.tap_to_click_;
27 three_finger_click_ = other.three_finger_click_; 37 three_finger_click_ = other.three_finger_click_;
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 bool keyboard_driven = false; 227 bool keyboard_driven = false;
218 if (chromeos::system::StatisticsProvider::GetInstance()->GetMachineFlag( 228 if (chromeos::system::StatisticsProvider::GetInstance()->GetMachineFlag(
219 kOemKeyboardDrivenOobeKey, &keyboard_driven)) { 229 kOemKeyboardDrivenOobeKey, &keyboard_driven)) {
220 return keyboard_driven; 230 return keyboard_driven;
221 } 231 }
222 232
223 return false; 233 return false;
224 } 234 }
225 235
226 // static 236 // static
227 void InputDeviceSettings::RegisterPrefs(PrefRegistrySimple* registry) { 237 void InputDeviceSettings::RegisterProfilePrefs(PrefRegistrySimple* registry) {
228 registry->RegisterBooleanPref(::prefs::kTouchScreenEnabled, true); 238 registry->RegisterBooleanPref(::prefs::kTouchScreenEnabled, true);
229 registry->RegisterBooleanPref(::prefs::kTouchPadEnabled, true); 239 registry->RegisterBooleanPref(::prefs::kTouchPadEnabled, true);
230 } 240 }
231 241
232 void InputDeviceSettings::InitTouchDevicesStatusFromLocalPrefs() { 242 void InputDeviceSettings::UpdateTouchDevicesStatusFromActiveProfilePrefs() {
233 PrefService* local_state = g_browser_process->local_state(); 243 PrefService* user_prefs = GetActiveProfilePrefs();
234 DCHECK(local_state); 244 if (!user_prefs)
245 return;
235 246
236 const bool touch_screen_status = 247 const bool touch_screen_status =
237 local_state->HasPrefPath(::prefs::kTouchScreenEnabled) 248 user_prefs->HasPrefPath(::prefs::kTouchScreenEnabled)
238 ? local_state->GetBoolean(::prefs::kTouchScreenEnabled) 249 ? user_prefs->GetBoolean(::prefs::kTouchScreenEnabled)
239 : true; 250 : true;
240 251
241 const bool touch_pad_status = 252 const bool touch_pad_status =
242 local_state->HasPrefPath(::prefs::kTouchPadEnabled) 253 user_prefs->HasPrefPath(::prefs::kTouchPadEnabled)
243 ? local_state->GetBoolean(::prefs::kTouchPadEnabled) 254 ? user_prefs->GetBoolean(::prefs::kTouchPadEnabled)
244 : true; 255 : true;
245 256
246 SetTouchscreensEnabled(touch_screen_status); 257 SetTouchscreensEnabled(touch_screen_status);
247 SetInternalTouchpadEnabled(touch_pad_status); 258 SetInternalTouchpadEnabled(touch_pad_status);
248 } 259 }
249 260
250 void InputDeviceSettings::ToggleTouchscreen() { 261 void InputDeviceSettings::ToggleTouchscreen() {
251 PrefService* local_state = g_browser_process->local_state(); 262 PrefService* user_prefs = GetActiveProfilePrefs();
252 DCHECK(local_state); 263 if (!user_prefs)
264 return;
253 265
254 const bool touch_screen_status = 266 const bool touch_screen_status =
255 local_state->HasPrefPath(::prefs::kTouchScreenEnabled) 267 user_prefs->HasPrefPath(::prefs::kTouchScreenEnabled)
256 ? local_state->GetBoolean(::prefs::kTouchScreenEnabled) 268 ? user_prefs->GetBoolean(::prefs::kTouchScreenEnabled)
257 : true; 269 : true;
258 270
259 local_state->SetBoolean(::prefs::kTouchScreenEnabled, !touch_screen_status); 271 user_prefs->SetBoolean(::prefs::kTouchScreenEnabled, !touch_screen_status);
260 SetTouchscreensEnabled(!touch_screen_status); 272 SetTouchscreensEnabled(!touch_screen_status);
261 } 273 }
262 274
263 void InputDeviceSettings::ToggleTouchpad() { 275 void InputDeviceSettings::ToggleTouchpad() {
264 PrefService* local_state = g_browser_process->local_state(); 276 PrefService* user_prefs = GetActiveProfilePrefs();
265 DCHECK(local_state); 277 if (!user_prefs)
278 return;
266 279
267 const bool touch_pad_status = 280 const bool touch_pad_status =
268 local_state->HasPrefPath(::prefs::kTouchPadEnabled) 281 user_prefs->HasPrefPath(::prefs::kTouchPadEnabled)
269 ? local_state->GetBoolean(::prefs::kTouchPadEnabled) 282 ? user_prefs->GetBoolean(::prefs::kTouchPadEnabled)
270 : true; 283 : true;
271 284
272 local_state->SetBoolean(::prefs::kTouchPadEnabled, !touch_pad_status); 285 user_prefs->SetBoolean(::prefs::kTouchPadEnabled, !touch_pad_status);
273 SetInternalTouchpadEnabled(!touch_pad_status); 286 SetInternalTouchpadEnabled(!touch_pad_status);
274 } 287 }
275 288
276 } // namespace system 289 } // namespace system
277 } // namespace chromeos 290 } // 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