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/hid/hid_api.h" | 5 #include "extensions/browser/api/hid/hid_api.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "device/hid/hid_connection.h" | 10 #include "device/hid/hid_connection.h" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 APIPermission::kUsbDevice, ¶m)) { | 124 APIPermission::kUsbDevice, ¶m)) { |
125 LOG(WARNING) << "Insufficient permissions to access device."; | 125 LOG(WARNING) << "Insufficient permissions to access device."; |
126 CompleteWithError(kErrorPermissionDenied); | 126 CompleteWithError(kErrorPermissionDenied); |
127 return; | 127 return; |
128 } | 128 } |
129 | 129 |
130 HidService* hid_service = ExtensionsAPIClient::Get()->GetHidService(); | 130 HidService* hid_service = ExtensionsAPIClient::Get()->GetHidService(); |
131 DCHECK(hid_service); | 131 DCHECK(hid_service); |
132 scoped_refptr<HidConnection> connection = | 132 scoped_refptr<HidConnection> connection = |
133 hid_service->Connect(device_info.device_id); | 133 hid_service->Connect(device_info.device_id); |
134 if (!connection) { | 134 if (!connection.get()) { |
135 CompleteWithError(kErrorFailedToOpenDevice); | 135 CompleteWithError(kErrorFailedToOpenDevice); |
136 return; | 136 return; |
137 } | 137 } |
138 int connection_id = connection_manager_->Add( | 138 int connection_id = connection_manager_->Add( |
139 new HidConnectionResource(extension_->id(), connection)); | 139 new HidConnectionResource(extension_->id(), connection)); |
140 SetResult(PopulateHidConnection(connection_id, connection)); | 140 SetResult(PopulateHidConnection(connection_id, connection)); |
141 AsyncWorkCompleted(); | 141 AsyncWorkCompleted(); |
142 } | 142 } |
143 | 143 |
144 HidDisconnectFunction::HidDisconnectFunction() {} | 144 HidDisconnectFunction::HidDisconnectFunction() {} |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 | 319 |
320 void HidSendFeatureReportFunction::OnFinished(bool success, size_t bytes) { | 320 void HidSendFeatureReportFunction::OnFinished(bool success, size_t bytes) { |
321 if (!success) { | 321 if (!success) { |
322 CompleteWithError(kErrorTransfer); | 322 CompleteWithError(kErrorTransfer); |
323 return; | 323 return; |
324 } | 324 } |
325 AsyncWorkCompleted(); | 325 AsyncWorkCompleted(); |
326 } | 326 } |
327 | 327 |
328 } // namespace extensions | 328 } // namespace extensions |
OLD | NEW |