OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/proximity_auth_system.h" | 5 #include "components/proximity_auth/proximity_auth_system.h" |
6 | 6 |
7 #include "base/threading/thread_task_runner_handle.h" | 7 #include "base/threading/thread_task_runner_handle.h" |
8 #include "base/time/default_clock.h" | 8 #include "base/time/default_clock.h" |
9 #include "components/proximity_auth/logging/logging.h" | 9 #include "components/proximity_auth/logging/logging.h" |
10 #include "components/proximity_auth/proximity_auth_client.h" | 10 #include "components/proximity_auth/proximity_auth_client.h" |
11 #include "components/proximity_auth/proximity_auth_pref_manager.h" | 11 #include "components/proximity_auth/proximity_auth_pref_manager.h" |
12 #include "components/proximity_auth/remote_device_life_cycle_impl.h" | 12 #include "components/proximity_auth/remote_device_life_cycle_impl.h" |
13 #include "components/proximity_auth/unlock_manager_impl.h" | 13 #include "components/proximity_auth/unlock_manager_impl.h" |
14 | 14 |
15 namespace proximity_auth { | 15 namespace proximity_auth { |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 // The maximum number of hours permitted before the user is forced is use their | 19 // The maximum number of hours permitted before the user is forced is use their |
20 // password to authenticate. | 20 // password to authenticate. |
21 const int64_t kPasswordReauthPeriodHours = 20; | 21 const int64_t kPasswordReauthPeriodHours = 20; |
22 | 22 |
23 } // namespace | 23 } // namespace |
24 | 24 |
25 ProximityAuthSystem::ProximityAuthSystem( | 25 ProximityAuthSystem::ProximityAuthSystem( |
26 ScreenlockType screenlock_type, | 26 ScreenlockType screenlock_type, |
27 ProximityAuthClient* proximity_auth_client) | 27 ProximityAuthClient* proximity_auth_client) |
28 : screenlock_type_(screenlock_type), | 28 : screenlock_type_(screenlock_type), |
29 proximity_auth_client_(proximity_auth_client), | 29 proximity_auth_client_(proximity_auth_client), |
30 unlock_manager_( | |
31 new UnlockManagerImpl(screenlock_type, proximity_auth_client)), | |
32 clock_(new base::DefaultClock()), | 30 clock_(new base::DefaultClock()), |
33 pref_manager_(new ProximityAuthPrefManager( | 31 pref_manager_(new ProximityAuthPrefManager( |
34 proximity_auth_client->GetPrefService())), | 32 proximity_auth_client->GetPrefService())), |
| 33 unlock_manager_(new UnlockManagerImpl(screenlock_type, |
| 34 proximity_auth_client_, |
| 35 pref_manager_.get())), |
35 suspended_(false), | 36 suspended_(false), |
36 started_(false), | 37 started_(false), |
37 weak_ptr_factory_(this) {} | 38 weak_ptr_factory_(this) {} |
38 | 39 |
39 ProximityAuthSystem::ProximityAuthSystem( | 40 ProximityAuthSystem::ProximityAuthSystem( |
40 ScreenlockType screenlock_type, | 41 ScreenlockType screenlock_type, |
41 ProximityAuthClient* proximity_auth_client, | 42 ProximityAuthClient* proximity_auth_client, |
42 std::unique_ptr<UnlockManager> unlock_manager, | 43 std::unique_ptr<UnlockManager> unlock_manager, |
43 std::unique_ptr<base::Clock> clock, | 44 std::unique_ptr<base::Clock> clock, |
44 std::unique_ptr<ProximityAuthPrefManager> pref_manager) | 45 std::unique_ptr<ProximityAuthPrefManager> pref_manager) |
45 : screenlock_type_(screenlock_type), | 46 : screenlock_type_(screenlock_type), |
46 proximity_auth_client_(proximity_auth_client), | 47 proximity_auth_client_(proximity_auth_client), |
47 unlock_manager_(std::move(unlock_manager)), | |
48 clock_(std::move(clock)), | 48 clock_(std::move(clock)), |
49 pref_manager_(std::move(pref_manager)), | 49 pref_manager_(std::move(pref_manager)), |
| 50 unlock_manager_(std::move(unlock_manager)), |
50 suspended_(false), | 51 suspended_(false), |
51 started_(false), | 52 started_(false), |
52 weak_ptr_factory_(this) {} | 53 weak_ptr_factory_(this) {} |
53 | 54 |
54 ProximityAuthSystem::~ProximityAuthSystem() { | 55 ProximityAuthSystem::~ProximityAuthSystem() { |
55 ScreenlockBridge::Get()->RemoveObserver(this); | 56 ScreenlockBridge::Get()->RemoveObserver(this); |
56 unlock_manager_->SetRemoteDeviceLifeCycle(nullptr); | 57 unlock_manager_->SetRemoteDeviceLifeCycle(nullptr); |
57 } | 58 } |
58 | 59 |
59 void ProximityAuthSystem::Start() { | 60 void ProximityAuthSystem::Start() { |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 PA_LOG(ERROR) << "Invalid last password timestamp: now=" << now_ms | 206 PA_LOG(ERROR) << "Invalid last password timestamp: now=" << now_ms |
206 << ", last_password=" << last_password_ms; | 207 << ", last_password=" << last_password_ms; |
207 return true; | 208 return true; |
208 } | 209 } |
209 | 210 |
210 return base::TimeDelta::FromMilliseconds(now_ms - last_password_ms) > | 211 return base::TimeDelta::FromMilliseconds(now_ms - last_password_ms) > |
211 base::TimeDelta::FromHours(kPasswordReauthPeriodHours); | 212 base::TimeDelta::FromHours(kPasswordReauthPeriodHours); |
212 } | 213 } |
213 | 214 |
214 } // proximity_auth | 215 } // proximity_auth |
OLD | NEW |