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/common/wallpaper/wallpaper_controller.h" | 10 #include "ash/common/wallpaper/wallpaper_controller.h" |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
466 // static | 466 // static |
467 void ScreenLocker::Hide() { | 467 void ScreenLocker::Hide() { |
468 DCHECK(base::MessageLoopForUI::IsCurrent()); | 468 DCHECK(base::MessageLoopForUI::IsCurrent()); |
469 // For a guest user, screen_locker_ would have never been initialized. | 469 // For a guest user, screen_locker_ would have never been initialized. |
470 if (user_manager::UserManager::Get()->IsLoggedInAsGuest()) { | 470 if (user_manager::UserManager::Get()->IsLoggedInAsGuest()) { |
471 VLOG(1) << "Refusing to hide lock screen for guest account"; | 471 VLOG(1) << "Refusing to hide lock screen for guest account"; |
472 return; | 472 return; |
473 } | 473 } |
474 | 474 |
475 DCHECK(screen_locker_); | 475 DCHECK(screen_locker_); |
476 base::Callback<void(void)> callback = | 476 |
477 base::Bind(&ScreenLocker::ScheduleDeletion); | 477 // Sets session state to ACTIVE before destroying screen locker. Otherwise, |
478 ash::Shell::GetInstance()->lock_state_controller()-> | 478 // ash thinks the session is blocked and does not correct set focus on |
479 OnLockScreenHide(callback); | 479 // screen lock dismissal. |
480 // TODO(xiyuan): Figure out a better way to ensure state change go through. | |
481 session_manager::SessionManager::Get()->SetSessionState( | |
482 session_manager::SessionState::ACTIVE); | |
483 BrowserThread::PostTask( | |
484 BrowserThread::UI, FROM_HERE, base::Bind([] { | |
485 base::Callback<void(void)> callback = | |
486 base::Bind(&ScreenLocker::ScheduleDeletion); | |
James Cook
2017/03/17 17:14:36
nit: maybe inline this below?
xiyuan
2017/03/17 22:52:03
We need to fix OnLockScreenHide's signature in ord
| |
487 ash::Shell::GetInstance()->lock_state_controller()->OnLockScreenHide( | |
488 callback); | |
489 })); | |
xiyuan
2017/03/17 07:08:16
This was caught by ScreenLockerTest.TestFullscreen
| |
480 } | 490 } |
481 | 491 |
492 // static | |
482 void ScreenLocker::ScheduleDeletion() { | 493 void ScreenLocker::ScheduleDeletion() { |
483 // Avoid possible multiple calls. | 494 // Avoid possible multiple calls. |
484 if (screen_locker_ == NULL) | 495 if (screen_locker_ == NULL) |
485 return; | 496 return; |
486 VLOG(1) << "Deleting ScreenLocker " << screen_locker_; | 497 VLOG(1) << "Deleting ScreenLocker " << screen_locker_; |
487 | 498 |
488 AccessibilityManager::Get()->PlayEarcon( | 499 AccessibilityManager::Get()->PlayEarcon( |
489 SOUND_UNLOCK, PlaySoundOption::SPOKEN_FEEDBACK_ENABLED); | 500 SOUND_UNLOCK, PlaySoundOption::SPOKEN_FEEDBACK_ENABLED); |
490 | 501 |
491 delete screen_locker_; | 502 delete screen_locker_; |
(...skipping 19 matching lines...) Expand all Loading... | |
511 VLOG(1) << "Emitting SCREEN_LOCK_STATE_CHANGED with state=" << state; | 522 VLOG(1) << "Emitting SCREEN_LOCK_STATE_CHANGED with state=" << state; |
512 content::NotificationService::current()->Notify( | 523 content::NotificationService::current()->Notify( |
513 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, | 524 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, |
514 content::Source<ScreenLocker>(this), | 525 content::Source<ScreenLocker>(this), |
515 content::Details<bool>(&state)); | 526 content::Details<bool>(&state)); |
516 | 527 |
517 VLOG(1) << "Calling session manager's HandleLockScreenDismissed D-Bus method"; | 528 VLOG(1) << "Calling session manager's HandleLockScreenDismissed D-Bus method"; |
518 DBusThreadManager::Get()->GetSessionManagerClient()-> | 529 DBusThreadManager::Get()->GetSessionManagerClient()-> |
519 NotifyLockScreenDismissed(); | 530 NotifyLockScreenDismissed(); |
520 | 531 |
521 session_manager::SessionManager::Get()->SetSessionState( | |
522 session_manager::SessionState::ACTIVE); | |
523 | |
524 if (saved_ime_state_.get()) { | 532 if (saved_ime_state_.get()) { |
525 input_method::InputMethodManager::Get()->SetState(saved_ime_state_); | 533 input_method::InputMethodManager::Get()->SetState(saved_ime_state_); |
526 } | 534 } |
527 } | 535 } |
528 | 536 |
529 void ScreenLocker::SetAuthenticator(Authenticator* authenticator) { | 537 void ScreenLocker::SetAuthenticator(Authenticator* authenticator) { |
530 authenticator_ = authenticator; | 538 authenticator_ = authenticator; |
531 } | 539 } |
532 | 540 |
533 void ScreenLocker::ScreenLockReady() { | 541 void ScreenLocker::ScreenLockReady() { |
(...skipping 25 matching lines...) Expand all Loading... | |
559 | 567 |
560 bool ScreenLocker::IsUserLoggedIn(const AccountId& account_id) const { | 568 bool ScreenLocker::IsUserLoggedIn(const AccountId& account_id) const { |
561 for (user_manager::User* user : users_) { | 569 for (user_manager::User* user : users_) { |
562 if (user->GetAccountId() == account_id) | 570 if (user->GetAccountId() == account_id) |
563 return true; | 571 return true; |
564 } | 572 } |
565 return false; | 573 return false; |
566 } | 574 } |
567 | 575 |
568 } // namespace chromeos | 576 } // namespace chromeos |
OLD | NEW |