| 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 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 <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> |
| 10 #include <string> | 11 #include <string> |
| 11 | 12 |
| 12 #include "base/macros.h" | 13 #include "base/macros.h" |
| 13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_ptr.h" | |
| 15 #include "extensions/browser/api/api_resource_manager.h" | 15 #include "extensions/browser/api/api_resource_manager.h" |
| 16 #include "extensions/browser/api/hid/hid_connection_resource.h" | 16 #include "extensions/browser/api/hid/hid_connection_resource.h" |
| 17 #include "extensions/browser/api/hid/hid_device_manager.h" | 17 #include "extensions/browser/api/hid/hid_device_manager.h" |
| 18 #include "extensions/browser/extension_function.h" | 18 #include "extensions/browser/extension_function.h" |
| 19 #include "extensions/common/api/hid.h" | 19 #include "extensions/common/api/hid.h" |
| 20 | 20 |
| 21 namespace device { | 21 namespace device { |
| 22 class HidConnection; | 22 class HidConnection; |
| 23 class HidDeviceInfo; | 23 class HidDeviceInfo; |
| 24 class HidService; | 24 class HidService; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 37 DECLARE_EXTENSION_FUNCTION("hid.getDevices", HID_GETDEVICES); | 37 DECLARE_EXTENSION_FUNCTION("hid.getDevices", HID_GETDEVICES); |
| 38 | 38 |
| 39 HidGetDevicesFunction(); | 39 HidGetDevicesFunction(); |
| 40 | 40 |
| 41 private: | 41 private: |
| 42 ~HidGetDevicesFunction() override; | 42 ~HidGetDevicesFunction() override; |
| 43 | 43 |
| 44 // ExtensionFunction: | 44 // ExtensionFunction: |
| 45 ResponseAction Run() override; | 45 ResponseAction Run() override; |
| 46 | 46 |
| 47 void OnEnumerationComplete(scoped_ptr<base::ListValue> devices); | 47 void OnEnumerationComplete(std::unique_ptr<base::ListValue> devices); |
| 48 | 48 |
| 49 DISALLOW_COPY_AND_ASSIGN(HidGetDevicesFunction); | 49 DISALLOW_COPY_AND_ASSIGN(HidGetDevicesFunction); |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 class HidGetUserSelectedDevicesFunction : public UIThreadExtensionFunction { | 52 class HidGetUserSelectedDevicesFunction : public UIThreadExtensionFunction { |
| 53 public: | 53 public: |
| 54 DECLARE_EXTENSION_FUNCTION("hid.getUserSelectedDevices", | 54 DECLARE_EXTENSION_FUNCTION("hid.getUserSelectedDevices", |
| 55 HID_GETUSERSELECTEDDEVICES) | 55 HID_GETUSERSELECTEDDEVICES) |
| 56 | 56 |
| 57 HidGetUserSelectedDevicesFunction(); | 57 HidGetUserSelectedDevicesFunction(); |
| 58 | 58 |
| 59 private: | 59 private: |
| 60 ~HidGetUserSelectedDevicesFunction() override; | 60 ~HidGetUserSelectedDevicesFunction() override; |
| 61 | 61 |
| 62 // ExtensionFunction: | 62 // ExtensionFunction: |
| 63 ResponseAction Run() override; | 63 ResponseAction Run() override; |
| 64 | 64 |
| 65 void OnDevicesChosen( | 65 void OnDevicesChosen( |
| 66 const std::vector<scoped_refptr<device::HidDeviceInfo>>& devices); | 66 const std::vector<scoped_refptr<device::HidDeviceInfo>>& devices); |
| 67 | 67 |
| 68 HidDeviceManager* device_manager_; | 68 HidDeviceManager* device_manager_; |
| 69 scoped_ptr<DevicePermissionsPrompt> prompt_; | 69 std::unique_ptr<DevicePermissionsPrompt> prompt_; |
| 70 | 70 |
| 71 DISALLOW_COPY_AND_ASSIGN(HidGetUserSelectedDevicesFunction); | 71 DISALLOW_COPY_AND_ASSIGN(HidGetUserSelectedDevicesFunction); |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 class HidConnectFunction : public UIThreadExtensionFunction { | 74 class HidConnectFunction : public UIThreadExtensionFunction { |
| 75 public: | 75 public: |
| 76 DECLARE_EXTENSION_FUNCTION("hid.connect", HID_CONNECT); | 76 DECLARE_EXTENSION_FUNCTION("hid.connect", HID_CONNECT); |
| 77 | 77 |
| 78 HidConnectFunction(); | 78 HidConnectFunction(); |
| 79 | 79 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 ~HidReceiveFunction() override; | 136 ~HidReceiveFunction() override; |
| 137 | 137 |
| 138 // HidConnectionIoFunction: | 138 // HidConnectionIoFunction: |
| 139 bool ValidateParameters() override; | 139 bool ValidateParameters() override; |
| 140 void StartWork(device::HidConnection* connection) override; | 140 void StartWork(device::HidConnection* connection) override; |
| 141 | 141 |
| 142 void OnFinished(bool success, | 142 void OnFinished(bool success, |
| 143 scoped_refptr<net::IOBuffer> buffer, | 143 scoped_refptr<net::IOBuffer> buffer, |
| 144 size_t size); | 144 size_t size); |
| 145 | 145 |
| 146 scoped_ptr<api::hid::Receive::Params> parameters_; | 146 std::unique_ptr<api::hid::Receive::Params> parameters_; |
| 147 | 147 |
| 148 DISALLOW_COPY_AND_ASSIGN(HidReceiveFunction); | 148 DISALLOW_COPY_AND_ASSIGN(HidReceiveFunction); |
| 149 }; | 149 }; |
| 150 | 150 |
| 151 class HidSendFunction : public HidConnectionIoFunction { | 151 class HidSendFunction : public HidConnectionIoFunction { |
| 152 public: | 152 public: |
| 153 DECLARE_EXTENSION_FUNCTION("hid.send", HID_SEND); | 153 DECLARE_EXTENSION_FUNCTION("hid.send", HID_SEND); |
| 154 | 154 |
| 155 HidSendFunction(); | 155 HidSendFunction(); |
| 156 | 156 |
| 157 private: | 157 private: |
| 158 ~HidSendFunction() override; | 158 ~HidSendFunction() override; |
| 159 | 159 |
| 160 // HidConnectionIoFunction: | 160 // HidConnectionIoFunction: |
| 161 bool ValidateParameters() override; | 161 bool ValidateParameters() override; |
| 162 void StartWork(device::HidConnection* connection) override; | 162 void StartWork(device::HidConnection* connection) override; |
| 163 | 163 |
| 164 void OnFinished(bool success); | 164 void OnFinished(bool success); |
| 165 | 165 |
| 166 scoped_ptr<api::hid::Send::Params> parameters_; | 166 std::unique_ptr<api::hid::Send::Params> parameters_; |
| 167 | 167 |
| 168 DISALLOW_COPY_AND_ASSIGN(HidSendFunction); | 168 DISALLOW_COPY_AND_ASSIGN(HidSendFunction); |
| 169 }; | 169 }; |
| 170 | 170 |
| 171 class HidReceiveFeatureReportFunction : public HidConnectionIoFunction { | 171 class HidReceiveFeatureReportFunction : public HidConnectionIoFunction { |
| 172 public: | 172 public: |
| 173 DECLARE_EXTENSION_FUNCTION("hid.receiveFeatureReport", | 173 DECLARE_EXTENSION_FUNCTION("hid.receiveFeatureReport", |
| 174 HID_RECEIVEFEATUREREPORT); | 174 HID_RECEIVEFEATUREREPORT); |
| 175 | 175 |
| 176 HidReceiveFeatureReportFunction(); | 176 HidReceiveFeatureReportFunction(); |
| 177 | 177 |
| 178 private: | 178 private: |
| 179 ~HidReceiveFeatureReportFunction() override; | 179 ~HidReceiveFeatureReportFunction() override; |
| 180 | 180 |
| 181 // HidConnectionIoFunction: | 181 // HidConnectionIoFunction: |
| 182 bool ValidateParameters() override; | 182 bool ValidateParameters() override; |
| 183 void StartWork(device::HidConnection* connection) override; | 183 void StartWork(device::HidConnection* connection) override; |
| 184 | 184 |
| 185 void OnFinished(bool success, | 185 void OnFinished(bool success, |
| 186 scoped_refptr<net::IOBuffer> buffer, | 186 scoped_refptr<net::IOBuffer> buffer, |
| 187 size_t size); | 187 size_t size); |
| 188 | 188 |
| 189 scoped_ptr<api::hid::ReceiveFeatureReport::Params> parameters_; | 189 std::unique_ptr<api::hid::ReceiveFeatureReport::Params> parameters_; |
| 190 | 190 |
| 191 DISALLOW_COPY_AND_ASSIGN(HidReceiveFeatureReportFunction); | 191 DISALLOW_COPY_AND_ASSIGN(HidReceiveFeatureReportFunction); |
| 192 }; | 192 }; |
| 193 | 193 |
| 194 class HidSendFeatureReportFunction : public HidConnectionIoFunction { | 194 class HidSendFeatureReportFunction : public HidConnectionIoFunction { |
| 195 public: | 195 public: |
| 196 DECLARE_EXTENSION_FUNCTION("hid.sendFeatureReport", HID_SENDFEATUREREPORT); | 196 DECLARE_EXTENSION_FUNCTION("hid.sendFeatureReport", HID_SENDFEATUREREPORT); |
| 197 | 197 |
| 198 HidSendFeatureReportFunction(); | 198 HidSendFeatureReportFunction(); |
| 199 | 199 |
| 200 private: | 200 private: |
| 201 ~HidSendFeatureReportFunction() override; | 201 ~HidSendFeatureReportFunction() override; |
| 202 | 202 |
| 203 // HidConnectionIoFunction: | 203 // HidConnectionIoFunction: |
| 204 bool ValidateParameters() override; | 204 bool ValidateParameters() override; |
| 205 void StartWork(device::HidConnection* connection) override; | 205 void StartWork(device::HidConnection* connection) override; |
| 206 | 206 |
| 207 void OnFinished(bool success); | 207 void OnFinished(bool success); |
| 208 | 208 |
| 209 scoped_ptr<api::hid::SendFeatureReport::Params> parameters_; | 209 std::unique_ptr<api::hid::SendFeatureReport::Params> parameters_; |
| 210 | 210 |
| 211 DISALLOW_COPY_AND_ASSIGN(HidSendFeatureReportFunction); | 211 DISALLOW_COPY_AND_ASSIGN(HidSendFeatureReportFunction); |
| 212 }; | 212 }; |
| 213 | 213 |
| 214 } // namespace extensions | 214 } // namespace extensions |
| 215 | 215 |
| 216 #endif // EXTENSIONS_BROWSER_API_HID_HID_API_H_ | 216 #endif // EXTENSIONS_BROWSER_API_HID_HID_API_H_ |
| OLD | NEW |