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. 4 5 #ifndef CHROME_BROWSER_CHROMEOS_SYSTEM_POINTER_DEVICE_OBSERVER_H_ 6 #define CHROME_BROWSER_CHROMEOS_SYSTEM_POINTER_DEVICE_OBSERVER_H_ 7 8 #include "base/memory/weak_ptr.h" 9 #include "base/observer_list.h" 10 #include "chrome/browser/chromeos/device_hierarchy_observer.h" 11 12 namespace chromeos { 13 namespace system { 14 15 class PointerDeviceObserver : public DeviceHierarchyObserver { 16 public: 17 PointerDeviceObserver(); 18 virtual ~PointerDeviceObserver(); 19 20 // Start observing device hierarchy. 21 void Init(); 22 23 // Check for presence of devices. 24 void CheckDevices(); 25 26 class Observer { 27 public: 28 virtual void TouchpadExists(bool exists) = 0; 29 virtual void MouseExists(bool exists) = 0; 30 31 protected: 32 Observer() {} 33 virtual ~Observer(); 34 }; 35 void AddObserver(Observer* observer); 36 void RemoveObserver(Observer* observer); 37 38 private: 39 // DeviceHierarchyObserver implementation. 40 virtual void DeviceHierarchyChanged() OVERRIDE; 41 virtual void DeviceAdded(int device_id) OVERRIDE {} 42 virtual void DeviceRemoved(int device_id) OVERRIDE {} 43 44 // Check for pointer devices. 45 void CheckTouchpadExists(); 46 void CheckMouseExists(); 47 48 // Callback for pointer device checks. 49 void OnTouchpadExists(bool exists); 50 void OnMouseExists(bool exists); 51 52 ObserverList<Observer> observers_; 53 54 base::WeakPtrFactory<PointerDeviceObserver> weak_factory_; 55 56 DISALLOW_COPY_AND_ASSIGN(PointerDeviceObserver); 57 }; 58 59 } // namespace system 60 } // namespace chromeos 61 62 #endif // CHROME_BROWSER_CHROMEOS_SYSTEM_POINTER_DEVICE_OBSERVER_H_ 63