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 EXTENSIONS_BROWSER_API_HID_HID_DEVICE_MANAGER_H_
6 #define EXTENSIONS_BROWSER_API_HID_HID_DEVICE_MANAGER_H_
12 #include "base/basictypes.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/threading/thread_checker.h"
15 #include "device/hid/hid_device_info.h"
16 #include "extensions/browser/browser_context_keyed_api_factory.h"
17 #include "extensions/common/api/hid.h"
19 namespace extensions
{
21 class HidDeviceManager
: public BrowserContextKeyedAPI
{
23 explicit HidDeviceManager(content::BrowserContext
* context
);
24 virtual ~HidDeviceManager();
26 // BrowserContextKeyedAPI implementation.
27 static BrowserContextKeyedAPIFactory
<HidDeviceManager
>* GetFactoryInstance();
29 // Convenience method to get the HidDeviceManager for a profile.
30 static HidDeviceManager
* Get(content::BrowserContext
* context
) {
31 return BrowserContextKeyedAPIFactory
<HidDeviceManager
>::Get(context
);
34 scoped_ptr
<base::ListValue
> GetApiDevices(uint16_t vendor_id
,
37 bool GetDeviceInfo(int resource_id
, device::HidDeviceInfo
* device_info
);
40 friend class BrowserContextKeyedAPIFactory
<HidDeviceManager
>;
42 static const char* service_name() { return "HidDeviceManager"; }
46 base::ThreadChecker thread_checker_
;
48 int next_resource_id_
;
50 typedef std::map
<int, device::HidDeviceId
> ResourceIdToDeviceIdMap
;
51 typedef std::map
<device::HidDeviceId
, int> DeviceIdToResourceIdMap
;
53 ResourceIdToDeviceIdMap device_ids_
;
54 DeviceIdToResourceIdMap resource_ids_
;
56 DISALLOW_COPY_AND_ASSIGN(HidDeviceManager
);
59 } // namespace extensions
61 #endif // EXTENSIONS_BROWSER_API_HID_HID_DEVICE_MANAGER_H_