Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "u2f_hid_device.h" | 5 #include "u2f_hid_device.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
| 11 #include "crypto/random.h" | 11 #include "crypto/random.h" |
| 12 #include "device/base/device_client.h" | 12 #include "device/base/device_client.h" |
| 13 #include "device/hid/hid_connection.h" | 13 #include "device/hid/hid_connection.h" |
| 14 #include "u2f_apdu_command.h" | 14 #include "u2f_apdu_command.h" |
| 15 #include "u2f_message.h" | 15 #include "u2f_message.h" |
| 16 | 16 |
| 17 namespace device { | 17 namespace device { |
| 18 | 18 |
| 19 namespace switches { | 19 namespace switches { |
| 20 static constexpr char kEnableU2fHidTest[] = "enable-u2f-hid-tests"; | 20 static constexpr char kEnableU2fHidTest[] = "enable-u2f-hid-tests"; |
| 21 } // namespace switches | 21 } // namespace switches |
| 22 | 22 |
| 23 U2fHidDevice::U2fHidDevice(scoped_refptr<HidDeviceInfo> device_info) | 23 U2fHidDevice::U2fHidDevice(scoped_refptr<HidDeviceInfo> device_info) |
| 24 : U2fDevice(), | 24 : U2fDevice(), |
| 25 state_(State::INIT), | 25 state_(State::INIT), |
| 26 device_info_(device_info), | 26 device_info_(device_info), |
| 27 weak_factory_(this) { | 27 weak_factory_(this) { |
|
Reilly Grant (use Gerrit)
2017/04/24 23:08:18
U2fHidDevice should share its parent class's WeakP
| |
| 28 channel_id_ = kBroadcastChannel; | |
| 29 } | 28 } |
| 30 | 29 |
| 31 U2fHidDevice::~U2fHidDevice() { | 30 U2fHidDevice::~U2fHidDevice() { |
| 32 // Cleanup connection | 31 // Cleanup connection |
| 33 if (connection_ && !connection_->closed()) | 32 if (connection_ && !connection_->closed()) |
| 34 connection_->Close(); | 33 connection_->Close(); |
| 35 } | 34 } |
| 36 | 35 |
| 37 void U2fHidDevice::DeviceTransact(std::unique_ptr<U2fApduCommand> command, | 36 void U2fHidDevice::DeviceTransact(std::unique_ptr<U2fApduCommand> command, |
| 38 const DeviceCallback& callback) { | 37 const DeviceCallback& callback) { |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 337 return id.str(); | 336 return id.str(); |
| 338 } | 337 } |
| 339 | 338 |
| 340 // static | 339 // static |
| 341 bool U2fHidDevice::IsTestEnabled() { | 340 bool U2fHidDevice::IsTestEnabled() { |
| 342 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 341 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 343 return command_line->HasSwitch(switches::kEnableU2fHidTest); | 342 return command_line->HasSwitch(switches::kEnableU2fHidTest); |
| 344 } | 343 } |
| 345 | 344 |
| 346 } // namespace device | 345 } // namespace device |
| OLD | NEW |