Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(701)

Side by Side Diff: extensions/browser/api/hid/hid_device_manager.h

Issue 514923002: Add more generic filters to the chrome.hid.getDevices API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clean up the chrome.hid documentation even more. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « extensions/browser/api/hid/hid_api.cc ('k') | extensions/browser/api/hid/hid_device_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 EXTENSIONS_BROWSER_API_HID_HID_DEVICE_MANAGER_H_ 5 #ifndef EXTENSIONS_BROWSER_API_HID_HID_DEVICE_MANAGER_H_
6 #define EXTENSIONS_BROWSER_API_HID_HID_DEVICE_MANAGER_H_ 6 #define EXTENSIONS_BROWSER_API_HID_HID_DEVICE_MANAGER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/threading/thread_checker.h" 14 #include "base/threading/thread_checker.h"
15 #include "device/hid/hid_device_info.h" 15 #include "device/hid/hid_device_info.h"
16 #include "extensions/browser/browser_context_keyed_api_factory.h" 16 #include "extensions/browser/browser_context_keyed_api_factory.h"
17 #include "extensions/common/api/hid.h" 17 #include "extensions/common/api/hid.h"
18 18
19 namespace device {
20 class HidDeviceFilter;
21 }
22
19 namespace extensions { 23 namespace extensions {
20 24
25 class Extension;
26
21 class HidDeviceManager : public BrowserContextKeyedAPI { 27 class HidDeviceManager : public BrowserContextKeyedAPI {
22 public: 28 public:
23 explicit HidDeviceManager(content::BrowserContext* context); 29 explicit HidDeviceManager(content::BrowserContext* context);
24 virtual ~HidDeviceManager(); 30 virtual ~HidDeviceManager();
25 31
26 // BrowserContextKeyedAPI implementation. 32 // BrowserContextKeyedAPI implementation.
27 static BrowserContextKeyedAPIFactory<HidDeviceManager>* GetFactoryInstance(); 33 static BrowserContextKeyedAPIFactory<HidDeviceManager>* GetFactoryInstance();
28 34
29 // Convenience method to get the HidDeviceManager for a profile. 35 // Convenience method to get the HidDeviceManager for a profile.
30 static HidDeviceManager* Get(content::BrowserContext* context) { 36 static HidDeviceManager* Get(content::BrowserContext* context) {
31 return BrowserContextKeyedAPIFactory<HidDeviceManager>::Get(context); 37 return BrowserContextKeyedAPIFactory<HidDeviceManager>::Get(context);
32 } 38 }
33 39
34 scoped_ptr<base::ListValue> GetApiDevices(uint16_t vendor_id, 40 scoped_ptr<base::ListValue> GetApiDevices(
35 uint16_t product_id); 41 const Extension* extension,
42 const std::vector<device::HidDeviceFilter>& filters);
36 43
37 bool GetDeviceInfo(int resource_id, device::HidDeviceInfo* device_info); 44 bool GetDeviceInfo(int resource_id, device::HidDeviceInfo* device_info);
38 45
46 bool HasPermission(const Extension* extension,
47 const device::HidDeviceInfo& device_info);
48
39 private: 49 private:
40 friend class BrowserContextKeyedAPIFactory<HidDeviceManager>; 50 friend class BrowserContextKeyedAPIFactory<HidDeviceManager>;
41 51
42 static const char* service_name() { return "HidDeviceManager"; } 52 static const char* service_name() { return "HidDeviceManager"; }
43 53
44 void UpdateDevices(); 54 void UpdateDevices();
45 55
46 base::ThreadChecker thread_checker_; 56 base::ThreadChecker thread_checker_;
47 57
48 int next_resource_id_; 58 int next_resource_id_;
49 59
50 typedef std::map<int, device::HidDeviceId> ResourceIdToDeviceIdMap; 60 typedef std::map<int, device::HidDeviceId> ResourceIdToDeviceIdMap;
51 typedef std::map<device::HidDeviceId, int> DeviceIdToResourceIdMap; 61 typedef std::map<device::HidDeviceId, int> DeviceIdToResourceIdMap;
52 62
53 ResourceIdToDeviceIdMap device_ids_; 63 ResourceIdToDeviceIdMap device_ids_;
54 DeviceIdToResourceIdMap resource_ids_; 64 DeviceIdToResourceIdMap resource_ids_;
55 65
56 DISALLOW_COPY_AND_ASSIGN(HidDeviceManager); 66 DISALLOW_COPY_AND_ASSIGN(HidDeviceManager);
57 }; 67 };
58 68
59 } // namespace extensions 69 } // namespace extensions
60 70
61 #endif // EXTENSIONS_BROWSER_API_HID_HID_DEVICE_MANAGER_H_ 71 #endif // EXTENSIONS_BROWSER_API_HID_HID_DEVICE_MANAGER_H_
OLDNEW
« no previous file with comments | « extensions/browser/api/hid/hid_api.cc ('k') | extensions/browser/api/hid/hid_device_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698