OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/extensions/api/usb/usb_api.h" | 5 #include "chrome/browser/extensions/api/usb/usb_api.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 } | 318 } |
319 (*i)->RequestUsbAcess(interface_id, base::Bind(RequestUsbDevicesAccessHelper, | 319 (*i)->RequestUsbAcess(interface_id, base::Bind(RequestUsbDevicesAccessHelper, |
320 base::Passed(devices.Pass()), | 320 base::Passed(devices.Pass()), |
321 i, interface_id, callback)); | 321 i, interface_id, callback)); |
322 } | 322 } |
323 | 323 |
324 void RequestUsbDevicesAccess( | 324 void RequestUsbDevicesAccess( |
325 ScopedDeviceVector devices, | 325 ScopedDeviceVector devices, |
326 int interface_id, | 326 int interface_id, |
327 const base::Callback<void(ScopedDeviceVector result)>& callback) { | 327 const base::Callback<void(ScopedDeviceVector result)>& callback) { |
| 328 if (devices->empty()) { |
| 329 callback.Run(devices.Pass()); |
| 330 return; |
| 331 } |
328 (*devices->begin())->RequestUsbAcess( | 332 (*devices->begin())->RequestUsbAcess( |
329 interface_id, | 333 interface_id, |
330 base::Bind(RequestUsbDevicesAccessHelper, base::Passed(devices.Pass()), | 334 base::Bind(RequestUsbDevicesAccessHelper, base::Passed(devices.Pass()), |
331 devices->begin(), interface_id, callback)); | 335 devices->begin(), interface_id, callback)); |
332 } | 336 } |
333 #endif // OS_CHROMEOS | 337 #endif // OS_CHROMEOS |
334 | 338 |
335 base::DictionaryValue* CreateTransferInfo( | 339 base::DictionaryValue* CreateTransferInfo( |
336 UsbTransferStatus status, | 340 UsbTransferStatus status, |
337 scoped_refptr<net::IOBuffer> data, | 341 scoped_refptr<net::IOBuffer> data, |
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1157 SetResult(new base::FundamentalValue(false)); | 1161 SetResult(new base::FundamentalValue(false)); |
1158 CompleteWithError(kErrorResetDevice); | 1162 CompleteWithError(kErrorResetDevice); |
1159 return; | 1163 return; |
1160 } | 1164 } |
1161 | 1165 |
1162 SetResult(new base::FundamentalValue(true)); | 1166 SetResult(new base::FundamentalValue(true)); |
1163 AsyncWorkCompleted(); | 1167 AsyncWorkCompleted(); |
1164 } | 1168 } |
1165 | 1169 |
1166 } // namespace extensions | 1170 } // namespace extensions |
OLD | NEW |