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

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

Issue 1115213004: Add chrome.hid.getUserSelectedDevices API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 5 years, 6 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
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_API_H_ 5 #ifndef EXTENSIONS_BROWSER_API_HID_HID_API_H_
6 #define EXTENSIONS_BROWSER_API_HID_HID_API_H_ 6 #define EXTENSIONS_BROWSER_API_HID_HID_API_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "extensions/browser/api/api_resource_manager.h" 12 #include "extensions/browser/api/api_resource_manager.h"
13 #include "extensions/browser/api/hid/hid_connection_resource.h" 13 #include "extensions/browser/api/hid/hid_connection_resource.h"
14 #include "extensions/browser/api/hid/hid_device_manager.h" 14 #include "extensions/browser/api/hid/hid_device_manager.h"
15 #include "extensions/browser/extension_function.h" 15 #include "extensions/browser/extension_function.h"
16 #include "extensions/common/api/hid.h" 16 #include "extensions/common/api/hid.h"
17 17
18 namespace device { 18 namespace device {
19 class HidConnection; 19 class HidConnection;
20 class HidDeviceInfo;
20 class HidService; 21 class HidService;
21 } // namespace device 22 } // namespace device
22 23
23 namespace net { 24 namespace net {
24 class IOBuffer; 25 class IOBuffer;
25 } // namespace net 26 } // namespace net
26 27
27 namespace extensions { 28 namespace extensions {
28 29
30 class DevicePermissionsPrompt;
31
29 class HidGetDevicesFunction : public UIThreadExtensionFunction { 32 class HidGetDevicesFunction : public UIThreadExtensionFunction {
30 public: 33 public:
31 DECLARE_EXTENSION_FUNCTION("hid.getDevices", HID_GETDEVICES); 34 DECLARE_EXTENSION_FUNCTION("hid.getDevices", HID_GETDEVICES);
32 35
33 HidGetDevicesFunction(); 36 HidGetDevicesFunction();
34 37
35 private: 38 private:
36 ~HidGetDevicesFunction() override; 39 ~HidGetDevicesFunction() override;
37 40
38 // ExtensionFunction: 41 // ExtensionFunction:
39 ResponseAction Run() override; 42 ResponseAction Run() override;
40 43
41 void OnEnumerationComplete(scoped_ptr<base::ListValue> devices); 44 void OnEnumerationComplete(scoped_ptr<base::ListValue> devices);
42 45
43 DISALLOW_COPY_AND_ASSIGN(HidGetDevicesFunction); 46 DISALLOW_COPY_AND_ASSIGN(HidGetDevicesFunction);
44 }; 47 };
45 48
49 class HidGetUserSelectedDevicesFunction : public UIThreadExtensionFunction {
50 public:
51 DECLARE_EXTENSION_FUNCTION("hid.getUserSelectedDevices",
52 HID_GETUSERSELECTEDDEVICES)
53
54 HidGetUserSelectedDevicesFunction();
55
56 private:
57 ~HidGetUserSelectedDevicesFunction() override;
58
59 // ExtensionFunction:
60 ResponseAction Run() override;
61
62 void OnDevicesChosen(
63 const std::vector<scoped_refptr<device::HidDeviceInfo>>& devices);
64
65 HidDeviceManager* device_manager_;
66 scoped_ptr<DevicePermissionsPrompt> prompt_;
67
68 DISALLOW_COPY_AND_ASSIGN(HidGetUserSelectedDevicesFunction);
69 };
70
46 class HidConnectFunction : public UIThreadExtensionFunction { 71 class HidConnectFunction : public UIThreadExtensionFunction {
47 public: 72 public:
48 DECLARE_EXTENSION_FUNCTION("hid.connect", HID_CONNECT); 73 DECLARE_EXTENSION_FUNCTION("hid.connect", HID_CONNECT);
49 74
50 HidConnectFunction(); 75 HidConnectFunction();
51 76
52 private: 77 private:
53 ~HidConnectFunction() override; 78 ~HidConnectFunction() override;
54 79
55 // ExtensionFunction: 80 // ExtensionFunction:
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 void OnFinished(bool success); 204 void OnFinished(bool success);
180 205
181 scoped_ptr<core_api::hid::SendFeatureReport::Params> parameters_; 206 scoped_ptr<core_api::hid::SendFeatureReport::Params> parameters_;
182 207
183 DISALLOW_COPY_AND_ASSIGN(HidSendFeatureReportFunction); 208 DISALLOW_COPY_AND_ASSIGN(HidSendFeatureReportFunction);
184 }; 209 };
185 210
186 } // namespace extensions 211 } // namespace extensions
187 212
188 #endif // EXTENSIONS_BROWSER_API_HID_HID_API_H_ 213 #endif // EXTENSIONS_BROWSER_API_HID_HID_API_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/extensions/device_permissions_dialog_view.cc ('k') | extensions/browser/api/hid/hid_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698