1// Copyright 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 "chrome/browser/chromeos/system/input_device_settings.h"
8
9namespace chromeos {
10namespace system {
11
12DeviceChangeHandler::DeviceChangeHandler()
13    : pointer_device_observer_(new PointerDeviceObserver) {
14  pointer_device_observer_->AddObserver(this);
15  pointer_device_observer_->Init();
16
17  // Apply settings on startup.
18  TouchpadExists(true);
19  MouseExists(true);
20}
21
22DeviceChangeHandler::~DeviceChangeHandler() {
23  pointer_device_observer_->RemoveObserver(this);
24}
25
26// When we detect a touchpad is attached, apply touchpad settings that was
27// cached inside InputDeviceSettings.
28void DeviceChangeHandler::TouchpadExists(bool exists) {
29  if (!exists)
30    return;
31  system::InputDeviceSettings::Get()->ReapplyTouchpadSettings();
32}
33
34// When we detect a mouse is attached, apply mouse settings that was cached
35// inside InputDeviceSettings.
36void DeviceChangeHandler::MouseExists(bool exists) {
37  if (!exists)
38    return;
39  system::InputDeviceSettings::Get()->ReapplyMouseSettings();
40}
41
42}  // namespace system
43}  // namespace chromeos
44