OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/proximity_auth/remote_device_life_cycle_impl.h" | 5 #include "components/proximity_auth/remote_device_life_cycle_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 } | 83 } |
84 | 84 |
85 void RemoteDeviceLifeCycleImpl::RemoveObserver(Observer* observer) { | 85 void RemoteDeviceLifeCycleImpl::RemoveObserver(Observer* observer) { |
86 observers_.RemoveObserver(observer); | 86 observers_.RemoveObserver(observer); |
87 } | 87 } |
88 | 88 |
89 std::unique_ptr<cryptauth::ConnectionFinder> | 89 std::unique_ptr<cryptauth::ConnectionFinder> |
90 RemoteDeviceLifeCycleImpl::CreateConnectionFinder() { | 90 RemoteDeviceLifeCycleImpl::CreateConnectionFinder() { |
91 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 91 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
92 proximity_auth::switches::kEnableBluetoothLowEnergyDiscovery)) { | 92 proximity_auth::switches::kEnableBluetoothLowEnergyDiscovery)) { |
| 93 cryptauth::RemoteBeaconSeedFetcher fetcher( |
| 94 proximity_auth_client_->GetCryptAuthDeviceManager()); |
| 95 std::vector<cryptauth::BeaconSeed> beacon_seeds; |
| 96 if (!fetcher.FetchSeedsForDevice(remote_device_, &beacon_seeds)) { |
| 97 PA_LOG(ERROR) << "Unable to fetch BeaconSeeds for " |
| 98 << remote_device_.name; |
| 99 return nullptr; |
| 100 } |
| 101 |
93 return base::MakeUnique<BluetoothLowEnergyConnectionFinder>( | 102 return base::MakeUnique<BluetoothLowEnergyConnectionFinder>( |
94 remote_device_, bluetooth_throttler_); | 103 remote_device_, beacon_seeds, bluetooth_throttler_); |
95 } else { | 104 } else { |
96 return base::MakeUnique<BluetoothConnectionFinder>( | 105 return base::MakeUnique<BluetoothConnectionFinder>( |
97 remote_device_, device::BluetoothUUID(kClassicBluetoothServiceUUID), | 106 remote_device_, device::BluetoothUUID(kClassicBluetoothServiceUUID), |
98 base::TimeDelta::FromSeconds(3)); | 107 base::TimeDelta::FromSeconds(3)); |
99 } | 108 } |
100 } | 109 } |
101 | 110 |
102 std::unique_ptr<cryptauth::Authenticator> | 111 std::unique_ptr<cryptauth::Authenticator> |
103 RemoteDeviceLifeCycleImpl::CreateAuthenticator() { | 112 RemoteDeviceLifeCycleImpl::CreateAuthenticator() { |
104 return base::MakeUnique<cryptauth::DeviceToDeviceAuthenticator>( | 113 return base::MakeUnique<cryptauth::DeviceToDeviceAuthenticator>( |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 TransitionToState(RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED); | 187 TransitionToState(RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED); |
179 } | 188 } |
180 | 189 |
181 void RemoteDeviceLifeCycleImpl::OnDisconnected() { | 190 void RemoteDeviceLifeCycleImpl::OnDisconnected() { |
182 DCHECK(state_ == RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED); | 191 DCHECK(state_ == RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED); |
183 messenger_.reset(); | 192 messenger_.reset(); |
184 FindConnection(); | 193 FindConnection(); |
185 } | 194 } |
186 | 195 |
187 } // namespace proximity_auth | 196 } // namespace proximity_auth |
OLD | NEW |