| Index: ash/wm/session_state_controller_impl.cc
|
| diff --git a/ash/wm/session_state_controller.cc b/ash/wm/session_state_controller_impl.cc
|
| similarity index 61%
|
| copy from ash/wm/session_state_controller.cc
|
| copy to ash/wm/session_state_controller_impl.cc
|
| index 5253ac2b84e0c5e35ec87100052849c02d3c324b..afab9d034456d4cb2a11360d472082e54712dded 100644
|
| --- a/ash/wm/session_state_controller.cc
|
| +++ b/ash/wm/session_state_controller_impl.cc
|
| @@ -2,7 +2,7 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "ash/wm/session_state_controller.h"
|
| +#include "ash/wm/session_state_controller_impl.h"
|
|
|
| #include "ash/ash_switches.h"
|
| #include "ash/shell.h"
|
| @@ -19,46 +19,33 @@
|
|
|
| namespace ash {
|
|
|
| -const int SessionStateController::kLockTimeoutMs = 400;
|
| -const int SessionStateController::kShutdownTimeoutMs = 400;
|
| -const int SessionStateController::kLockFailTimeoutMs = 4000;
|
| -const int SessionStateController::kLockToShutdownTimeoutMs = 150;
|
| -const int SessionStateController::kSlowCloseAnimMs = 400;
|
| -const int SessionStateController::kUndoSlowCloseAnimMs = 100;
|
| -const int SessionStateController::kFastCloseAnimMs = 150;
|
| -const int SessionStateController::kShutdownRequestDelayMs = 50;
|
| -
|
| -SessionStateController::TestApi::TestApi(SessionStateController* controller)
|
| +SessionStateControllerImpl::TestApi::TestApi(
|
| + SessionStateControllerImpl* controller)
|
| : controller_(controller) {
|
| }
|
|
|
| -SessionStateController::TestApi::~TestApi() {
|
| +SessionStateControllerImpl::TestApi::~TestApi() {
|
| }
|
|
|
| -SessionStateController::SessionStateController()
|
| +SessionStateControllerImpl::SessionStateControllerImpl()
|
| : login_status_(user::LOGGED_IN_NONE),
|
| - unlocked_login_status_(user::LOGGED_IN_NONE),
|
| + system_is_locked_(false),
|
| shutting_down_(false),
|
| - shutdown_after_lock_(false),
|
| - animator_(new internal::SessionStateAnimator()) {
|
| + shutdown_after_lock_(false) {
|
| Shell::GetPrimaryRootWindow()->AddRootWindowObserver(this);
|
| }
|
|
|
| -SessionStateController::~SessionStateController() {
|
| +SessionStateControllerImpl::~SessionStateControllerImpl() {
|
| Shell::GetPrimaryRootWindow()->RemoveRootWindowObserver(this);
|
| }
|
|
|
| -void SessionStateController::SetDelegate(
|
| - SessionStateControllerDelegate* delegate) {
|
| - delegate_.reset(delegate);
|
| -}
|
| -
|
| -void SessionStateController::OnLoginStateChanged(user::LoginStatus status) {
|
| - login_status_ = status;
|
| - unlocked_login_status_ = user::LOGGED_IN_NONE;
|
| +void SessionStateControllerImpl::OnLoginStateChanged(user::LoginStatus status) {
|
| + if (status != user::LOGGED_IN_LOCKED)
|
| + login_status_ = status;
|
| + system_is_locked_ = (status == user::LOGGED_IN_LOCKED);
|
| }
|
|
|
| -void SessionStateController::OnAppTerminating() {
|
| +void SessionStateControllerImpl::OnAppTerminating() {
|
| // If we hear that Chrome is exiting but didn't request it ourselves, all we
|
| // can really hope for is that we'll have time to clear the screen.
|
| if (!shutting_down_) {
|
| @@ -73,17 +60,11 @@ void SessionStateController::OnAppTerminating() {
|
| }
|
| }
|
|
|
| -void SessionStateController::OnLockStateChanged(bool locked) {
|
| +void SessionStateControllerImpl::OnLockStateChanged(bool locked) {
|
| if (shutting_down_ || (IsLocked()) == locked)
|
| return;
|
|
|
| - if (!locked && login_status_ == user::LOGGED_IN_LOCKED) {
|
| - login_status_ = unlocked_login_status_;
|
| - unlocked_login_status_ = user::LOGGED_IN_NONE;
|
| - } else {
|
| - unlocked_login_status_ = login_status_;
|
| - login_status_ = user::LOGGED_IN_LOCKED;
|
| - }
|
| + system_is_locked_ = locked;
|
|
|
| if (locked) {
|
| animator_->StartAnimation(
|
| @@ -106,8 +87,8 @@ void SessionStateController::OnLockStateChanged(bool locked) {
|
| }
|
| }
|
|
|
| -void SessionStateController::OnStartingLock() {
|
| - if (shutting_down_ || login_status_ == user::LOGGED_IN_LOCKED)
|
| +void SessionStateControllerImpl::OnStartingLock() {
|
| + if (shutting_down_ || system_is_locked_)
|
| return;
|
|
|
| // Ensure that the black layer is visible -- if the screen was locked via
|
| @@ -121,7 +102,7 @@ void SessionStateController::OnStartingLock() {
|
|
|
| animator_->StartAnimation(
|
| internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS,
|
| - internal::SessionStateAnimator::ANIMATION_FAST_CLOSE);
|
| + internal::SessionStateAnimator::ANIMATION_FULL_CLOSE);
|
|
|
| // Hide the screen locker containers so we can make them fade in later.
|
| animator_->StartAnimation(
|
| @@ -129,82 +110,71 @@ void SessionStateController::OnStartingLock() {
|
| internal::SessionStateAnimator::ANIMATION_HIDE);
|
| }
|
|
|
| -void SessionStateController::StartLockAnimationAndLockImmediately() {
|
| +void SessionStateControllerImpl::StartLockAnimationAndLockImmediately() {
|
| animator_->ShowBlackLayer();
|
| animator_->StartAnimation(
|
| internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS,
|
| - internal::SessionStateAnimator::ANIMATION_SLOW_CLOSE);
|
| + internal::SessionStateAnimator::ANIMATION_PARTIAL_CLOSE);
|
| OnLockTimeout();
|
| }
|
|
|
| -void SessionStateController::StartLockAnimation() {
|
| +void SessionStateControllerImpl::StartLockAnimation() {
|
| shutdown_after_lock_ = true;
|
|
|
| animator_->ShowBlackLayer();
|
| animator_->StartAnimation(
|
| internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS,
|
| - internal::SessionStateAnimator::ANIMATION_SLOW_CLOSE);
|
| + internal::SessionStateAnimator::ANIMATION_PARTIAL_CLOSE);
|
| StartLockTimer();
|
| }
|
|
|
| -void SessionStateController::StartShutdownAnimation() {
|
| +void SessionStateControllerImpl::StartShutdownAnimation() {
|
| animator_->ShowBlackLayer();
|
| animator_->StartAnimation(
|
| internal::SessionStateAnimator::kAllContainersMask,
|
| - internal::SessionStateAnimator::ANIMATION_SLOW_CLOSE);
|
| + internal::SessionStateAnimator::ANIMATION_PARTIAL_CLOSE);
|
|
|
| StartPreShutdownAnimationTimer();
|
| }
|
|
|
| -bool SessionStateController::IsEligibleForLock() {
|
| +bool SessionStateControllerImpl::IsEligibleForLock() {
|
| return IsLoggedInAsNonGuest() && !IsLocked() && !LockRequested();
|
| }
|
|
|
| -bool SessionStateController::IsLocked() {
|
| - return login_status_ == user::LOGGED_IN_LOCKED;
|
| +bool SessionStateControllerImpl::IsLocked() {
|
| + return system_is_locked_;
|
| }
|
|
|
| -bool SessionStateController::LockRequested() {
|
| +bool SessionStateControllerImpl::LockRequested() {
|
| return lock_fail_timer_.IsRunning();
|
| }
|
|
|
| -bool SessionStateController::ShutdownRequested() {
|
| +bool SessionStateControllerImpl::ShutdownRequested() {
|
| return shutting_down_;
|
| }
|
|
|
| -bool SessionStateController::CanCancelLockAnimation() {
|
| +bool SessionStateControllerImpl::CanCancelLockAnimation() {
|
| return lock_timer_.IsRunning();
|
| }
|
|
|
| -void SessionStateController::CancelLockAnimation() {
|
| - if (!CanCancelLockAnimation())
|
| - return;
|
| - shutdown_after_lock_ = false;
|
| - animator_->StartAnimation(
|
| - internal::SessionStateAnimator::kAllContainersMask,
|
| - internal::SessionStateAnimator::ANIMATION_UNDO_SLOW_CLOSE);
|
| - animator_->ScheduleDropBlackLayer();
|
| - lock_timer_.Stop();
|
| -}
|
| -
|
| -void SessionStateController::CancelLockWithOtherAnimation() {
|
| +void SessionStateControllerImpl::CancelLockAnimation() {
|
| if (!CanCancelLockAnimation())
|
| return;
|
| shutdown_after_lock_ = false;
|
| animator_->StartAnimation(
|
| internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS,
|
| - internal::SessionStateAnimator::ANIMATION_UNDO_SLOW_CLOSE);
|
| + internal::SessionStateAnimator::ANIMATION_UNDO_PARTIAL_CLOSE);
|
| animator_->ScheduleDropBlackLayer();
|
| lock_timer_.Stop();
|
| }
|
|
|
| -bool SessionStateController::CanCancelShutdownAnimation() {
|
| +bool SessionStateControllerImpl::CanCancelShutdownAnimation() {
|
| return pre_shutdown_timer_.IsRunning() ||
|
| shutdown_after_lock_ ||
|
| lock_to_shutdown_timer_.IsRunning();
|
| }
|
|
|
| -void SessionStateController::CancelShutdownAnimation() {
|
| +void SessionStateControllerImpl::CancelShutdownAnimation() {
|
| if (!CanCancelShutdownAnimation())
|
| return;
|
| if (lock_to_shutdown_timer_.IsRunning()) {
|
| @@ -216,7 +186,7 @@ void SessionStateController::CancelShutdownAnimation() {
|
| return;
|
| }
|
|
|
| - if (login_status_ == user::LOGGED_IN_LOCKED) {
|
| + if (system_is_locked_) {
|
| // If we've already started shutdown transition at lock screen
|
| // desktop background needs to be restored immediately.
|
| animator_->StartAnimation(
|
| @@ -224,24 +194,24 @@ void SessionStateController::CancelShutdownAnimation() {
|
| internal::SessionStateAnimator::ANIMATION_RESTORE);
|
| animator_->StartAnimation(
|
| internal::SessionStateAnimator::kAllLockScreenContainersMask,
|
| - internal::SessionStateAnimator::ANIMATION_UNDO_SLOW_CLOSE);
|
| + internal::SessionStateAnimator::ANIMATION_UNDO_PARTIAL_CLOSE);
|
| animator_->ScheduleDropBlackLayer();
|
| } else {
|
| animator_->StartAnimation(
|
| internal::SessionStateAnimator::kAllContainersMask,
|
| - internal::SessionStateAnimator::ANIMATION_UNDO_SLOW_CLOSE);
|
| + internal::SessionStateAnimator::ANIMATION_UNDO_PARTIAL_CLOSE);
|
| animator_->ScheduleDropBlackLayer();
|
| }
|
| pre_shutdown_timer_.Stop();
|
| }
|
|
|
| -void SessionStateController::RequestShutdown() {
|
| +void SessionStateControllerImpl::RequestShutdown() {
|
| if (!shutting_down_)
|
| animator_->ShowBlackLayer();
|
| RequestShutdownImpl();
|
| }
|
|
|
| -void SessionStateController::RequestShutdownImpl() {
|
| +void SessionStateControllerImpl::RequestShutdownImpl() {
|
| DCHECK(!shutting_down_);
|
| shutting_down_ = true;
|
|
|
| @@ -252,7 +222,7 @@ void SessionStateController::RequestShutdownImpl() {
|
| animator_->ShowBlackLayer();
|
| if (login_status_ != user::LOGGED_IN_NONE) {
|
| // Hide the other containers before starting the animation.
|
| - // ANIMATION_FAST_CLOSE will make the screen locker windows partially
|
| + // ANIMATION_FULL_CLOSE will make the screen locker windows partially
|
| // transparent, and we don't want the other windows to show through.
|
| animator_->StartAnimation(
|
| internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS |
|
| @@ -260,44 +230,44 @@ void SessionStateController::RequestShutdownImpl() {
|
| internal::SessionStateAnimator::ANIMATION_HIDE);
|
| animator_->StartAnimation(
|
| internal::SessionStateAnimator::kAllLockScreenContainersMask,
|
| - internal::SessionStateAnimator::ANIMATION_FAST_CLOSE);
|
| + internal::SessionStateAnimator::ANIMATION_FULL_CLOSE);
|
| } else {
|
| animator_->StartAnimation(
|
| internal::SessionStateAnimator::kAllContainersMask,
|
| - internal::SessionStateAnimator::ANIMATION_FAST_CLOSE);
|
| + internal::SessionStateAnimator::ANIMATION_FULL_CLOSE);
|
| }
|
| StartRealShutdownTimer();
|
| }
|
|
|
| -void SessionStateController::OnRootWindowHostCloseRequested(
|
| +void SessionStateControllerImpl::OnRootWindowHostCloseRequested(
|
| const aura::RootWindow*) {
|
| if(Shell::GetInstance() && Shell::GetInstance()->delegate())
|
| Shell::GetInstance()->delegate()->Exit();
|
| }
|
|
|
| -bool SessionStateController::IsLoggedInAsNonGuest() const {
|
| +bool SessionStateControllerImpl::IsLoggedInAsNonGuest() const {
|
| // TODO(mukai): think about kiosk mode.
|
| return (login_status_ != user::LOGGED_IN_NONE) &&
|
| (login_status_ != user::LOGGED_IN_GUEST);
|
| }
|
|
|
| -void SessionStateController::StartLockTimer() {
|
| +void SessionStateControllerImpl::StartLockTimer() {
|
| lock_timer_.Stop();
|
| lock_timer_.Start(FROM_HERE,
|
| base::TimeDelta::FromMilliseconds(kSlowCloseAnimMs),
|
| - this, &SessionStateController::OnLockTimeout);
|
| + this, &SessionStateControllerImpl::OnLockTimeout);
|
| }
|
|
|
| -void SessionStateController::OnLockTimeout() {
|
| +void SessionStateControllerImpl::OnLockTimeout() {
|
| delegate_->RequestLockScreen();
|
| lock_fail_timer_.Start(
|
| FROM_HERE,
|
| base::TimeDelta::FromMilliseconds(kLockFailTimeoutMs),
|
| - this, &SessionStateController::OnLockFailTimeout);
|
| + this, &SessionStateControllerImpl::OnLockFailTimeout);
|
| }
|
|
|
| -void SessionStateController::OnLockFailTimeout() {
|
| - DCHECK_NE(login_status_, user::LOGGED_IN_LOCKED);
|
| +void SessionStateControllerImpl::OnLockFailTimeout() {
|
| + DCHECK(!system_is_locked_);
|
| // Undo lock animation.
|
| animator_->StartAnimation(
|
| internal::SessionStateAnimator::LAUNCHER |
|
| @@ -306,43 +276,43 @@ void SessionStateController::OnLockFailTimeout() {
|
| animator_->DropBlackLayer();
|
| }
|
|
|
| -void SessionStateController::StartLockToShutdownTimer() {
|
| +void SessionStateControllerImpl::StartLockToShutdownTimer() {
|
| shutdown_after_lock_ = false;
|
| lock_to_shutdown_timer_.Stop();
|
| lock_to_shutdown_timer_.Start(
|
| FROM_HERE,
|
| base::TimeDelta::FromMilliseconds(kLockToShutdownTimeoutMs),
|
| - this, &SessionStateController::OnLockToShutdownTimeout);
|
| + this, &SessionStateControllerImpl::OnLockToShutdownTimeout);
|
| }
|
|
|
|
|
| -void SessionStateController::OnLockToShutdownTimeout() {
|
| - DCHECK_EQ(login_status_, user::LOGGED_IN_LOCKED);
|
| +void SessionStateControllerImpl::OnLockToShutdownTimeout() {
|
| + DCHECK(system_is_locked_);
|
| StartShutdownAnimation();
|
| }
|
|
|
| -void SessionStateController::StartPreShutdownAnimationTimer() {
|
| +void SessionStateControllerImpl::StartPreShutdownAnimationTimer() {
|
| pre_shutdown_timer_.Stop();
|
| pre_shutdown_timer_.Start(
|
| FROM_HERE,
|
| base::TimeDelta::FromMilliseconds(kShutdownTimeoutMs),
|
| - this, &SessionStateController::OnPreShutdownAnimationTimeout);
|
| + this, &SessionStateControllerImpl::OnPreShutdownAnimationTimeout);
|
| }
|
|
|
| -void SessionStateController::OnPreShutdownAnimationTimeout() {
|
| +void SessionStateControllerImpl::OnPreShutdownAnimationTimeout() {
|
| if (!shutting_down_)
|
| RequestShutdownImpl();
|
| }
|
|
|
| -void SessionStateController::StartRealShutdownTimer() {
|
| +void SessionStateControllerImpl::StartRealShutdownTimer() {
|
| real_shutdown_timer_.Start(
|
| FROM_HERE,
|
| base::TimeDelta::FromMilliseconds(kFastCloseAnimMs +
|
| kShutdownRequestDelayMs),
|
| - this, &SessionStateController::OnRealShutdownTimeout);
|
| + this, &SessionStateControllerImpl::OnRealShutdownTimeout);
|
| }
|
|
|
| -void SessionStateController::OnRealShutdownTimeout() {
|
| +void SessionStateControllerImpl::OnRealShutdownTimeout() {
|
| DCHECK(shutting_down_);
|
| #if defined(OS_CHROMEOS)
|
| if (!base::chromeos::IsRunningOnChromeOS()) {
|
|
|