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" |
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/cryptauth/remote_device.h" |
16 #include "components/cryptauth/secure_context.h" | 16 #include "components/cryptauth/secure_context.h" |
17 #include "components/proximity_auth/logging/logging.h" | 17 #include "components/proximity_auth/logging/logging.h" |
18 #include "components/proximity_auth/messenger.h" | 18 #include "components/proximity_auth/messenger.h" |
19 #include "components/proximity_auth/metrics.h" | 19 #include "components/proximity_auth/metrics.h" |
20 #include "components/proximity_auth/proximity_auth_client.h" | 20 #include "components/proximity_auth/proximity_auth_client.h" |
| 21 #include "components/proximity_auth/proximity_auth_pref_manager.h" |
21 #include "components/proximity_auth/proximity_monitor_impl.h" | 22 #include "components/proximity_auth/proximity_monitor_impl.h" |
22 #include "device/bluetooth/bluetooth_adapter_factory.h" | 23 #include "device/bluetooth/bluetooth_adapter_factory.h" |
23 | 24 |
24 #if defined(OS_CHROMEOS) | 25 #if defined(OS_CHROMEOS) |
25 #include "chromeos/dbus/dbus_thread_manager.h" | 26 #include "chromeos/dbus/dbus_thread_manager.h" |
26 | 27 |
27 using chromeos::DBusThreadManager; | 28 using chromeos::DBusThreadManager; |
28 #endif // defined(OS_CHROMEOS) | 29 #endif // defined(OS_CHROMEOS) |
29 | 30 |
30 namespace proximity_auth { | 31 namespace proximity_auth { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 SCREEN_LOCK_ENABLED_TRUST_AGENT_ENABLED; | 74 SCREEN_LOCK_ENABLED_TRUST_AGENT_ENABLED; |
74 } | 75 } |
75 } | 76 } |
76 | 77 |
77 NOTREACHED(); | 78 NOTREACHED(); |
78 return metrics::RemoteSecuritySettingsState::UNKNOWN; | 79 return metrics::RemoteSecuritySettingsState::UNKNOWN; |
79 } | 80 } |
80 | 81 |
81 } // namespace | 82 } // namespace |
82 | 83 |
| 84 class ProximityAuthPrefManager; |
| 85 |
83 UnlockManagerImpl::UnlockManagerImpl( | 86 UnlockManagerImpl::UnlockManagerImpl( |
84 ProximityAuthSystem::ScreenlockType screenlock_type, | 87 ProximityAuthSystem::ScreenlockType screenlock_type, |
85 ProximityAuthClient* proximity_auth_client) | 88 ProximityAuthClient* proximity_auth_client, |
| 89 ProximityAuthPrefManager* pref_manager) |
86 : screenlock_type_(screenlock_type), | 90 : screenlock_type_(screenlock_type), |
87 life_cycle_(nullptr), | 91 life_cycle_(nullptr), |
88 proximity_auth_client_(proximity_auth_client), | 92 proximity_auth_client_(proximity_auth_client), |
| 93 pref_manager_(pref_manager), |
89 is_locked_(false), | 94 is_locked_(false), |
90 is_attempting_auth_(false), | 95 is_attempting_auth_(false), |
91 is_waking_up_(false), | 96 is_waking_up_(false), |
92 screenlock_state_(ScreenlockState::INACTIVE), | 97 screenlock_state_(ScreenlockState::INACTIVE), |
93 clear_waking_up_state_weak_ptr_factory_(this), | 98 clear_waking_up_state_weak_ptr_factory_(this), |
94 reject_auth_attempt_weak_ptr_factory_(this), | 99 reject_auth_attempt_weak_ptr_factory_(this), |
95 weak_ptr_factory_(this) { | 100 weak_ptr_factory_(this) { |
96 ScreenlockBridge* screenlock_bridge = ScreenlockBridge::Get(); | 101 ScreenlockBridge* screenlock_bridge = ScreenlockBridge::Get(); |
97 screenlock_bridge->AddObserver(this); | 102 screenlock_bridge->AddObserver(this); |
98 OnScreenLockedOrUnlocked(screenlock_bridge->IsLocked()); | 103 OnScreenLockedOrUnlocked(screenlock_bridge->IsLocked()); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 | 156 |
152 void UnlockManagerImpl::OnLifeCycleStateChanged() { | 157 void UnlockManagerImpl::OnLifeCycleStateChanged() { |
153 RemoteDeviceLifeCycle::State state = life_cycle_->GetState(); | 158 RemoteDeviceLifeCycle::State state = life_cycle_->GetState(); |
154 PA_LOG(INFO) << "RemoteDeviceLifeCycle state changed: " | 159 PA_LOG(INFO) << "RemoteDeviceLifeCycle state changed: " |
155 << static_cast<int>(state); | 160 << static_cast<int>(state); |
156 | 161 |
157 remote_screenlock_state_.reset(); | 162 remote_screenlock_state_.reset(); |
158 if (state == RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED) { | 163 if (state == RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED) { |
159 DCHECK(life_cycle_->GetConnection()); | 164 DCHECK(life_cycle_->GetConnection()); |
160 DCHECK(GetMessenger()); | 165 DCHECK(GetMessenger()); |
161 proximity_monitor_ = CreateProximityMonitor(life_cycle_->GetConnection()); | 166 proximity_monitor_ = |
| 167 CreateProximityMonitor(life_cycle_->GetConnection(), pref_manager_); |
162 GetMessenger()->AddObserver(this); | 168 GetMessenger()->AddObserver(this); |
163 } | 169 } |
164 | 170 |
165 if (state == RemoteDeviceLifeCycle::State::AUTHENTICATION_FAILED) | 171 if (state == RemoteDeviceLifeCycle::State::AUTHENTICATION_FAILED) |
166 SetWakingUpState(false); | 172 SetWakingUpState(false); |
167 | 173 |
168 UpdateLockScreen(); | 174 UpdateLockScreen(); |
169 } | 175 } |
170 | 176 |
171 void UnlockManagerImpl::OnUnlockEventSent(bool success) { | 177 void UnlockManagerImpl::OnUnlockEventSent(bool success) { |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 if (GetMessenger()->SupportsSignIn()) { | 325 if (GetMessenger()->SupportsSignIn()) { |
320 GetMessenger()->RequestUnlock(); | 326 GetMessenger()->RequestUnlock(); |
321 } else { | 327 } else { |
322 PA_LOG(INFO) << "Protocol v3.1 not supported, skipping request_unlock."; | 328 PA_LOG(INFO) << "Protocol v3.1 not supported, skipping request_unlock."; |
323 GetMessenger()->DispatchUnlockEvent(); | 329 GetMessenger()->DispatchUnlockEvent(); |
324 } | 330 } |
325 } | 331 } |
326 } | 332 } |
327 | 333 |
328 std::unique_ptr<ProximityMonitor> UnlockManagerImpl::CreateProximityMonitor( | 334 std::unique_ptr<ProximityMonitor> UnlockManagerImpl::CreateProximityMonitor( |
329 cryptauth::Connection* connection) { | 335 cryptauth::Connection* connection, |
| 336 ProximityAuthPrefManager* pref_manager) { |
330 return base::MakeUnique<ProximityMonitorImpl>( | 337 return base::MakeUnique<ProximityMonitorImpl>( |
331 connection, base::WrapUnique(new base::DefaultTickClock())); | 338 connection, base::WrapUnique(new base::DefaultTickClock()), pref_manager); |
332 } | 339 } |
333 | 340 |
334 void UnlockManagerImpl::SendSignInChallenge() { | 341 void UnlockManagerImpl::SendSignInChallenge() { |
335 if (!life_cycle_ || !GetMessenger() || !GetMessenger()->GetSecureContext()) { | 342 if (!life_cycle_ || !GetMessenger() || !GetMessenger()->GetSecureContext()) { |
336 PA_LOG(ERROR) << "Not ready to send sign-in challenge"; | 343 PA_LOG(ERROR) << "Not ready to send sign-in challenge"; |
337 return; | 344 return; |
338 } | 345 } |
339 | 346 |
340 cryptauth::RemoteDevice remote_device = life_cycle_->GetRemoteDevice(); | 347 cryptauth::RemoteDevice remote_device = life_cycle_->GetRemoteDevice(); |
341 proximity_auth_client_->GetChallengeForUserAndDevice( | 348 proximity_auth_client_->GetChallengeForUserAndDevice( |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 | 503 |
497 Messenger* UnlockManagerImpl::GetMessenger() { | 504 Messenger* UnlockManagerImpl::GetMessenger() { |
498 // TODO(tengs): We should use a weak pointer to hold the Messenger instance | 505 // TODO(tengs): We should use a weak pointer to hold the Messenger instance |
499 // instead. | 506 // instead. |
500 if (!life_cycle_) | 507 if (!life_cycle_) |
501 return nullptr; | 508 return nullptr; |
502 return life_cycle_->GetMessenger(); | 509 return life_cycle_->GetMessenger(); |
503 } | 510 } |
504 | 511 |
505 } // namespace proximity_auth | 512 } // namespace proximity_auth |
OLD | NEW |