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"
14 #include "chrome/browser/chromeos/events/xinput_hierarchy_changed_event_listener.h"
17 using content::BrowserThread
;
22 PointerDeviceObserver::PointerDeviceObserver()
23 : weak_factory_(this) {
26 PointerDeviceObserver::~PointerDeviceObserver() {
28 XInputHierarchyChangedEventListener::GetInstance()
29 ->RemoveObserver(this);
33 void PointerDeviceObserver::Init() {
35 XInputHierarchyChangedEventListener::GetInstance()
40 void PointerDeviceObserver::CheckDevices() {
42 CheckTouchpadExists();
45 void PointerDeviceObserver::AddObserver(Observer
* observer
) {
46 observers_
.AddObserver(observer
);
49 void PointerDeviceObserver::RemoveObserver(Observer
* observer
) {
50 observers_
.RemoveObserver(observer
);
53 void PointerDeviceObserver::DeviceHierarchyChanged() {
57 void PointerDeviceObserver::CheckTouchpadExists() {
58 InputDeviceSettings::Get()->TouchpadExists(
59 base::Bind(&PointerDeviceObserver::OnTouchpadExists
,
60 weak_factory_
.GetWeakPtr()));
63 void PointerDeviceObserver::CheckMouseExists() {
64 InputDeviceSettings::Get()->MouseExists(
65 base::Bind(&PointerDeviceObserver::OnMouseExists
,
66 weak_factory_
.GetWeakPtr()));
69 void PointerDeviceObserver::OnTouchpadExists(bool exists
) {
70 FOR_EACH_OBSERVER(Observer
, observers_
, TouchpadExists(exists
));
73 void PointerDeviceObserver::OnMouseExists(bool exists
) {
74 FOR_EACH_OBSERVER(Observer
, observers_
, MouseExists(exists
));
77 PointerDeviceObserver::Observer::~Observer() {
81 } // namespace chromeos