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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 if (GetMessenger()->SupportsSignIn()) { | 322 if (GetMessenger()->SupportsSignIn()) { |
317 GetMessenger()->RequestUnlock(); | 323 GetMessenger()->RequestUnlock(); |
318 } else { | 324 } else { |
319 PA_LOG(INFO) << "Protocol v3.1 not supported, skipping request_unlock."; | 325 PA_LOG(INFO) << "Protocol v3.1 not supported, skipping request_unlock."; |
320 GetMessenger()->DispatchUnlockEvent(); | 326 GetMessenger()->DispatchUnlockEvent(); |
321 } | 327 } |
322 } | 328 } |
323 } | 329 } |
324 | 330 |
325 std::unique_ptr<ProximityMonitor> UnlockManagerImpl::CreateProximityMonitor( | 331 std::unique_ptr<ProximityMonitor> UnlockManagerImpl::CreateProximityMonitor( |
326 cryptauth::Connection* connection) { | 332 cryptauth::Connection* connection, |
| 333 ProximityAuthPrefManager* pref_manager) { |
327 return base::MakeUnique<ProximityMonitorImpl>( | 334 return base::MakeUnique<ProximityMonitorImpl>( |
328 connection, base::WrapUnique(new base::DefaultTickClock())); | 335 connection, base::WrapUnique(new base::DefaultTickClock()), pref_manager); |
329 } | 336 } |
330 | 337 |
331 void UnlockManagerImpl::SendSignInChallenge() { | 338 void UnlockManagerImpl::SendSignInChallenge() { |
332 if (!life_cycle_ || !GetMessenger() || !GetMessenger()->GetSecureContext()) { | 339 if (!life_cycle_ || !GetMessenger() || !GetMessenger()->GetSecureContext()) { |
333 PA_LOG(ERROR) << "Not ready to send sign-in challenge"; | 340 PA_LOG(ERROR) << "Not ready to send sign-in challenge"; |
334 return; | 341 return; |
335 } | 342 } |
336 | 343 |
337 cryptauth::RemoteDevice remote_device = life_cycle_->GetRemoteDevice(); | 344 cryptauth::RemoteDevice remote_device = life_cycle_->GetRemoteDevice(); |
338 proximity_auth_client_->GetChallengeForUserAndDevice( | 345 proximity_auth_client_->GetChallengeForUserAndDevice( |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 | 505 |
499 Messenger* UnlockManagerImpl::GetMessenger() { | 506 Messenger* UnlockManagerImpl::GetMessenger() { |
500 // TODO(tengs): We should use a weak pointer to hold the Messenger instance | 507 // TODO(tengs): We should use a weak pointer to hold the Messenger instance |
501 // instead. | 508 // instead. |
502 if (!life_cycle_) | 509 if (!life_cycle_) |
503 return nullptr; | 510 return nullptr; |
504 return life_cycle_->GetMessenger(); | 511 return life_cycle_->GetMessenger(); |
505 } | 512 } |
506 | 513 |
507 } // namespace proximity_auth | 514 } // namespace proximity_auth |
OLD | NEW |