Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/chromeos/system/device_change_handler.h" | |
| 6 | |
| 7 #include "base/prefs/pref_service.h" | |
| 8 #include "chrome/browser/browser_process.h" | |
| 9 #include "chrome/browser/chromeos/system/input_device_settings.h" | |
| 10 #include "chrome/browser/profiles/profile_manager.h" | |
| 11 #include "chrome/common/pref_names.h" | |
| 12 | |
| 13 namespace chromeos { | |
| 14 namespace system { | |
| 15 | |
| 16 DeviceChangeHandler::DeviceChangeHandler() | |
| 17 : pointer_device_observer_(new PointerDeviceObserver) { | |
| 18 pointer_device_observer_->AddObserver(this); | |
| 19 pointer_device_observer_->Init(); | |
| 20 } | |
| 21 | |
| 22 DeviceChangeHandler::~DeviceChangeHandler() { | |
|
xiyuan
2013/05/23 21:40:42
nit: Do we need to RemoveObserver(this)?
achuithb
2013/05/23 21:51:42
Better to be explicit, so I added it. Done.
| |
| 23 } | |
| 24 | |
| 25 // When we detect a touchpad is attached, apply touchpad settings of the last | |
| 26 // used profile. | |
| 27 void DeviceChangeHandler::TouchpadExists(bool exists) { | |
| 28 if (!exists) | |
| 29 return; | |
| 30 | |
| 31 PrefService* prefs = | |
| 32 g_browser_process->profile_manager()->GetLastUsedProfile()->GetPrefs(); | |
| 33 | |
| 34 const bool tap_to_click = prefs->GetBoolean(prefs::kTapToClickEnabled); | |
| 35 system::touchpad_settings::SetTapToClick(tap_to_click); | |
| 36 | |
| 37 const bool tap_dragging = prefs->GetBoolean(prefs::kTapDraggingEnabled); | |
| 38 system::touchpad_settings::SetTapDragging(tap_dragging); | |
| 39 | |
| 40 const bool three_finger_click = | |
| 41 prefs->GetBoolean(prefs::kEnableTouchpadThreeFingerClick); | |
| 42 system::touchpad_settings::SetThreeFingerClick(three_finger_click); | |
| 43 | |
| 44 const bool three_finger_swipe = | |
| 45 prefs->GetBoolean(prefs::kEnableTouchpadThreeFingerSwipe); | |
| 46 system::touchpad_settings::SetThreeFingerSwipe(three_finger_swipe); | |
| 47 | |
| 48 const int sensitivity = prefs->GetInteger(prefs::kTouchpadSensitivity); | |
| 49 system::touchpad_settings::SetSensitivity(sensitivity); | |
| 50 } | |
| 51 | |
| 52 // When we detect a mouse is attached, apply mouse settings of the last | |
| 53 // used profile. | |
| 54 void DeviceChangeHandler::MouseExists(bool exists) { | |
| 55 if (!exists) | |
| 56 return; | |
| 57 | |
| 58 PrefService* prefs = | |
| 59 g_browser_process->profile_manager()->GetLastUsedProfile()->GetPrefs(); | |
| 60 | |
| 61 const int sensitivity = prefs->GetInteger(prefs::kMouseSensitivity); | |
| 62 system::mouse_settings::SetSensitivity(sensitivity); | |
| 63 | |
| 64 const bool primary_button_right = | |
| 65 prefs->GetBoolean(prefs::kPrimaryMouseButtonRight); | |
| 66 system::mouse_settings::SetPrimaryButtonRight(primary_button_right); | |
| 67 } | |
| 68 | |
| 69 } // namespace system | |
| 70 } // namespace chromeos | |
| 71 | |
| OLD | NEW |