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/unlock_manager.h" | 5 #include "components/proximity_auth/unlock_manager.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
11 #include "base/threading/thread_task_runner_handle.h" | 11 #include "base/threading/thread_task_runner_handle.h" |
12 #include "base/time/default_tick_clock.h" | 12 #include "base/time/default_tick_clock.h" |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 15 #include "components/cryptauth/remote_device.h" |
15 #include "components/proximity_auth/logging/logging.h" | 16 #include "components/proximity_auth/logging/logging.h" |
16 #include "components/proximity_auth/messenger.h" | 17 #include "components/proximity_auth/messenger.h" |
17 #include "components/proximity_auth/metrics.h" | 18 #include "components/proximity_auth/metrics.h" |
18 #include "components/proximity_auth/proximity_auth_client.h" | 19 #include "components/proximity_auth/proximity_auth_client.h" |
19 #include "components/proximity_auth/proximity_monitor_impl.h" | 20 #include "components/proximity_auth/proximity_monitor_impl.h" |
20 #include "components/proximity_auth/remote_device.h" | |
21 #include "components/proximity_auth/secure_context.h" | 21 #include "components/proximity_auth/secure_context.h" |
22 #include "device/bluetooth/bluetooth_adapter_factory.h" | 22 #include "device/bluetooth/bluetooth_adapter_factory.h" |
23 | 23 |
24 #if defined(OS_CHROMEOS) | 24 #if defined(OS_CHROMEOS) |
25 #include "chromeos/dbus/dbus_thread_manager.h" | 25 #include "chromeos/dbus/dbus_thread_manager.h" |
26 | 26 |
27 using chromeos::DBusThreadManager; | 27 using chromeos::DBusThreadManager; |
28 #endif // defined(OS_CHROMEOS) | 28 #endif // defined(OS_CHROMEOS) |
29 | 29 |
30 namespace proximity_auth { | 30 namespace proximity_auth { |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 GetMessenger()->RequestUnlock(); | 313 GetMessenger()->RequestUnlock(); |
314 } else { | 314 } else { |
315 PA_LOG(INFO) << "[Unlock] Protocol v3.1 not supported, skipping " | 315 PA_LOG(INFO) << "[Unlock] Protocol v3.1 not supported, skipping " |
316 << "request_unlock."; | 316 << "request_unlock."; |
317 GetMessenger()->DispatchUnlockEvent(); | 317 GetMessenger()->DispatchUnlockEvent(); |
318 } | 318 } |
319 } | 319 } |
320 } | 320 } |
321 | 321 |
322 std::unique_ptr<ProximityMonitor> UnlockManager::CreateProximityMonitor( | 322 std::unique_ptr<ProximityMonitor> UnlockManager::CreateProximityMonitor( |
323 const RemoteDevice& remote_device) { | 323 const cryptauth::RemoteDevice& remote_device) { |
324 return base::MakeUnique<ProximityMonitorImpl>( | 324 return base::MakeUnique<ProximityMonitorImpl>( |
325 remote_device, base::WrapUnique(new base::DefaultTickClock())); | 325 remote_device, base::WrapUnique(new base::DefaultTickClock())); |
326 } | 326 } |
327 | 327 |
328 void UnlockManager::SendSignInChallenge() { | 328 void UnlockManager::SendSignInChallenge() { |
329 if (!life_cycle_ || !GetMessenger() || !GetMessenger()->GetSecureContext()) { | 329 if (!life_cycle_ || !GetMessenger() || !GetMessenger()->GetSecureContext()) { |
330 PA_LOG(ERROR) << "Not ready to send sign-in challenge"; | 330 PA_LOG(ERROR) << "Not ready to send sign-in challenge"; |
331 return; | 331 return; |
332 } | 332 } |
333 | 333 |
334 RemoteDevice remote_device = life_cycle_->GetRemoteDevice(); | 334 cryptauth::RemoteDevice remote_device = life_cycle_->GetRemoteDevice(); |
335 proximity_auth_client_->GetChallengeForUserAndDevice( | 335 proximity_auth_client_->GetChallengeForUserAndDevice( |
336 remote_device.user_id, remote_device.public_key, | 336 remote_device.user_id, remote_device.public_key, |
337 GetMessenger()->GetSecureContext()->GetChannelBindingData(), | 337 GetMessenger()->GetSecureContext()->GetChannelBindingData(), |
338 base::Bind(&UnlockManager::OnGotSignInChallenge, | 338 base::Bind(&UnlockManager::OnGotSignInChallenge, |
339 weak_ptr_factory_.GetWeakPtr())); | 339 weak_ptr_factory_.GetWeakPtr())); |
340 } | 340 } |
341 | 341 |
342 void UnlockManager::OnGotSignInChallenge(const std::string& challenge) { | 342 void UnlockManager::OnGotSignInChallenge(const std::string& challenge) { |
343 PA_LOG(INFO) << "Got sign-in challenge, sending for decryption..."; | 343 PA_LOG(INFO) << "Got sign-in challenge, sending for decryption..."; |
344 GetMessenger()->RequestDecryption(challenge); | 344 GetMessenger()->RequestDecryption(challenge); |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 | 494 |
495 Messenger* UnlockManager::GetMessenger() { | 495 Messenger* UnlockManager::GetMessenger() { |
496 // TODO(tengs): We should use a weak pointer to hold the Messenger instance | 496 // TODO(tengs): We should use a weak pointer to hold the Messenger instance |
497 // instead. | 497 // instead. |
498 if (!life_cycle_) | 498 if (!life_cycle_) |
499 return nullptr; | 499 return nullptr; |
500 return life_cycle_->GetMessenger(); | 500 return life_cycle_->GetMessenger(); |
501 } | 501 } |
502 | 502 |
503 } // namespace proximity_auth | 503 } // namespace proximity_auth |
OLD | NEW |