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 <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 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 bool UsbRequestAccessFunction::Prepare() { | 687 bool UsbRequestAccessFunction::Prepare() { |
688 parameters_ = RequestAccess::Params::Create(*args_); | 688 parameters_ = RequestAccess::Params::Create(*args_); |
689 EXTENSION_FUNCTION_VALIDATE(parameters_.get()); | 689 EXTENSION_FUNCTION_VALIDATE(parameters_.get()); |
690 return true; | 690 return true; |
691 } | 691 } |
692 | 692 |
693 void UsbRequestAccessFunction::AsyncWorkStart() { | 693 void UsbRequestAccessFunction::AsyncWorkStart() { |
694 #if defined(OS_CHROMEOS) | 694 #if defined(OS_CHROMEOS) |
695 scoped_refptr<UsbDevice> device = | 695 scoped_refptr<UsbDevice> device = |
696 GetDeviceOrCompleteWithError(parameters_->device); | 696 GetDeviceOrCompleteWithError(parameters_->device); |
697 if (!device) | 697 if (!device.get()) |
698 return; | 698 return; |
699 | 699 |
700 device->RequestUsbAccess( | 700 device->RequestUsbAccess( |
701 parameters_->interface_id, | 701 parameters_->interface_id, |
702 base::Bind(&UsbRequestAccessFunction::OnCompleted, this)); | 702 base::Bind(&UsbRequestAccessFunction::OnCompleted, this)); |
703 #else | 703 #else |
704 SetResult(new base::FundamentalValue(false)); | 704 SetResult(new base::FundamentalValue(false)); |
705 CompleteWithError(kErrorNotSupported); | 705 CompleteWithError(kErrorNotSupported); |
706 #endif // OS_CHROMEOS | 706 #endif // OS_CHROMEOS |
707 } | 707 } |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1216 SetResult(new base::FundamentalValue(false)); | 1216 SetResult(new base::FundamentalValue(false)); |
1217 CompleteWithError(kErrorResetDevice); | 1217 CompleteWithError(kErrorResetDevice); |
1218 return; | 1218 return; |
1219 } | 1219 } |
1220 | 1220 |
1221 SetResult(new base::FundamentalValue(true)); | 1221 SetResult(new base::FundamentalValue(true)); |
1222 AsyncWorkCompleted(); | 1222 AsyncWorkCompleted(); |
1223 } | 1223 } |
1224 | 1224 |
1225 } // namespace extensions | 1225 } // namespace extensions |
OLD | NEW |