| 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_impl.h" | 5 #include "components/proximity_auth/unlock_manager_impl.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" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 | 151 |
| 152 void UnlockManagerImpl::OnLifeCycleStateChanged() { | 152 void UnlockManagerImpl::OnLifeCycleStateChanged() { |
| 153 RemoteDeviceLifeCycle::State state = life_cycle_->GetState(); | 153 RemoteDeviceLifeCycle::State state = life_cycle_->GetState(); |
| 154 PA_LOG(INFO) << "RemoteDeviceLifeCycle state changed: " | 154 PA_LOG(INFO) << "RemoteDeviceLifeCycle state changed: " |
| 155 << static_cast<int>(state); | 155 << static_cast<int>(state); |
| 156 | 156 |
| 157 remote_screenlock_state_.reset(); | 157 remote_screenlock_state_.reset(); |
| 158 if (state == RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED) { | 158 if (state == RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED) { |
| 159 DCHECK(life_cycle_->GetConnection()); | 159 DCHECK(life_cycle_->GetConnection()); |
| 160 DCHECK(GetMessenger()); | 160 DCHECK(GetMessenger()); |
| 161 proximity_monitor_ = CreateProximityMonitor(life_cycle_->GetConnection()); | 161 proximity_monitor_ = CreateProximityMonitor( |
| 162 life_cycle_->GetConnection(), proximity_auth_client_->GetPrefService()); |
| 162 GetMessenger()->AddObserver(this); | 163 GetMessenger()->AddObserver(this); |
| 163 } | 164 } |
| 164 | 165 |
| 165 if (state == RemoteDeviceLifeCycle::State::AUTHENTICATION_FAILED) | 166 if (state == RemoteDeviceLifeCycle::State::AUTHENTICATION_FAILED) |
| 166 SetWakingUpState(false); | 167 SetWakingUpState(false); |
| 167 | 168 |
| 168 UpdateLockScreen(); | 169 UpdateLockScreen(); |
| 169 } | 170 } |
| 170 | 171 |
| 171 void UnlockManagerImpl::OnUnlockEventSent(bool success) { | 172 void UnlockManagerImpl::OnUnlockEventSent(bool success) { |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 if (GetMessenger()->SupportsSignIn()) { | 320 if (GetMessenger()->SupportsSignIn()) { |
| 320 GetMessenger()->RequestUnlock(); | 321 GetMessenger()->RequestUnlock(); |
| 321 } else { | 322 } else { |
| 322 PA_LOG(INFO) << "Protocol v3.1 not supported, skipping request_unlock."; | 323 PA_LOG(INFO) << "Protocol v3.1 not supported, skipping request_unlock."; |
| 323 GetMessenger()->DispatchUnlockEvent(); | 324 GetMessenger()->DispatchUnlockEvent(); |
| 324 } | 325 } |
| 325 } | 326 } |
| 326 } | 327 } |
| 327 | 328 |
| 328 std::unique_ptr<ProximityMonitor> UnlockManagerImpl::CreateProximityMonitor( | 329 std::unique_ptr<ProximityMonitor> UnlockManagerImpl::CreateProximityMonitor( |
| 329 cryptauth::Connection* connection) { | 330 cryptauth::Connection* connection, |
| 331 PrefService* pref_service) { |
| 330 return base::MakeUnique<ProximityMonitorImpl>( | 332 return base::MakeUnique<ProximityMonitorImpl>( |
| 331 connection, base::WrapUnique(new base::DefaultTickClock())); | 333 connection, base::WrapUnique(new base::DefaultTickClock()), pref_service); |
| 332 } | 334 } |
| 333 | 335 |
| 334 void UnlockManagerImpl::SendSignInChallenge() { | 336 void UnlockManagerImpl::SendSignInChallenge() { |
| 335 if (!life_cycle_ || !GetMessenger() || !GetMessenger()->GetSecureContext()) { | 337 if (!life_cycle_ || !GetMessenger() || !GetMessenger()->GetSecureContext()) { |
| 336 PA_LOG(ERROR) << "Not ready to send sign-in challenge"; | 338 PA_LOG(ERROR) << "Not ready to send sign-in challenge"; |
| 337 return; | 339 return; |
| 338 } | 340 } |
| 339 | 341 |
| 340 cryptauth::RemoteDevice remote_device = life_cycle_->GetRemoteDevice(); | 342 cryptauth::RemoteDevice remote_device = life_cycle_->GetRemoteDevice(); |
| 341 proximity_auth_client_->GetChallengeForUserAndDevice( | 343 proximity_auth_client_->GetChallengeForUserAndDevice( |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 | 498 |
| 497 Messenger* UnlockManagerImpl::GetMessenger() { | 499 Messenger* UnlockManagerImpl::GetMessenger() { |
| 498 // TODO(tengs): We should use a weak pointer to hold the Messenger instance | 500 // TODO(tengs): We should use a weak pointer to hold the Messenger instance |
| 499 // instead. | 501 // instead. |
| 500 if (!life_cycle_) | 502 if (!life_cycle_) |
| 501 return nullptr; | 503 return nullptr; |
| 502 return life_cycle_->GetMessenger(); | 504 return life_cycle_->GetMessenger(); |
| 503 } | 505 } |
| 504 | 506 |
| 505 } // namespace proximity_auth | 507 } // namespace proximity_auth |
| OLD | NEW |