Chromium Code Reviews| Index: chrome/browser/chromeos/system/device_change_handler.cc |
| =================================================================== |
| --- chrome/browser/chromeos/system/device_change_handler.cc (revision 0) |
| +++ chrome/browser/chromeos/system/device_change_handler.cc (revision 0) |
| @@ -0,0 +1,71 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/chromeos/system/device_change_handler.h" |
| + |
| +#include "base/prefs/pref_service.h" |
| +#include "chrome/browser/browser_process.h" |
| +#include "chrome/browser/chromeos/system/input_device_settings.h" |
| +#include "chrome/browser/profiles/profile_manager.h" |
| +#include "chrome/common/pref_names.h" |
| + |
| +namespace chromeos { |
| +namespace system { |
| + |
| +DeviceChangeHandler::DeviceChangeHandler() |
| + : pointer_device_observer_(new PointerDeviceObserver) { |
| + pointer_device_observer_->AddObserver(this); |
| + pointer_device_observer_->Init(); |
| +} |
| + |
| +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.
|
| +} |
| + |
| +// When we detect a touchpad is attached, apply touchpad settings of the last |
| +// used profile. |
| +void DeviceChangeHandler::TouchpadExists(bool exists) { |
| + if (!exists) |
| + return; |
| + |
| + PrefService* prefs = |
| + g_browser_process->profile_manager()->GetLastUsedProfile()->GetPrefs(); |
| + |
| + const bool tap_to_click = prefs->GetBoolean(prefs::kTapToClickEnabled); |
| + system::touchpad_settings::SetTapToClick(tap_to_click); |
| + |
| + const bool tap_dragging = prefs->GetBoolean(prefs::kTapDraggingEnabled); |
| + system::touchpad_settings::SetTapDragging(tap_dragging); |
| + |
| + const bool three_finger_click = |
| + prefs->GetBoolean(prefs::kEnableTouchpadThreeFingerClick); |
| + system::touchpad_settings::SetThreeFingerClick(three_finger_click); |
| + |
| + const bool three_finger_swipe = |
| + prefs->GetBoolean(prefs::kEnableTouchpadThreeFingerSwipe); |
| + system::touchpad_settings::SetThreeFingerSwipe(three_finger_swipe); |
| + |
| + const int sensitivity = prefs->GetInteger(prefs::kTouchpadSensitivity); |
| + system::touchpad_settings::SetSensitivity(sensitivity); |
| +} |
| + |
| +// When we detect a mouse is attached, apply mouse settings of the last |
| +// used profile. |
| +void DeviceChangeHandler::MouseExists(bool exists) { |
| + if (!exists) |
| + return; |
| + |
| + PrefService* prefs = |
| + g_browser_process->profile_manager()->GetLastUsedProfile()->GetPrefs(); |
| + |
| + const int sensitivity = prefs->GetInteger(prefs::kMouseSensitivity); |
| + system::mouse_settings::SetSensitivity(sensitivity); |
| + |
| + const bool primary_button_right = |
| + prefs->GetBoolean(prefs::kPrimaryMouseButtonRight); |
| + system::mouse_settings::SetPrimaryButtonRight(primary_button_right); |
| +} |
| + |
| +} // namespace system |
| +} // namespace chromeos |
| + |