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

Side by Side Diff: extensions/browser/api/usb/usb_api.cc

Issue 2137013005: [Extensions] Code Cleanup - Remove redundant smart-ptr get()s (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 #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
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, &param)) { 510 APIPermission::kUsbDevice, &param)) {
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
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
OLDNEW
« no previous file with comments | « extensions/browser/api/sockets_udp/sockets_udp_api.cc ('k') | extensions/browser/api/usb/usb_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698