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 CHROME_BROWSER_EXTENSIONS_API_HID_HID_API_H_ | 5 #ifndef EXTENSIONS_BROWSER_API_HID_HID_API_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_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 "chrome/browser/extensions/api/hid/hid_connection_resource.h" | |
13 #include "chrome/browser/extensions/api/hid/hid_device_manager.h" | |
14 #include "chrome/common/extensions/api/hid.h" | |
15 #include "extensions/browser/api/api_resource_manager.h" | 12 #include "extensions/browser/api/api_resource_manager.h" |
16 #include "extensions/browser/api/async_api_function.h" | 13 #include "extensions/browser/api/async_api_function.h" |
| 14 #include "extensions/browser/api/hid/hid_connection_resource.h" |
| 15 #include "extensions/browser/api/hid/hid_device_manager.h" |
| 16 #include "extensions/common/api/hid.h" |
17 | 17 |
18 namespace net { | 18 namespace net { |
19 | 19 |
20 class IOBufferWithSize; | 20 class IOBufferWithSize; |
21 | 21 |
22 } // namespace net | 22 } // namespace net |
23 | 23 |
24 namespace extensions { | 24 namespace extensions { |
25 | 25 |
26 class HidAsyncApiFunction : public AsyncApiFunction { | 26 class HidAsyncApiFunction : public AsyncApiFunction { |
(...skipping 24 matching lines...) Expand all Loading... |
51 | 51 |
52 HidGetDevicesFunction(); | 52 HidGetDevicesFunction(); |
53 | 53 |
54 protected: | 54 protected: |
55 virtual bool Prepare() OVERRIDE; | 55 virtual bool Prepare() OVERRIDE; |
56 virtual void AsyncWorkStart() OVERRIDE; | 56 virtual void AsyncWorkStart() OVERRIDE; |
57 | 57 |
58 virtual ~HidGetDevicesFunction(); | 58 virtual ~HidGetDevicesFunction(); |
59 | 59 |
60 scoped_ptr<base::ListValue> result_; | 60 scoped_ptr<base::ListValue> result_; |
61 scoped_ptr<extensions::api::hid::GetDevices::Params> parameters_; | 61 scoped_ptr<core_api::hid::GetDevices::Params> parameters_; |
62 | 62 |
63 private: | 63 private: |
64 DISALLOW_COPY_AND_ASSIGN(HidGetDevicesFunction); | 64 DISALLOW_COPY_AND_ASSIGN(HidGetDevicesFunction); |
65 }; | 65 }; |
66 | 66 |
67 class HidConnectFunction : public HidAsyncApiFunction { | 67 class HidConnectFunction : public HidAsyncApiFunction { |
68 public: | 68 public: |
69 DECLARE_EXTENSION_FUNCTION("hid.connect", HID_CONNECT); | 69 DECLARE_EXTENSION_FUNCTION("hid.connect", HID_CONNECT); |
70 | 70 |
71 HidConnectFunction(); | 71 HidConnectFunction(); |
72 | 72 |
73 protected: | 73 protected: |
74 virtual bool Prepare() OVERRIDE; | 74 virtual bool Prepare() OVERRIDE; |
75 virtual void AsyncWorkStart() OVERRIDE; | 75 virtual void AsyncWorkStart() OVERRIDE; |
76 | 76 |
77 private: | 77 private: |
78 virtual ~HidConnectFunction(); | 78 virtual ~HidConnectFunction(); |
79 | 79 |
80 scoped_ptr<base::ListValue> result_; | 80 scoped_ptr<base::ListValue> result_; |
81 scoped_ptr<extensions::api::hid::Connect::Params> parameters_; | 81 scoped_ptr<core_api::hid::Connect::Params> parameters_; |
82 | 82 |
83 DISALLOW_COPY_AND_ASSIGN(HidConnectFunction); | 83 DISALLOW_COPY_AND_ASSIGN(HidConnectFunction); |
84 }; | 84 }; |
85 | 85 |
86 class HidDisconnectFunction : public HidAsyncApiFunction { | 86 class HidDisconnectFunction : public HidAsyncApiFunction { |
87 public: | 87 public: |
88 DECLARE_EXTENSION_FUNCTION("hid.disconnect", HID_DISCONNECT); | 88 DECLARE_EXTENSION_FUNCTION("hid.disconnect", HID_DISCONNECT); |
89 | 89 |
90 HidDisconnectFunction(); | 90 HidDisconnectFunction(); |
91 | 91 |
92 protected: | 92 protected: |
93 virtual bool Prepare() OVERRIDE; | 93 virtual bool Prepare() OVERRIDE; |
94 virtual void AsyncWorkStart() OVERRIDE; | 94 virtual void AsyncWorkStart() OVERRIDE; |
95 | 95 |
96 private: | 96 private: |
97 virtual ~HidDisconnectFunction(); | 97 virtual ~HidDisconnectFunction(); |
98 | 98 |
99 scoped_ptr<base::ListValue> result_; | 99 scoped_ptr<base::ListValue> result_; |
100 scoped_ptr<extensions::api::hid::Disconnect::Params> parameters_; | 100 scoped_ptr<core_api::hid::Disconnect::Params> parameters_; |
101 | 101 |
102 DISALLOW_COPY_AND_ASSIGN(HidDisconnectFunction); | 102 DISALLOW_COPY_AND_ASSIGN(HidDisconnectFunction); |
103 }; | 103 }; |
104 | 104 |
105 class HidReceiveFunction : public HidAsyncApiFunction { | 105 class HidReceiveFunction : public HidAsyncApiFunction { |
106 public: | 106 public: |
107 DECLARE_EXTENSION_FUNCTION("hid.receive", HID_RECEIVE); | 107 DECLARE_EXTENSION_FUNCTION("hid.receive", HID_RECEIVE); |
108 | 108 |
109 HidReceiveFunction(); | 109 HidReceiveFunction(); |
110 | 110 |
111 protected: | 111 protected: |
112 virtual bool Prepare() OVERRIDE; | 112 virtual bool Prepare() OVERRIDE; |
113 virtual void AsyncWorkStart() OVERRIDE; | 113 virtual void AsyncWorkStart() OVERRIDE; |
114 | 114 |
115 private: | 115 private: |
116 virtual ~HidReceiveFunction(); | 116 virtual ~HidReceiveFunction(); |
117 | 117 |
118 void OnFinished(bool success, size_t bytes); | 118 void OnFinished(bool success, size_t bytes); |
119 | 119 |
120 scoped_refptr<net::IOBufferWithSize> buffer_; | 120 scoped_refptr<net::IOBufferWithSize> buffer_; |
121 scoped_ptr<base::ListValue> result_; | 121 scoped_ptr<base::ListValue> result_; |
122 scoped_ptr<extensions::api::hid::Receive::Params> parameters_; | 122 scoped_ptr<core_api::hid::Receive::Params> parameters_; |
123 | 123 |
124 DISALLOW_COPY_AND_ASSIGN(HidReceiveFunction); | 124 DISALLOW_COPY_AND_ASSIGN(HidReceiveFunction); |
125 }; | 125 }; |
126 | 126 |
127 class HidSendFunction : public HidAsyncApiFunction { | 127 class HidSendFunction : public HidAsyncApiFunction { |
128 public: | 128 public: |
129 DECLARE_EXTENSION_FUNCTION("hid.send", HID_SEND); | 129 DECLARE_EXTENSION_FUNCTION("hid.send", HID_SEND); |
130 | 130 |
131 HidSendFunction(); | 131 HidSendFunction(); |
132 | 132 |
133 protected: | 133 protected: |
134 virtual bool Prepare() OVERRIDE; | 134 virtual bool Prepare() OVERRIDE; |
135 virtual void AsyncWorkStart() OVERRIDE; | 135 virtual void AsyncWorkStart() OVERRIDE; |
136 | 136 |
137 private: | 137 private: |
138 virtual ~HidSendFunction(); | 138 virtual ~HidSendFunction(); |
139 | 139 |
140 void OnFinished(bool success, size_t bytes); | 140 void OnFinished(bool success, size_t bytes); |
141 | 141 |
142 scoped_ptr<base::ListValue> result_; | 142 scoped_ptr<base::ListValue> result_; |
143 scoped_ptr<extensions::api::hid::Send::Params> parameters_; | 143 scoped_ptr<core_api::hid::Send::Params> parameters_; |
144 | 144 |
145 DISALLOW_COPY_AND_ASSIGN(HidSendFunction); | 145 DISALLOW_COPY_AND_ASSIGN(HidSendFunction); |
146 }; | 146 }; |
147 | 147 |
148 class HidReceiveFeatureReportFunction : public HidAsyncApiFunction { | 148 class HidReceiveFeatureReportFunction : public HidAsyncApiFunction { |
149 public: | 149 public: |
150 DECLARE_EXTENSION_FUNCTION("hid.receiveFeatureReport", | 150 DECLARE_EXTENSION_FUNCTION("hid.receiveFeatureReport", |
151 HID_RECEIVEFEATUREREPORT); | 151 HID_RECEIVEFEATUREREPORT); |
152 | 152 |
153 HidReceiveFeatureReportFunction(); | 153 HidReceiveFeatureReportFunction(); |
154 | 154 |
155 protected: | 155 protected: |
156 virtual bool Prepare() OVERRIDE; | 156 virtual bool Prepare() OVERRIDE; |
157 virtual void AsyncWorkStart() OVERRIDE; | 157 virtual void AsyncWorkStart() OVERRIDE; |
158 | 158 |
159 private: | 159 private: |
160 virtual ~HidReceiveFeatureReportFunction(); | 160 virtual ~HidReceiveFeatureReportFunction(); |
161 | 161 |
162 void OnFinished(bool success, size_t bytes); | 162 void OnFinished(bool success, size_t bytes); |
163 | 163 |
164 scoped_refptr<net::IOBufferWithSize> buffer_; | 164 scoped_refptr<net::IOBufferWithSize> buffer_; |
165 scoped_ptr<base::ListValue> result_; | 165 scoped_ptr<base::ListValue> result_; |
166 scoped_ptr<extensions::api::hid::ReceiveFeatureReport::Params> parameters_; | 166 scoped_ptr<core_api::hid::ReceiveFeatureReport::Params> parameters_; |
167 | 167 |
168 DISALLOW_COPY_AND_ASSIGN(HidReceiveFeatureReportFunction); | 168 DISALLOW_COPY_AND_ASSIGN(HidReceiveFeatureReportFunction); |
169 }; | 169 }; |
170 | 170 |
171 class HidSendFeatureReportFunction : public HidAsyncApiFunction { | 171 class HidSendFeatureReportFunction : public HidAsyncApiFunction { |
172 public: | 172 public: |
173 DECLARE_EXTENSION_FUNCTION("hid.sendFeatureReport", HID_SENDFEATUREREPORT); | 173 DECLARE_EXTENSION_FUNCTION("hid.sendFeatureReport", HID_SENDFEATUREREPORT); |
174 | 174 |
175 HidSendFeatureReportFunction(); | 175 HidSendFeatureReportFunction(); |
176 | 176 |
177 protected: | 177 protected: |
178 virtual bool Prepare() OVERRIDE; | 178 virtual bool Prepare() OVERRIDE; |
179 virtual void AsyncWorkStart() OVERRIDE; | 179 virtual void AsyncWorkStart() OVERRIDE; |
180 | 180 |
181 private: | 181 private: |
182 virtual ~HidSendFeatureReportFunction(); | 182 virtual ~HidSendFeatureReportFunction(); |
183 | 183 |
184 void OnFinished(bool success, size_t bytes); | 184 void OnFinished(bool success, size_t bytes); |
185 | 185 |
186 scoped_ptr<base::ListValue> result_; | 186 scoped_ptr<base::ListValue> result_; |
187 scoped_ptr<extensions::api::hid::SendFeatureReport::Params> parameters_; | 187 scoped_ptr<core_api::hid::SendFeatureReport::Params> parameters_; |
188 | 188 |
189 DISALLOW_COPY_AND_ASSIGN(HidSendFeatureReportFunction); | 189 DISALLOW_COPY_AND_ASSIGN(HidSendFeatureReportFunction); |
190 }; | 190 }; |
191 | 191 |
192 } // namespace extensions | 192 } // namespace extensions |
193 | 193 |
194 #endif // CHROME_BROWSER_EXTENSIONS_API_HID_HID_API_H_ | 194 #endif // EXTENSIONS_BROWSER_API_HID_HID_API_H_ |
OLD | NEW |