Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: components/proximity_auth/unlock_manager_impl.cc

Issue 2973243002: Adding pref to store the user-selected proximity threshold. (Closed)
Patch Set: Fixing tests Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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)
86 : screenlock_type_(screenlock_type), 89 : screenlock_type_(screenlock_type),
87 life_cycle_(nullptr), 90 life_cycle_(nullptr),
88 proximity_auth_client_(proximity_auth_client), 91 proximity_auth_client_(proximity_auth_client),
89 is_locked_(false), 92 is_locked_(false),
90 is_attempting_auth_(false), 93 is_attempting_auth_(false),
91 is_waking_up_(false), 94 is_waking_up_(false),
92 screenlock_state_(ScreenlockState::INACTIVE), 95 screenlock_state_(ScreenlockState::INACTIVE),
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 154
152 void UnlockManagerImpl::OnLifeCycleStateChanged() { 155 void UnlockManagerImpl::OnLifeCycleStateChanged() {
153 RemoteDeviceLifeCycle::State state = life_cycle_->GetState(); 156 RemoteDeviceLifeCycle::State state = life_cycle_->GetState();
154 PA_LOG(INFO) << "RemoteDeviceLifeCycle state changed: " 157 PA_LOG(INFO) << "RemoteDeviceLifeCycle state changed: "
155 << static_cast<int>(state); 158 << static_cast<int>(state);
156 159
157 remote_screenlock_state_.reset(); 160 remote_screenlock_state_.reset();
158 if (state == RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED) { 161 if (state == RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED) {
159 DCHECK(life_cycle_->GetConnection()); 162 DCHECK(life_cycle_->GetConnection());
160 DCHECK(GetMessenger()); 163 DCHECK(GetMessenger());
161 proximity_monitor_ = CreateProximityMonitor(life_cycle_->GetConnection()); 164 proximity_monitor_ = CreateProximityMonitor(
165 life_cycle_->GetConnection(), proximity_auth_client_->GetPrefService());
162 GetMessenger()->AddObserver(this); 166 GetMessenger()->AddObserver(this);
163 } 167 }
164 168
165 if (state == RemoteDeviceLifeCycle::State::AUTHENTICATION_FAILED) 169 if (state == RemoteDeviceLifeCycle::State::AUTHENTICATION_FAILED)
166 SetWakingUpState(false); 170 SetWakingUpState(false);
167 171
168 UpdateLockScreen(); 172 UpdateLockScreen();
169 } 173 }
170 174
171 void UnlockManagerImpl::OnUnlockEventSent(bool success) { 175 void UnlockManagerImpl::OnUnlockEventSent(bool success) {
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 if (GetMessenger()->SupportsSignIn()) { 323 if (GetMessenger()->SupportsSignIn()) {
320 GetMessenger()->RequestUnlock(); 324 GetMessenger()->RequestUnlock();
321 } else { 325 } else {
322 PA_LOG(INFO) << "Protocol v3.1 not supported, skipping request_unlock."; 326 PA_LOG(INFO) << "Protocol v3.1 not supported, skipping request_unlock.";
323 GetMessenger()->DispatchUnlockEvent(); 327 GetMessenger()->DispatchUnlockEvent();
324 } 328 }
325 } 329 }
326 } 330 }
327 331
328 std::unique_ptr<ProximityMonitor> UnlockManagerImpl::CreateProximityMonitor( 332 std::unique_ptr<ProximityMonitor> UnlockManagerImpl::CreateProximityMonitor(
329 cryptauth::Connection* connection) { 333 cryptauth::Connection* connection,
334 PrefService* pref_service) {
330 return base::MakeUnique<ProximityMonitorImpl>( 335 return base::MakeUnique<ProximityMonitorImpl>(
331 connection, base::WrapUnique(new base::DefaultTickClock())); 336 connection, base::WrapUnique(new base::DefaultTickClock()),
337 base::MakeUnique<ProximityAuthPrefManager>(pref_service));
332 } 338 }
333 339
334 void UnlockManagerImpl::SendSignInChallenge() { 340 void UnlockManagerImpl::SendSignInChallenge() {
335 if (!life_cycle_ || !GetMessenger() || !GetMessenger()->GetSecureContext()) { 341 if (!life_cycle_ || !GetMessenger() || !GetMessenger()->GetSecureContext()) {
336 PA_LOG(ERROR) << "Not ready to send sign-in challenge"; 342 PA_LOG(ERROR) << "Not ready to send sign-in challenge";
337 return; 343 return;
338 } 344 }
339 345
340 cryptauth::RemoteDevice remote_device = life_cycle_->GetRemoteDevice(); 346 cryptauth::RemoteDevice remote_device = life_cycle_->GetRemoteDevice();
341 proximity_auth_client_->GetChallengeForUserAndDevice( 347 proximity_auth_client_->GetChallengeForUserAndDevice(
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 502
497 Messenger* UnlockManagerImpl::GetMessenger() { 503 Messenger* UnlockManagerImpl::GetMessenger() {
498 // TODO(tengs): We should use a weak pointer to hold the Messenger instance 504 // TODO(tengs): We should use a weak pointer to hold the Messenger instance
499 // instead. 505 // instead.
500 if (!life_cycle_) 506 if (!life_cycle_)
501 return nullptr; 507 return nullptr;
502 return life_cycle_->GetMessenger(); 508 return life_cycle_->GetMessenger();
503 } 509 }
504 510
505 } // namespace proximity_auth 511 } // namespace proximity_auth
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698