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
3 // found in the LICENSE file.
5 #include "chrome/browser/chromeos/system/pointer_device_observer.h"
7 #include "base/basictypes.h"
9 #include "base/bind_helpers.h"
10 #include "chrome/browser/chromeos/system/input_device_settings.h"
11 #include "content/public/browser/browser_thread.h"
12 #include "ui/events/devices/device_data_manager.h"
14 using content::BrowserThread
;
19 PointerDeviceObserver::PointerDeviceObserver()
20 : weak_factory_(this) {
23 PointerDeviceObserver::~PointerDeviceObserver() {
24 ui::DeviceDataManager::GetInstance()->RemoveObserver(this);
27 void PointerDeviceObserver::Init() {
28 ui::DeviceDataManager::GetInstance()->AddObserver(this);
31 void PointerDeviceObserver::CheckDevices() {
33 CheckTouchpadExists();
36 void PointerDeviceObserver::AddObserver(Observer
* observer
) {
37 observers_
.AddObserver(observer
);
40 void PointerDeviceObserver::RemoveObserver(Observer
* observer
) {
41 observers_
.RemoveObserver(observer
);
44 void PointerDeviceObserver::OnMouseDeviceConfigurationChanged() {
48 void PointerDeviceObserver::OnTouchpadDeviceConfigurationChanged() {
52 void PointerDeviceObserver::CheckTouchpadExists() {
53 InputDeviceSettings::Get()->TouchpadExists(
54 base::Bind(&PointerDeviceObserver::OnTouchpadExists
,
55 weak_factory_
.GetWeakPtr()));
58 void PointerDeviceObserver::CheckMouseExists() {
59 InputDeviceSettings::Get()->MouseExists(
60 base::Bind(&PointerDeviceObserver::OnMouseExists
,
61 weak_factory_
.GetWeakPtr()));
64 void PointerDeviceObserver::OnTouchpadExists(bool exists
) {
65 FOR_EACH_OBSERVER(Observer
, observers_
, TouchpadExists(exists
));
68 void PointerDeviceObserver::OnMouseExists(bool exists
) {
69 FOR_EACH_OBSERVER(Observer
, observers_
, MouseExists(exists
));
72 PointerDeviceObserver::Observer::~Observer() {
76 } // namespace chromeos