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 "chrome/browser/chromeos/login/lock/screen_locker.h" | 5 #include "chrome/browser/chromeos/login/lock/screen_locker.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 ScreenLockObserver* g_screen_lock_observer = NULL; | 122 ScreenLockObserver* g_screen_lock_observer = NULL; |
123 | 123 |
124 } // namespace | 124 } // namespace |
125 | 125 |
126 // static | 126 // static |
127 ScreenLocker* ScreenLocker::screen_locker_ = NULL; | 127 ScreenLocker* ScreenLocker::screen_locker_ = NULL; |
128 | 128 |
129 ////////////////////////////////////////////////////////////////////////////// | 129 ////////////////////////////////////////////////////////////////////////////// |
130 // ScreenLocker, public: | 130 // ScreenLocker, public: |
131 | 131 |
132 ScreenLocker::ScreenLocker(const UserList& users) | 132 ScreenLocker::ScreenLocker(const user_manager::UserList& users) |
133 : users_(users), | 133 : users_(users), |
134 locked_(false), | 134 locked_(false), |
135 start_time_(base::Time::Now()), | 135 start_time_(base::Time::Now()), |
136 auth_status_consumer_(NULL), | 136 auth_status_consumer_(NULL), |
137 incorrect_passwords_count_(0), | 137 incorrect_passwords_count_(0), |
138 weak_factory_(this) { | 138 weak_factory_(this) { |
139 DCHECK(!screen_locker_); | 139 DCHECK(!screen_locker_); |
140 screen_locker_ = this; | 140 screen_locker_ = this; |
141 | 141 |
142 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 142 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 incorrect_passwords_count_ = 0; | 195 incorrect_passwords_count_ = 0; |
196 if (authentication_start_time_.is_null()) { | 196 if (authentication_start_time_.is_null()) { |
197 if (!user_context.GetUserID().empty()) | 197 if (!user_context.GetUserID().empty()) |
198 LOG(ERROR) << "Start time is not set at authentication success"; | 198 LOG(ERROR) << "Start time is not set at authentication success"; |
199 } else { | 199 } else { |
200 base::TimeDelta delta = base::Time::Now() - authentication_start_time_; | 200 base::TimeDelta delta = base::Time::Now() - authentication_start_time_; |
201 VLOG(1) << "Authentication success: " << delta.InSecondsF() << " second(s)"; | 201 VLOG(1) << "Authentication success: " << delta.InSecondsF() << " second(s)"; |
202 UMA_HISTOGRAM_TIMES("ScreenLocker.AuthenticationSuccessTime", delta); | 202 UMA_HISTOGRAM_TIMES("ScreenLocker.AuthenticationSuccessTime", delta); |
203 } | 203 } |
204 | 204 |
205 const User* user = UserManager::Get()->FindUser(user_context.GetUserID()); | 205 const user_manager::User* user = |
| 206 UserManager::Get()->FindUser(user_context.GetUserID()); |
206 if (user) { | 207 if (user) { |
207 if (!user->is_active()) | 208 if (!user->is_active()) |
208 UserManager::Get()->SwitchActiveUser(user_context.GetUserID()); | 209 UserManager::Get()->SwitchActiveUser(user_context.GetUserID()); |
209 } else { | 210 } else { |
210 NOTREACHED() << "Logged in user not found."; | 211 NOTREACHED() << "Logged in user not found."; |
211 } | 212 } |
212 | 213 |
213 authentication_capture_.reset(new AuthenticationParametersCapture()); | 214 authentication_capture_.reset(new AuthenticationParametersCapture()); |
214 authentication_capture_->user_context = user_context; | 215 authentication_capture_->user_context = user_context; |
215 | 216 |
(...skipping 27 matching lines...) Expand all Loading... |
243 | 244 |
244 void ScreenLocker::Authenticate(const UserContext& user_context) { | 245 void ScreenLocker::Authenticate(const UserContext& user_context) { |
245 LOG_ASSERT(IsUserLoggedIn(user_context.GetUserID())) | 246 LOG_ASSERT(IsUserLoggedIn(user_context.GetUserID())) |
246 << "Invalid user trying to unlock."; | 247 << "Invalid user trying to unlock."; |
247 | 248 |
248 authentication_start_time_ = base::Time::Now(); | 249 authentication_start_time_ = base::Time::Now(); |
249 delegate_->SetInputEnabled(false); | 250 delegate_->SetInputEnabled(false); |
250 delegate_->OnAuthenticate(); | 251 delegate_->OnAuthenticate(); |
251 | 252 |
252 // Special case: supervised users. Use special authenticator. | 253 // Special case: supervised users. Use special authenticator. |
253 if (const User* user = FindUnlockUser(user_context.GetUserID())) { | 254 if (const user_manager::User* user = |
| 255 FindUnlockUser(user_context.GetUserID())) { |
254 if (user->GetType() == user_manager::USER_TYPE_SUPERVISED) { | 256 if (user->GetType() == user_manager::USER_TYPE_SUPERVISED) { |
255 UserContext updated_context = UserManager::Get() | 257 UserContext updated_context = UserManager::Get() |
256 ->GetSupervisedUserManager() | 258 ->GetSupervisedUserManager() |
257 ->GetAuthentication() | 259 ->GetAuthentication() |
258 ->TransformKey(user_context); | 260 ->TransformKey(user_context); |
259 // TODO(antrim) : replace empty closure with explicit method. | 261 // TODO(antrim) : replace empty closure with explicit method. |
260 // http://crbug.com/351268 | 262 // http://crbug.com/351268 |
261 BrowserThread::PostTask( | 263 BrowserThread::PostTask( |
262 BrowserThread::UI, | 264 BrowserThread::UI, |
263 FROM_HERE, | 265 FROM_HERE, |
264 base::Bind(&ExtendedAuthenticator::AuthenticateToCheck, | 266 base::Bind(&ExtendedAuthenticator::AuthenticateToCheck, |
265 extended_authenticator_.get(), | 267 extended_authenticator_.get(), |
266 updated_context, | 268 updated_context, |
267 base::Closure())); | 269 base::Closure())); |
268 return; | 270 return; |
269 } | 271 } |
270 } | 272 } |
271 | 273 |
272 // TODO(antrim) : migrate to new authenticator for all types of users. | 274 // TODO(antrim) : migrate to new authenticator for all types of users. |
273 // http://crbug.com/351268 | 275 // http://crbug.com/351268 |
274 BrowserThread::PostTask( | 276 BrowserThread::PostTask( |
275 BrowserThread::UI, FROM_HERE, | 277 BrowserThread::UI, FROM_HERE, |
276 base::Bind(&Authenticator::AuthenticateToUnlock, | 278 base::Bind(&Authenticator::AuthenticateToUnlock, |
277 authenticator_.get(), | 279 authenticator_.get(), |
278 user_context)); | 280 user_context)); |
279 } | 281 } |
280 | 282 |
281 const User* ScreenLocker::FindUnlockUser(const std::string& user_id) { | 283 const user_manager::User* ScreenLocker::FindUnlockUser( |
282 const User* unlock_user = NULL; | 284 const std::string& user_id) { |
283 for (UserList::const_iterator it = users_.begin(); it != users_.end(); ++it) { | 285 const user_manager::User* unlock_user = NULL; |
| 286 for (user_manager::UserList::const_iterator it = users_.begin(); |
| 287 it != users_.end(); |
| 288 ++it) { |
284 if ((*it)->email() == user_id) { | 289 if ((*it)->email() == user_id) { |
285 unlock_user = *it; | 290 unlock_user = *it; |
286 break; | 291 break; |
287 } | 292 } |
288 } | 293 } |
289 return unlock_user; | 294 return unlock_user; |
290 } | 295 } |
291 | 296 |
292 void ScreenLocker::ClearErrors() { | 297 void ScreenLocker::ClearErrors() { |
293 delegate_->ClearErrors(); | 298 delegate_->ClearErrors(); |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 content::Details<bool>(&state)); | 482 content::Details<bool>(&state)); |
478 VLOG(1) << "Calling session manager's HandleLockScreenShown D-Bus method"; | 483 VLOG(1) << "Calling session manager's HandleLockScreenShown D-Bus method"; |
479 DBusThreadManager::Get()->GetSessionManagerClient()->NotifyLockScreenShown(); | 484 DBusThreadManager::Get()->GetSessionManagerClient()->NotifyLockScreenShown(); |
480 } | 485 } |
481 | 486 |
482 content::WebUI* ScreenLocker::GetAssociatedWebUI() { | 487 content::WebUI* ScreenLocker::GetAssociatedWebUI() { |
483 return delegate_->GetAssociatedWebUI(); | 488 return delegate_->GetAssociatedWebUI(); |
484 } | 489 } |
485 | 490 |
486 bool ScreenLocker::IsUserLoggedIn(const std::string& username) { | 491 bool ScreenLocker::IsUserLoggedIn(const std::string& username) { |
487 for (UserList::const_iterator it = users_.begin(); it != users_.end(); ++it) { | 492 for (user_manager::UserList::const_iterator it = users_.begin(); |
| 493 it != users_.end(); |
| 494 ++it) { |
488 if ((*it)->email() == username) | 495 if ((*it)->email() == username) |
489 return true; | 496 return true; |
490 } | 497 } |
491 return false; | 498 return false; |
492 } | 499 } |
493 | 500 |
494 } // namespace chromeos | 501 } // namespace chromeos |
OLD | NEW |