OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef DEVICE_HID_HID_SERVICE_H_ | 5 #ifndef DEVICE_HID_HID_SERVICE_H_ |
6 #define DEVICE_HID_HID_SERVICE_H_ | 6 #define DEVICE_HID_HID_SERVICE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 13 matching lines...) Expand all Loading... |
24 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner, | 24 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner, |
25 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner); | 25 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner); |
26 | 26 |
27 // Enumerates and returns a list of device identifiers. | 27 // Enumerates and returns a list of device identifiers. |
28 virtual void GetDevices(std::vector<HidDeviceInfo>* devices); | 28 virtual void GetDevices(std::vector<HidDeviceInfo>* devices); |
29 | 29 |
30 // Fills in a DeviceInfo struct with info for the given device_id. | 30 // Fills in a DeviceInfo struct with info for the given device_id. |
31 // Returns |true| if successful or |false| if |device_id| is invalid. | 31 // Returns |true| if successful or |false| if |device_id| is invalid. |
32 bool GetDeviceInfo(const HidDeviceId& device_id, HidDeviceInfo* info) const; | 32 bool GetDeviceInfo(const HidDeviceId& device_id, HidDeviceInfo* info) const; |
33 | 33 |
| 34 #if defined(OS_CHROMEOS) |
| 35 // Requests access to the given device from the Chrome OS permission broker. |
| 36 virtual void RequestAccess( |
| 37 const HidDeviceId& device_id, |
| 38 const base::Callback<void(bool success)>& callback) = 0; |
| 39 #endif |
| 40 |
34 virtual scoped_refptr<HidConnection> Connect( | 41 virtual scoped_refptr<HidConnection> Connect( |
35 const HidDeviceId& device_id) = 0; | 42 const HidDeviceId& device_id) = 0; |
36 | 43 |
37 protected: | 44 protected: |
38 friend class HidConnectionTest; | 45 friend class HidConnectionTest; |
39 | 46 |
40 typedef std::map<HidDeviceId, HidDeviceInfo> DeviceMap; | 47 typedef std::map<HidDeviceId, HidDeviceInfo> DeviceMap; |
41 | 48 |
42 HidService(); | 49 HidService(); |
43 virtual ~HidService(); | 50 virtual ~HidService(); |
44 | 51 |
45 void AddDevice(const HidDeviceInfo& info); | 52 void AddDevice(const HidDeviceInfo& info); |
46 void RemoveDevice(const HidDeviceId& device_id); | 53 void RemoveDevice(const HidDeviceId& device_id); |
47 | 54 |
48 const DeviceMap& devices() const { return devices_; } | 55 const DeviceMap& devices() const { return devices_; } |
49 | 56 |
50 base::ThreadChecker thread_checker_; | 57 base::ThreadChecker thread_checker_; |
51 | 58 |
52 private: | 59 private: |
53 class Destroyer; | 60 class Destroyer; |
54 | 61 |
55 DeviceMap devices_; | 62 DeviceMap devices_; |
56 | 63 |
57 DISALLOW_COPY_AND_ASSIGN(HidService); | 64 DISALLOW_COPY_AND_ASSIGN(HidService); |
58 }; | 65 }; |
59 | 66 |
60 } // namespace device | 67 } // namespace device |
61 | 68 |
62 #endif // DEVICE_HID_HID_SERVICE_H_ | 69 #endif // DEVICE_HID_HID_SERVICE_H_ |
OLD | NEW |