OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/screen_locker.h" | 5 #include "chrome/browser/chromeos/login/screen_locker.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 content::NotificationService::AllSources()); | 63 content::NotificationService::AllSources()); |
64 } | 64 } |
65 | 65 |
66 // NotificationObserver overrides: | 66 // NotificationObserver overrides: |
67 virtual void Observe(int type, | 67 virtual void Observe(int type, |
68 const content::NotificationSource& source, | 68 const content::NotificationSource& source, |
69 const content::NotificationDetails& details) OVERRIDE { | 69 const content::NotificationDetails& details) OVERRIDE { |
70 if (type == chrome::NOTIFICATION_LOGIN_USER_CHANGED) { | 70 if (type == chrome::NOTIFICATION_LOGIN_USER_CHANGED) { |
71 // Register Screen Lock after login screen to make sure | 71 // Register Screen Lock after login screen to make sure |
72 // we don't show the screen lock on top of the login screen by accident. | 72 // we don't show the screen lock on top of the login screen by accident. |
73 if (chromeos::CrosLibrary::Get()->EnsureLoaded()) | 73 chromeos::CrosLibrary::Get()->GetScreenLockLibrary()->AddObserver(this); |
74 chromeos::CrosLibrary::Get()->GetScreenLockLibrary()->AddObserver(this); | |
75 } | 74 } |
76 } | 75 } |
77 | 76 |
78 virtual void LockScreen(chromeos::ScreenLockLibrary* obj) OVERRIDE { | 77 virtual void LockScreen(chromeos::ScreenLockLibrary* obj) OVERRIDE { |
79 VLOG(1) << "In: ScreenLockObserver::LockScreen"; | 78 VLOG(1) << "In: ScreenLockObserver::LockScreen"; |
80 SetupInputMethodsForScreenLocker(); | 79 SetupInputMethodsForScreenLocker(); |
81 chromeos::ScreenLocker::Show(); | 80 chromeos::ScreenLocker::Show(); |
82 } | 81 } |
83 | 82 |
84 virtual void UnlockScreen(chromeos::ScreenLockLibrary* obj) OVERRIDE { | 83 virtual void UnlockScreen(chromeos::ScreenLockLibrary* obj) OVERRIDE { |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 } | 264 } |
266 | 265 |
267 Profile* profile = ProfileManager::GetDefaultProfile(); | 266 Profile* profile = ProfileManager::GetDefaultProfile(); |
268 if (profile) { | 267 if (profile) { |
269 ProfileSyncService* service = profile->GetProfileSyncService(username); | 268 ProfileSyncService* service = profile->GetProfileSyncService(username); |
270 if (service && !service->HasSyncSetupCompleted()) { | 269 if (service && !service->HasSyncSetupCompleted()) { |
271 // If sync has failed somehow, try setting the sync passphrase here. | 270 // If sync has failed somehow, try setting the sync passphrase here. |
272 service->SetPassphrase(password, false); | 271 service->SetPassphrase(password, false); |
273 } | 272 } |
274 } | 273 } |
275 if (CrosLibrary::Get()->EnsureLoaded()) | 274 CrosLibrary::Get()->GetScreenLockLibrary()->NotifyScreenUnlockRequested(); |
276 CrosLibrary::Get()->GetScreenLockLibrary()->NotifyScreenUnlockRequested(); | |
277 | 275 |
278 if (login_status_consumer_) | 276 if (login_status_consumer_) |
279 login_status_consumer_->OnLoginSuccess(username, password, | 277 login_status_consumer_->OnLoginSuccess(username, password, |
280 unused, pending_requests, | 278 unused, pending_requests, |
281 using_oauth); | 279 using_oauth); |
282 } | 280 } |
283 | 281 |
284 void ScreenLocker::Authenticate(const string16& password) { | 282 void ScreenLocker::Authenticate(const string16& password) { |
285 authentication_start_time_ = base::Time::Now(); | 283 authentication_start_time_ = base::Time::Now(); |
286 delegate_->SetInputEnabled(false); | 284 delegate_->SetInputEnabled(false); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 else | 364 else |
367 locker->Signout(); | 365 locker->Signout(); |
368 #else | 366 #else |
369 locker->Init(); | 367 locker->Init(); |
370 #endif | 368 #endif |
371 } else { | 369 } else { |
372 // PowerManager re-sends lock screen signal if it doesn't | 370 // PowerManager re-sends lock screen signal if it doesn't |
373 // receive the response within timeout. Just send complete | 371 // receive the response within timeout. Just send complete |
374 // signal. | 372 // signal. |
375 VLOG(1) << "Show: locker already exists. Just sending completion event."; | 373 VLOG(1) << "Show: locker already exists. Just sending completion event."; |
376 if (CrosLibrary::Get()->EnsureLoaded()) | 374 CrosLibrary::Get()->GetScreenLockLibrary()->NotifyScreenLockCompleted(); |
377 CrosLibrary::Get()->GetScreenLockLibrary()->NotifyScreenLockCompleted(); | |
378 } | 375 } |
379 } | 376 } |
380 | 377 |
381 // static | 378 // static |
382 void ScreenLocker::Hide() { | 379 void ScreenLocker::Hide() { |
383 DCHECK(MessageLoop::current()->type() == MessageLoop::TYPE_UI); | 380 DCHECK(MessageLoop::current()->type() == MessageLoop::TYPE_UI); |
384 DCHECK(screen_locker_); | 381 DCHECK(screen_locker_); |
385 VLOG(1) << "Hide: Deleting ScreenLocker: " << screen_locker_; | 382 VLOG(1) << "Hide: Deleting ScreenLocker: " << screen_locker_; |
386 MessageLoopForUI::current()->DeleteSoon(FROM_HERE, screen_locker_); | 383 MessageLoopForUI::current()->DeleteSoon(FROM_HERE, screen_locker_); |
387 } | 384 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 ScreenLocker::~ScreenLocker() { | 418 ScreenLocker::~ScreenLocker() { |
422 DCHECK(MessageLoop::current()->type() == MessageLoop::TYPE_UI); | 419 DCHECK(MessageLoop::current()->type() == MessageLoop::TYPE_UI); |
423 ClearErrors(); | 420 ClearErrors(); |
424 | 421 |
425 screen_locker_ = NULL; | 422 screen_locker_ = NULL; |
426 bool state = false; | 423 bool state = false; |
427 content::NotificationService::current()->Notify( | 424 content::NotificationService::current()->Notify( |
428 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, | 425 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, |
429 content::Source<ScreenLocker>(this), | 426 content::Source<ScreenLocker>(this), |
430 content::Details<bool>(&state)); | 427 content::Details<bool>(&state)); |
431 if (CrosLibrary::Get()->EnsureLoaded()) | 428 CrosLibrary::Get()->GetScreenLockLibrary()->NotifyScreenUnlockCompleted(); |
432 CrosLibrary::Get()->GetScreenLockLibrary()->NotifyScreenUnlockCompleted(); | |
433 } | 429 } |
434 | 430 |
435 void ScreenLocker::SetAuthenticator(Authenticator* authenticator) { | 431 void ScreenLocker::SetAuthenticator(Authenticator* authenticator) { |
436 authenticator_ = authenticator; | 432 authenticator_ = authenticator; |
437 } | 433 } |
438 | 434 |
439 void ScreenLocker::ScreenLockReady() { | 435 void ScreenLocker::ScreenLockReady() { |
440 VLOG(1) << "ScreenLockReady: sending completed signal to power manager."; | 436 VLOG(1) << "ScreenLockReady: sending completed signal to power manager."; |
441 locked_ = true; | 437 locked_ = true; |
442 base::TimeDelta delta = base::Time::Now() - start_time_; | 438 base::TimeDelta delta = base::Time::Now() - start_time_; |
443 VLOG(1) << "Screen lock time: " << delta.InSecondsF(); | 439 VLOG(1) << "Screen lock time: " << delta.InSecondsF(); |
444 UMA_HISTOGRAM_TIMES("ScreenLocker.ScreenLockTime", delta); | 440 UMA_HISTOGRAM_TIMES("ScreenLocker.ScreenLockTime", delta); |
445 | 441 |
446 bool state = true; | 442 bool state = true; |
447 content::NotificationService::current()->Notify( | 443 content::NotificationService::current()->Notify( |
448 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, | 444 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, |
449 content::Source<ScreenLocker>(this), | 445 content::Source<ScreenLocker>(this), |
450 content::Details<bool>(&state)); | 446 content::Details<bool>(&state)); |
451 if (CrosLibrary::Get()->EnsureLoaded()) | 447 CrosLibrary::Get()->GetScreenLockLibrary()->NotifyScreenLockCompleted(); |
452 CrosLibrary::Get()->GetScreenLockLibrary()->NotifyScreenLockCompleted(); | |
453 } | 448 } |
454 | 449 |
455 } // namespace chromeos | 450 } // namespace chromeos |
OLD | NEW |