1 // Copyright 2014 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 #ifndef CHROME_BROWSER_CHROMEOS_DEVICE_INPUT_SERVICE_PROXY_H_
6 #define CHROME_BROWSER_CHROMEOS_DEVICE_INPUT_SERVICE_PROXY_H_
10 #include "base/callback.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h"
13 #include "base/observer_list.h"
14 #include "base/threading/thread_checker.h"
15 #include "device/hid/input_service_linux.h"
19 // Proxy to device::InputServiceLinux. Should be created and used on the UI
21 class InputServiceProxy {
23 typedef device::InputServiceLinux::InputDeviceInfo InputDeviceInfo;
27 virtual ~Observer() {}
28 virtual void OnInputDeviceAdded(const InputDeviceInfo& info) = 0;
29 virtual void OnInputDeviceRemoved(const std::string& id) = 0;
32 typedef base::Callback<void(const std::vector<InputDeviceInfo>& devices)>
34 typedef base::Callback<void(bool success, const InputDeviceInfo& info)>
35 GetDeviceInfoCallback;
40 void AddObserver(Observer* observer);
41 void RemoveObserver(Observer* observer);
43 void GetDevices(const GetDevicesCallback& callback);
44 void GetDeviceInfo(const std::string& id,
45 const GetDeviceInfoCallback& callback);
48 class ServiceObserver;
50 void OnDeviceAdded(const device::InputServiceLinux::InputDeviceInfo& info);
51 void OnDeviceRemoved(const std::string& id);
53 ObserverList<Observer> observers_;
54 scoped_ptr<ServiceObserver> service_observer_;
56 base::ThreadChecker thread_checker_;
58 base::WeakPtrFactory<InputServiceProxy> weak_factory_;
60 DISALLOW_COPY_AND_ASSIGN(InputServiceProxy);
63 } // namespace chromeos
65 #endif // CHROME_BROWSER_CHROMEOS_DEVICE_INPUT_SERVICE_PROXY_H_