| OLD | NEW |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "device/hid/hid_connection.h" | 5 #include "device/hid/hid_connection.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "components/device_event_log/device_event_log.h" | 9 #include "components/device_event_log/device_event_log.h" |
| 10 | 10 |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 } | 163 } |
| 164 if (IsReportIdProtected(report_id)) { | 164 if (IsReportIdProtected(report_id)) { |
| 165 HID_LOG(USER) << "Attempt to set a protected feature report."; | 165 HID_LOG(USER) << "Attempt to set a protected feature report."; |
| 166 callback.Run(false); | 166 callback.Run(false); |
| 167 return; | 167 return; |
| 168 } | 168 } |
| 169 | 169 |
| 170 PlatformSendFeatureReport(buffer, size, callback); | 170 PlatformSendFeatureReport(buffer, size, callback); |
| 171 } | 171 } |
| 172 | 172 |
| 173 bool HidConnection::CompleteRead(scoped_refptr<net::IOBuffer> buffer, | |
| 174 size_t size, | |
| 175 const ReadCallback& callback) { | |
| 176 DCHECK_GE(size, 1u); | |
| 177 uint8_t report_id = buffer->data()[0]; | |
| 178 if (IsReportIdProtected(report_id)) { | |
| 179 HID_LOG(EVENT) << "Filtered a protected input report."; | |
| 180 return false; | |
| 181 } | |
| 182 | |
| 183 callback.Run(true, buffer, size); | |
| 184 return true; | |
| 185 } | |
| 186 | |
| 187 bool HidConnection::IsReportIdProtected(uint8_t report_id) { | 173 bool HidConnection::IsReportIdProtected(uint8_t report_id) { |
| 188 HidCollectionInfo collection_info; | 174 HidCollectionInfo collection_info; |
| 189 if (FindCollectionByReportId(device_info_->collections(), report_id, | 175 if (FindCollectionByReportId(device_info_->collections(), report_id, |
| 190 &collection_info)) { | 176 &collection_info)) { |
| 191 return collection_info.usage.IsProtected(); | 177 return collection_info.usage.IsProtected(); |
| 192 } | 178 } |
| 193 | 179 |
| 194 return has_protected_collection(); | 180 return has_protected_collection(); |
| 195 } | 181 } |
| 196 | 182 |
| 197 PendingHidReport::PendingHidReport() {} | 183 PendingHidReport::PendingHidReport() {} |
| 198 | 184 |
| 199 PendingHidReport::PendingHidReport(const PendingHidReport& other) = default; | 185 PendingHidReport::PendingHidReport(const PendingHidReport& other) = default; |
| 200 | 186 |
| 201 PendingHidReport::~PendingHidReport() {} | 187 PendingHidReport::~PendingHidReport() {} |
| 202 | 188 |
| 203 PendingHidRead::PendingHidRead() {} | 189 PendingHidRead::PendingHidRead() {} |
| 204 | 190 |
| 205 PendingHidRead::PendingHidRead(const PendingHidRead& other) = default; | 191 PendingHidRead::PendingHidRead(const PendingHidRead& other) = default; |
| 206 | 192 |
| 207 PendingHidRead::~PendingHidRead() {} | 193 PendingHidRead::~PendingHidRead() {} |
| 208 | 194 |
| 209 } // namespace device | 195 } // namespace device |
| OLD | NEW |