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

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

Issue 2918933002: [EasyUnlock] Make login work if command line flag is enabled. (Closed)
Patch Set: Created 3 years, 6 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
« no previous file with comments | « components/proximity_auth/proximity_auth_system.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 : proximity_auth_client_(proximity_auth_client), 28 : screenlock_type_(screenlock_type),
29 proximity_auth_client_(proximity_auth_client),
29 unlock_manager_( 30 unlock_manager_(
30 new UnlockManagerImpl(screenlock_type, proximity_auth_client)), 31 new UnlockManagerImpl(screenlock_type, proximity_auth_client)),
31 clock_(new base::DefaultClock()), 32 clock_(new base::DefaultClock()),
32 pref_manager_(new ProximityAuthPrefManager( 33 pref_manager_(new ProximityAuthPrefManager(
33 proximity_auth_client->GetPrefService())), 34 proximity_auth_client->GetPrefService())),
34 suspended_(false), 35 suspended_(false),
35 started_(false), 36 started_(false),
36 weak_ptr_factory_(this) {} 37 weak_ptr_factory_(this) {}
37 38
38 ProximityAuthSystem::ProximityAuthSystem( 39 ProximityAuthSystem::ProximityAuthSystem(
39 ScreenlockType screenlock_type, 40 ScreenlockType screenlock_type,
40 ProximityAuthClient* proximity_auth_client, 41 ProximityAuthClient* proximity_auth_client,
41 std::unique_ptr<UnlockManager> unlock_manager, 42 std::unique_ptr<UnlockManager> unlock_manager,
42 std::unique_ptr<base::Clock> clock, 43 std::unique_ptr<base::Clock> clock,
43 std::unique_ptr<ProximityAuthPrefManager> pref_manager) 44 std::unique_ptr<ProximityAuthPrefManager> pref_manager)
44 : proximity_auth_client_(proximity_auth_client), 45 : screenlock_type_(screenlock_type),
46 proximity_auth_client_(proximity_auth_client),
45 unlock_manager_(std::move(unlock_manager)), 47 unlock_manager_(std::move(unlock_manager)),
46 clock_(std::move(clock)), 48 clock_(std::move(clock)),
47 pref_manager_(std::move(pref_manager)), 49 pref_manager_(std::move(pref_manager)),
48 suspended_(false), 50 suspended_(false),
49 started_(false), 51 started_(false),
50 weak_ptr_factory_(this) {} 52 weak_ptr_factory_(this) {}
51 53
52 ProximityAuthSystem::~ProximityAuthSystem() { 54 ProximityAuthSystem::~ProximityAuthSystem() {
53 ScreenlockBridge::Get()->RemoveObserver(this); 55 ScreenlockBridge::Get()->RemoveObserver(this);
54 unlock_manager_->SetRemoteDeviceLifeCycle(nullptr); 56 unlock_manager_->SetRemoteDeviceLifeCycle(nullptr);
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 PA_LOG(INFO) << "Creating RemoteDeviceLifeCycle for focused user: " 184 PA_LOG(INFO) << "Creating RemoteDeviceLifeCycle for focused user: "
183 << account_id.Serialize(); 185 << account_id.Serialize();
184 remote_device_life_cycle_ = CreateRemoteDeviceLifeCycle(remote_device); 186 remote_device_life_cycle_ = CreateRemoteDeviceLifeCycle(remote_device);
185 unlock_manager_->SetRemoteDeviceLifeCycle(remote_device_life_cycle_.get()); 187 unlock_manager_->SetRemoteDeviceLifeCycle(remote_device_life_cycle_.get());
186 remote_device_life_cycle_->AddObserver(this); 188 remote_device_life_cycle_->AddObserver(this);
187 remote_device_life_cycle_->Start(); 189 remote_device_life_cycle_->Start();
188 } 190 }
189 } 191 }
190 192
191 bool ProximityAuthSystem::ShouldForcePassword() { 193 bool ProximityAuthSystem::ShouldForcePassword() {
194 // TODO(tengs): We need to properly propagate the last login time to the login
195 // screen.
196 if (screenlock_type_ == ScreenlockType::SIGN_IN)
197 return false;
198
192 // TODO(tengs): Put this force password reauth logic behind an enterprise 199 // TODO(tengs): Put this force password reauth logic behind an enterprise
193 // policy. See crbug.com/724717. 200 // policy. See crbug.com/724717.
194 int64_t now_ms = clock_->Now().ToJavaTime(); 201 int64_t now_ms = clock_->Now().ToJavaTime();
195 int64_t last_password_ms = pref_manager_->GetLastPasswordEntryTimestampMs(); 202 int64_t last_password_ms = pref_manager_->GetLastPasswordEntryTimestampMs();
196 203
197 if (now_ms < last_password_ms) { 204 if (now_ms < last_password_ms) {
198 PA_LOG(ERROR) << "Invalid last password timestamp: now=" << now_ms 205 PA_LOG(ERROR) << "Invalid last password timestamp: now=" << now_ms
199 << ", last_password=" << last_password_ms; 206 << ", last_password=" << last_password_ms;
200 return true; 207 return true;
201 } 208 }
202 209
203 return base::TimeDelta::FromMilliseconds(now_ms - last_password_ms) > 210 return base::TimeDelta::FromMilliseconds(now_ms - last_password_ms) >
204 base::TimeDelta::FromHours(kPasswordReauthPeriodHours); 211 base::TimeDelta::FromHours(kPasswordReauthPeriodHours);
205 } 212 }
206 213
207 } // proximity_auth 214 } // proximity_auth
OLDNEW
« no previous file with comments | « components/proximity_auth/proximity_auth_system.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698