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 #include "extensions/browser/api/usb/usb_api.h" | 5 #include "extensions/browser/api/usb/usb_api.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <memory> | 8 #include <memory> |
9 #include <numeric> | 9 #include <numeric> |
10 #include <string> | 10 #include <string> |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 } | 496 } |
497 | 497 |
498 ExtensionFunction::ResponseAction UsbFindDevicesFunction::Run() { | 498 ExtensionFunction::ResponseAction UsbFindDevicesFunction::Run() { |
499 std::unique_ptr<extensions::api::usb::FindDevices::Params> parameters = | 499 std::unique_ptr<extensions::api::usb::FindDevices::Params> parameters = |
500 FindDevices::Params::Create(*args_); | 500 FindDevices::Params::Create(*args_); |
501 EXTENSION_FUNCTION_VALIDATE(parameters.get()); | 501 EXTENSION_FUNCTION_VALIDATE(parameters.get()); |
502 | 502 |
503 vendor_id_ = parameters->options.vendor_id; | 503 vendor_id_ = parameters->options.vendor_id; |
504 product_id_ = parameters->options.product_id; | 504 product_id_ = parameters->options.product_id; |
505 int interface_id = parameters->options.interface_id.get() | 505 int interface_id = parameters->options.interface_id.get() |
506 ? *parameters->options.interface_id.get() | 506 ? *parameters->options.interface_id |
507 : UsbDevicePermissionData::ANY_INTERFACE; | 507 : UsbDevicePermissionData::ANY_INTERFACE; |
508 UsbDevicePermission::CheckParam param(vendor_id_, product_id_, interface_id); | 508 UsbDevicePermission::CheckParam param(vendor_id_, product_id_, interface_id); |
509 if (!extension()->permissions_data()->CheckAPIPermissionWithParam( | 509 if (!extension()->permissions_data()->CheckAPIPermissionWithParam( |
510 APIPermission::kUsbDevice, ¶m)) { | 510 APIPermission::kUsbDevice, ¶m)) { |
511 return RespondNow(Error(kErrorPermissionDenied)); | 511 return RespondNow(Error(kErrorPermissionDenied)); |
512 } | 512 } |
513 | 513 |
514 UsbService* service = device::DeviceClient::Get()->GetUsbService(); | 514 UsbService* service = device::DeviceClient::Get()->GetUsbService(); |
515 if (!service) { | 515 if (!service) { |
516 return RespondNow(Error(kErrorInitService)); | 516 return RespondNow(Error(kErrorInitService)); |
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1271 | 1271 |
1272 std::unique_ptr<base::ListValue> error_args(new base::ListValue()); | 1272 std::unique_ptr<base::ListValue> error_args(new base::ListValue()); |
1273 error_args->AppendBoolean(false); | 1273 error_args->AppendBoolean(false); |
1274 // Using ErrorWithArguments is discouraged but required to maintain | 1274 // Using ErrorWithArguments is discouraged but required to maintain |
1275 // compatibility with existing applications. | 1275 // compatibility with existing applications. |
1276 Respond(ErrorWithArguments(std::move(error_args), kErrorResetDevice)); | 1276 Respond(ErrorWithArguments(std::move(error_args), kErrorResetDevice)); |
1277 } | 1277 } |
1278 } | 1278 } |
1279 | 1279 |
1280 } // namespace extensions | 1280 } // namespace extensions |
OLD | NEW |