| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/wm/session_state_controller.h" | 5 #include "ash/wm/session_state_controller_impl.h" |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/shell_delegate.h" | 9 #include "ash/shell_delegate.h" |
| 10 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
| 11 #include "ash/wm/session_state_animator.h" | 11 #include "ash/wm/session_state_animator.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "ui/aura/root_window.h" | 13 #include "ui/aura/root_window.h" |
| 14 #include "ui/aura/shared/compound_event_filter.h" | 14 #include "ui/aura/shared/compound_event_filter.h" |
| 15 | 15 |
| 16 #if defined(OS_CHROMEOS) | 16 #if defined(OS_CHROMEOS) |
| 17 #include "base/chromeos/chromeos_version.h" | 17 #include "base/chromeos/chromeos_version.h" |
| 18 #endif | 18 #endif |
| 19 | 19 |
| 20 namespace ash { | 20 namespace ash { |
| 21 | 21 |
| 22 const int SessionStateController::kLockTimeoutMs = 400; | 22 SessionStateControllerImpl::TestApi::TestApi( |
| 23 const int SessionStateController::kShutdownTimeoutMs = 400; | 23 SessionStateControllerImpl* controller) |
| 24 const int SessionStateController::kLockFailTimeoutMs = 4000; | |
| 25 const int SessionStateController::kLockToShutdownTimeoutMs = 150; | |
| 26 const int SessionStateController::kSlowCloseAnimMs = 400; | |
| 27 const int SessionStateController::kUndoSlowCloseAnimMs = 100; | |
| 28 const int SessionStateController::kFastCloseAnimMs = 150; | |
| 29 const int SessionStateController::kShutdownRequestDelayMs = 50; | |
| 30 | |
| 31 SessionStateController::TestApi::TestApi(SessionStateController* controller) | |
| 32 : controller_(controller) { | 24 : controller_(controller) { |
| 33 } | 25 } |
| 34 | 26 |
| 35 SessionStateController::TestApi::~TestApi() { | 27 SessionStateControllerImpl::TestApi::~TestApi() { |
| 36 } | 28 } |
| 37 | 29 |
| 38 SessionStateController::SessionStateController() | 30 SessionStateControllerImpl::SessionStateControllerImpl() |
| 39 : login_status_(user::LOGGED_IN_NONE), | 31 : login_status_(user::LOGGED_IN_NONE), |
| 40 unlocked_login_status_(user::LOGGED_IN_NONE), | 32 system_is_locked_(false), |
| 41 shutting_down_(false), | 33 shutting_down_(false), |
| 42 shutdown_after_lock_(false), | 34 shutdown_after_lock_(false) { |
| 43 animator_(new internal::SessionStateAnimator()) { | |
| 44 Shell::GetPrimaryRootWindow()->AddRootWindowObserver(this); | 35 Shell::GetPrimaryRootWindow()->AddRootWindowObserver(this); |
| 45 } | 36 } |
| 46 | 37 |
| 47 SessionStateController::~SessionStateController() { | 38 SessionStateControllerImpl::~SessionStateControllerImpl() { |
| 48 Shell::GetPrimaryRootWindow()->RemoveRootWindowObserver(this); | 39 Shell::GetPrimaryRootWindow()->RemoveRootWindowObserver(this); |
| 49 } | 40 } |
| 50 | 41 |
| 51 void SessionStateController::SetDelegate( | 42 void SessionStateControllerImpl::OnLoginStateChanged(user::LoginStatus status) { |
| 52 SessionStateControllerDelegate* delegate) { | 43 if (status != user::LOGGED_IN_LOCKED) |
| 53 delegate_.reset(delegate); | 44 login_status_ = status; |
| 45 system_is_locked_ = (status == user::LOGGED_IN_LOCKED); |
| 54 } | 46 } |
| 55 | 47 |
| 56 void SessionStateController::OnLoginStateChanged(user::LoginStatus status) { | 48 void SessionStateControllerImpl::OnAppTerminating() { |
| 57 login_status_ = status; | |
| 58 unlocked_login_status_ = user::LOGGED_IN_NONE; | |
| 59 } | |
| 60 | |
| 61 void SessionStateController::OnAppTerminating() { | |
| 62 // If we hear that Chrome is exiting but didn't request it ourselves, all we | 49 // If we hear that Chrome is exiting but didn't request it ourselves, all we |
| 63 // can really hope for is that we'll have time to clear the screen. | 50 // can really hope for is that we'll have time to clear the screen. |
| 64 if (!shutting_down_) { | 51 if (!shutting_down_) { |
| 65 shutting_down_ = true; | 52 shutting_down_ = true; |
| 66 Shell* shell = ash::Shell::GetInstance(); | 53 Shell* shell = ash::Shell::GetInstance(); |
| 67 shell->env_filter()->set_cursor_hidden_by_filter(false); | 54 shell->env_filter()->set_cursor_hidden_by_filter(false); |
| 68 shell->cursor_manager()->ShowCursor(false); | 55 shell->cursor_manager()->ShowCursor(false); |
| 69 animator_->ShowBlackLayer(); | 56 animator_->ShowBlackLayer(); |
| 70 animator_->StartAnimation( | 57 animator_->StartAnimation( |
| 71 internal::SessionStateAnimator::kAllContainersMask, | 58 internal::SessionStateAnimator::kAllContainersMask, |
| 72 internal::SessionStateAnimator::ANIMATION_HIDE); | 59 internal::SessionStateAnimator::ANIMATION_HIDE); |
| 73 } | 60 } |
| 74 } | 61 } |
| 75 | 62 |
| 76 void SessionStateController::OnLockStateChanged(bool locked) { | 63 void SessionStateControllerImpl::OnLockStateChanged(bool locked) { |
| 77 if (shutting_down_ || (IsLocked()) == locked) | 64 if (shutting_down_ || (IsLocked()) == locked) |
| 78 return; | 65 return; |
| 79 | 66 |
| 80 if (!locked && login_status_ == user::LOGGED_IN_LOCKED) { | 67 system_is_locked_ = locked; |
| 81 login_status_ = unlocked_login_status_; | |
| 82 unlocked_login_status_ = user::LOGGED_IN_NONE; | |
| 83 } else { | |
| 84 unlocked_login_status_ = login_status_; | |
| 85 login_status_ = user::LOGGED_IN_LOCKED; | |
| 86 } | |
| 87 | 68 |
| 88 if (locked) { | 69 if (locked) { |
| 89 animator_->StartAnimation( | 70 animator_->StartAnimation( |
| 90 internal::SessionStateAnimator::LOCK_SCREEN_CONTAINERS, | 71 internal::SessionStateAnimator::LOCK_SCREEN_CONTAINERS, |
| 91 internal::SessionStateAnimator::ANIMATION_FADE_IN); | 72 internal::SessionStateAnimator::ANIMATION_FADE_IN); |
| 92 lock_timer_.Stop(); | 73 lock_timer_.Stop(); |
| 93 lock_fail_timer_.Stop(); | 74 lock_fail_timer_.Stop(); |
| 94 | 75 |
| 95 if (shutdown_after_lock_) { | 76 if (shutdown_after_lock_) { |
| 96 shutdown_after_lock_ = false; | 77 shutdown_after_lock_ = false; |
| 97 StartLockToShutdownTimer(); | 78 StartLockToShutdownTimer(); |
| 98 } | 79 } |
| 99 } else { | 80 } else { |
| 100 animator_->StartAnimation( | 81 animator_->StartAnimation( |
| 101 internal::SessionStateAnimator::DESKTOP_BACKGROUND | | 82 internal::SessionStateAnimator::DESKTOP_BACKGROUND | |
| 102 internal::SessionStateAnimator::LAUNCHER | | 83 internal::SessionStateAnimator::LAUNCHER | |
| 103 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, | 84 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
| 104 internal::SessionStateAnimator::ANIMATION_RESTORE); | 85 internal::SessionStateAnimator::ANIMATION_RESTORE); |
| 105 animator_->DropBlackLayer(); | 86 animator_->DropBlackLayer(); |
| 106 } | 87 } |
| 107 } | 88 } |
| 108 | 89 |
| 109 void SessionStateController::OnStartingLock() { | 90 void SessionStateControllerImpl::OnStartingLock() { |
| 110 if (shutting_down_ || login_status_ == user::LOGGED_IN_LOCKED) | 91 if (shutting_down_ || system_is_locked_) |
| 111 return; | 92 return; |
| 112 | 93 |
| 113 // Ensure that the black layer is visible -- if the screen was locked via | 94 // Ensure that the black layer is visible -- if the screen was locked via |
| 114 // the wrench menu, we won't have already shown the black background | 95 // the wrench menu, we won't have already shown the black background |
| 115 // as part of the slow-close animation. | 96 // as part of the slow-close animation. |
| 116 animator_->ShowBlackLayer(); | 97 animator_->ShowBlackLayer(); |
| 117 | 98 |
| 118 animator_->StartAnimation( | 99 animator_->StartAnimation( |
| 119 internal::SessionStateAnimator::LAUNCHER, | 100 internal::SessionStateAnimator::LAUNCHER, |
| 120 internal::SessionStateAnimator::ANIMATION_HIDE); | 101 internal::SessionStateAnimator::ANIMATION_HIDE); |
| 121 | 102 |
| 122 animator_->StartAnimation( | 103 animator_->StartAnimation( |
| 123 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, | 104 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
| 124 internal::SessionStateAnimator::ANIMATION_FAST_CLOSE); | 105 internal::SessionStateAnimator::ANIMATION_FULL_CLOSE); |
| 125 | 106 |
| 126 // Hide the screen locker containers so we can make them fade in later. | 107 // Hide the screen locker containers so we can make them fade in later. |
| 127 animator_->StartAnimation( | 108 animator_->StartAnimation( |
| 128 internal::SessionStateAnimator::LOCK_SCREEN_CONTAINERS, | 109 internal::SessionStateAnimator::LOCK_SCREEN_CONTAINERS, |
| 129 internal::SessionStateAnimator::ANIMATION_HIDE); | 110 internal::SessionStateAnimator::ANIMATION_HIDE); |
| 130 } | 111 } |
| 131 | 112 |
| 132 void SessionStateController::StartLockAnimationAndLockImmediately() { | 113 void SessionStateControllerImpl::StartLockAnimationAndLockImmediately() { |
| 133 animator_->ShowBlackLayer(); | 114 animator_->ShowBlackLayer(); |
| 134 animator_->StartAnimation( | 115 animator_->StartAnimation( |
| 135 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, | 116 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
| 136 internal::SessionStateAnimator::ANIMATION_SLOW_CLOSE); | 117 internal::SessionStateAnimator::ANIMATION_PARTIAL_CLOSE); |
| 137 OnLockTimeout(); | 118 OnLockTimeout(); |
| 138 } | 119 } |
| 139 | 120 |
| 140 void SessionStateController::StartLockAnimation() { | 121 void SessionStateControllerImpl::StartLockAnimation() { |
| 141 shutdown_after_lock_ = true; | 122 shutdown_after_lock_ = true; |
| 142 | 123 |
| 143 animator_->ShowBlackLayer(); | 124 animator_->ShowBlackLayer(); |
| 144 animator_->StartAnimation( | 125 animator_->StartAnimation( |
| 145 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, | 126 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
| 146 internal::SessionStateAnimator::ANIMATION_SLOW_CLOSE); | 127 internal::SessionStateAnimator::ANIMATION_PARTIAL_CLOSE); |
| 147 StartLockTimer(); | 128 StartLockTimer(); |
| 148 } | 129 } |
| 149 | 130 |
| 150 void SessionStateController::StartShutdownAnimation() { | 131 void SessionStateControllerImpl::StartShutdownAnimation() { |
| 151 animator_->ShowBlackLayer(); | 132 animator_->ShowBlackLayer(); |
| 152 animator_->StartAnimation( | 133 animator_->StartAnimation( |
| 153 internal::SessionStateAnimator::kAllContainersMask, | 134 internal::SessionStateAnimator::kAllContainersMask, |
| 154 internal::SessionStateAnimator::ANIMATION_SLOW_CLOSE); | 135 internal::SessionStateAnimator::ANIMATION_PARTIAL_CLOSE); |
| 155 | 136 |
| 156 StartPreShutdownAnimationTimer(); | 137 StartPreShutdownAnimationTimer(); |
| 157 } | 138 } |
| 158 | 139 |
| 159 bool SessionStateController::IsEligibleForLock() { | 140 bool SessionStateControllerImpl::IsEligibleForLock() { |
| 160 return IsLoggedInAsNonGuest() && !IsLocked() && !LockRequested(); | 141 return IsLoggedInAsNonGuest() && !IsLocked() && !LockRequested(); |
| 161 } | 142 } |
| 162 | 143 |
| 163 bool SessionStateController::IsLocked() { | 144 bool SessionStateControllerImpl::IsLocked() { |
| 164 return login_status_ == user::LOGGED_IN_LOCKED; | 145 return system_is_locked_; |
| 165 } | 146 } |
| 166 | 147 |
| 167 bool SessionStateController::LockRequested() { | 148 bool SessionStateControllerImpl::LockRequested() { |
| 168 return lock_fail_timer_.IsRunning(); | 149 return lock_fail_timer_.IsRunning(); |
| 169 } | 150 } |
| 170 | 151 |
| 171 bool SessionStateController::ShutdownRequested() { | 152 bool SessionStateControllerImpl::ShutdownRequested() { |
| 172 return shutting_down_; | 153 return shutting_down_; |
| 173 } | 154 } |
| 174 | 155 |
| 175 bool SessionStateController::CanCancelLockAnimation() { | 156 bool SessionStateControllerImpl::CanCancelLockAnimation() { |
| 176 return lock_timer_.IsRunning(); | 157 return lock_timer_.IsRunning(); |
| 177 } | 158 } |
| 178 | 159 |
| 179 void SessionStateController::CancelLockAnimation() { | 160 void SessionStateControllerImpl::CancelLockAnimation() { |
| 180 if (!CanCancelLockAnimation()) | |
| 181 return; | |
| 182 shutdown_after_lock_ = false; | |
| 183 animator_->StartAnimation( | |
| 184 internal::SessionStateAnimator::kAllContainersMask, | |
| 185 internal::SessionStateAnimator::ANIMATION_UNDO_SLOW_CLOSE); | |
| 186 animator_->ScheduleDropBlackLayer(); | |
| 187 lock_timer_.Stop(); | |
| 188 } | |
| 189 | |
| 190 void SessionStateController::CancelLockWithOtherAnimation() { | |
| 191 if (!CanCancelLockAnimation()) | 161 if (!CanCancelLockAnimation()) |
| 192 return; | 162 return; |
| 193 shutdown_after_lock_ = false; | 163 shutdown_after_lock_ = false; |
| 194 animator_->StartAnimation( | 164 animator_->StartAnimation( |
| 195 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, | 165 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
| 196 internal::SessionStateAnimator::ANIMATION_UNDO_SLOW_CLOSE); | 166 internal::SessionStateAnimator::ANIMATION_UNDO_PARTIAL_CLOSE); |
| 197 animator_->ScheduleDropBlackLayer(); | 167 animator_->ScheduleDropBlackLayer(); |
| 198 lock_timer_.Stop(); | 168 lock_timer_.Stop(); |
| 199 } | 169 } |
| 200 | 170 |
| 201 bool SessionStateController::CanCancelShutdownAnimation() { | 171 bool SessionStateControllerImpl::CanCancelShutdownAnimation() { |
| 202 return pre_shutdown_timer_.IsRunning() || | 172 return pre_shutdown_timer_.IsRunning() || |
| 203 shutdown_after_lock_ || | 173 shutdown_after_lock_ || |
| 204 lock_to_shutdown_timer_.IsRunning(); | 174 lock_to_shutdown_timer_.IsRunning(); |
| 205 } | 175 } |
| 206 | 176 |
| 207 void SessionStateController::CancelShutdownAnimation() { | 177 void SessionStateControllerImpl::CancelShutdownAnimation() { |
| 208 if (!CanCancelShutdownAnimation()) | 178 if (!CanCancelShutdownAnimation()) |
| 209 return; | 179 return; |
| 210 if (lock_to_shutdown_timer_.IsRunning()) { | 180 if (lock_to_shutdown_timer_.IsRunning()) { |
| 211 lock_to_shutdown_timer_.Stop(); | 181 lock_to_shutdown_timer_.Stop(); |
| 212 return; | 182 return; |
| 213 } | 183 } |
| 214 if (shutdown_after_lock_) { | 184 if (shutdown_after_lock_) { |
| 215 shutdown_after_lock_ = false; | 185 shutdown_after_lock_ = false; |
| 216 return; | 186 return; |
| 217 } | 187 } |
| 218 | 188 |
| 219 if (login_status_ == user::LOGGED_IN_LOCKED) { | 189 if (system_is_locked_) { |
| 220 // If we've already started shutdown transition at lock screen | 190 // If we've already started shutdown transition at lock screen |
| 221 // desktop background needs to be restored immediately. | 191 // desktop background needs to be restored immediately. |
| 222 animator_->StartAnimation( | 192 animator_->StartAnimation( |
| 223 internal::SessionStateAnimator::DESKTOP_BACKGROUND, | 193 internal::SessionStateAnimator::DESKTOP_BACKGROUND, |
| 224 internal::SessionStateAnimator::ANIMATION_RESTORE); | 194 internal::SessionStateAnimator::ANIMATION_RESTORE); |
| 225 animator_->StartAnimation( | 195 animator_->StartAnimation( |
| 226 internal::SessionStateAnimator::kAllLockScreenContainersMask, | 196 internal::SessionStateAnimator::kAllLockScreenContainersMask, |
| 227 internal::SessionStateAnimator::ANIMATION_UNDO_SLOW_CLOSE); | 197 internal::SessionStateAnimator::ANIMATION_UNDO_PARTIAL_CLOSE); |
| 228 animator_->ScheduleDropBlackLayer(); | 198 animator_->ScheduleDropBlackLayer(); |
| 229 } else { | 199 } else { |
| 230 animator_->StartAnimation( | 200 animator_->StartAnimation( |
| 231 internal::SessionStateAnimator::kAllContainersMask, | 201 internal::SessionStateAnimator::kAllContainersMask, |
| 232 internal::SessionStateAnimator::ANIMATION_UNDO_SLOW_CLOSE); | 202 internal::SessionStateAnimator::ANIMATION_UNDO_PARTIAL_CLOSE); |
| 233 animator_->ScheduleDropBlackLayer(); | 203 animator_->ScheduleDropBlackLayer(); |
| 234 } | 204 } |
| 235 pre_shutdown_timer_.Stop(); | 205 pre_shutdown_timer_.Stop(); |
| 236 } | 206 } |
| 237 | 207 |
| 238 void SessionStateController::RequestShutdown() { | 208 void SessionStateControllerImpl::RequestShutdown() { |
| 239 if (!shutting_down_) | 209 if (!shutting_down_) |
| 240 animator_->ShowBlackLayer(); | 210 animator_->ShowBlackLayer(); |
| 241 RequestShutdownImpl(); | 211 RequestShutdownImpl(); |
| 242 } | 212 } |
| 243 | 213 |
| 244 void SessionStateController::RequestShutdownImpl() { | 214 void SessionStateControllerImpl::RequestShutdownImpl() { |
| 245 DCHECK(!shutting_down_); | 215 DCHECK(!shutting_down_); |
| 246 shutting_down_ = true; | 216 shutting_down_ = true; |
| 247 | 217 |
| 248 Shell* shell = ash::Shell::GetInstance(); | 218 Shell* shell = ash::Shell::GetInstance(); |
| 249 shell->env_filter()->set_cursor_hidden_by_filter(false); | 219 shell->env_filter()->set_cursor_hidden_by_filter(false); |
| 250 shell->cursor_manager()->ShowCursor(false); | 220 shell->cursor_manager()->ShowCursor(false); |
| 251 | 221 |
| 252 animator_->ShowBlackLayer(); | 222 animator_->ShowBlackLayer(); |
| 253 if (login_status_ != user::LOGGED_IN_NONE) { | 223 if (login_status_ != user::LOGGED_IN_NONE) { |
| 254 // Hide the other containers before starting the animation. | 224 // Hide the other containers before starting the animation. |
| 255 // ANIMATION_FAST_CLOSE will make the screen locker windows partially | 225 // ANIMATION_FULL_CLOSE will make the screen locker windows partially |
| 256 // transparent, and we don't want the other windows to show through. | 226 // transparent, and we don't want the other windows to show through. |
| 257 animator_->StartAnimation( | 227 animator_->StartAnimation( |
| 258 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS | | 228 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS | |
| 259 internal::SessionStateAnimator::LAUNCHER, | 229 internal::SessionStateAnimator::LAUNCHER, |
| 260 internal::SessionStateAnimator::ANIMATION_HIDE); | 230 internal::SessionStateAnimator::ANIMATION_HIDE); |
| 261 animator_->StartAnimation( | 231 animator_->StartAnimation( |
| 262 internal::SessionStateAnimator::kAllLockScreenContainersMask, | 232 internal::SessionStateAnimator::kAllLockScreenContainersMask, |
| 263 internal::SessionStateAnimator::ANIMATION_FAST_CLOSE); | 233 internal::SessionStateAnimator::ANIMATION_FULL_CLOSE); |
| 264 } else { | 234 } else { |
| 265 animator_->StartAnimation( | 235 animator_->StartAnimation( |
| 266 internal::SessionStateAnimator::kAllContainersMask, | 236 internal::SessionStateAnimator::kAllContainersMask, |
| 267 internal::SessionStateAnimator::ANIMATION_FAST_CLOSE); | 237 internal::SessionStateAnimator::ANIMATION_FULL_CLOSE); |
| 268 } | 238 } |
| 269 StartRealShutdownTimer(); | 239 StartRealShutdownTimer(); |
| 270 } | 240 } |
| 271 | 241 |
| 272 void SessionStateController::OnRootWindowHostCloseRequested( | 242 void SessionStateControllerImpl::OnRootWindowHostCloseRequested( |
| 273 const aura::RootWindow*) { | 243 const aura::RootWindow*) { |
| 274 if(Shell::GetInstance() && Shell::GetInstance()->delegate()) | 244 if(Shell::GetInstance() && Shell::GetInstance()->delegate()) |
| 275 Shell::GetInstance()->delegate()->Exit(); | 245 Shell::GetInstance()->delegate()->Exit(); |
| 276 } | 246 } |
| 277 | 247 |
| 278 bool SessionStateController::IsLoggedInAsNonGuest() const { | 248 bool SessionStateControllerImpl::IsLoggedInAsNonGuest() const { |
| 279 // TODO(mukai): think about kiosk mode. | 249 // TODO(mukai): think about kiosk mode. |
| 280 return (login_status_ != user::LOGGED_IN_NONE) && | 250 return (login_status_ != user::LOGGED_IN_NONE) && |
| 281 (login_status_ != user::LOGGED_IN_GUEST); | 251 (login_status_ != user::LOGGED_IN_GUEST); |
| 282 } | 252 } |
| 283 | 253 |
| 284 void SessionStateController::StartLockTimer() { | 254 void SessionStateControllerImpl::StartLockTimer() { |
| 285 lock_timer_.Stop(); | 255 lock_timer_.Stop(); |
| 286 lock_timer_.Start(FROM_HERE, | 256 lock_timer_.Start(FROM_HERE, |
| 287 base::TimeDelta::FromMilliseconds(kSlowCloseAnimMs), | 257 base::TimeDelta::FromMilliseconds(kSlowCloseAnimMs), |
| 288 this, &SessionStateController::OnLockTimeout); | 258 this, &SessionStateControllerImpl::OnLockTimeout); |
| 289 } | 259 } |
| 290 | 260 |
| 291 void SessionStateController::OnLockTimeout() { | 261 void SessionStateControllerImpl::OnLockTimeout() { |
| 292 delegate_->RequestLockScreen(); | 262 delegate_->RequestLockScreen(); |
| 293 lock_fail_timer_.Start( | 263 lock_fail_timer_.Start( |
| 294 FROM_HERE, | 264 FROM_HERE, |
| 295 base::TimeDelta::FromMilliseconds(kLockFailTimeoutMs), | 265 base::TimeDelta::FromMilliseconds(kLockFailTimeoutMs), |
| 296 this, &SessionStateController::OnLockFailTimeout); | 266 this, &SessionStateControllerImpl::OnLockFailTimeout); |
| 297 } | 267 } |
| 298 | 268 |
| 299 void SessionStateController::OnLockFailTimeout() { | 269 void SessionStateControllerImpl::OnLockFailTimeout() { |
| 300 DCHECK_NE(login_status_, user::LOGGED_IN_LOCKED); | 270 DCHECK(!system_is_locked_); |
| 301 // Undo lock animation. | 271 // Undo lock animation. |
| 302 animator_->StartAnimation( | 272 animator_->StartAnimation( |
| 303 internal::SessionStateAnimator::LAUNCHER | | 273 internal::SessionStateAnimator::LAUNCHER | |
| 304 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, | 274 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
| 305 internal::SessionStateAnimator::ANIMATION_RESTORE); | 275 internal::SessionStateAnimator::ANIMATION_RESTORE); |
| 306 animator_->DropBlackLayer(); | 276 animator_->DropBlackLayer(); |
| 307 } | 277 } |
| 308 | 278 |
| 309 void SessionStateController::StartLockToShutdownTimer() { | 279 void SessionStateControllerImpl::StartLockToShutdownTimer() { |
| 310 shutdown_after_lock_ = false; | 280 shutdown_after_lock_ = false; |
| 311 lock_to_shutdown_timer_.Stop(); | 281 lock_to_shutdown_timer_.Stop(); |
| 312 lock_to_shutdown_timer_.Start( | 282 lock_to_shutdown_timer_.Start( |
| 313 FROM_HERE, | 283 FROM_HERE, |
| 314 base::TimeDelta::FromMilliseconds(kLockToShutdownTimeoutMs), | 284 base::TimeDelta::FromMilliseconds(kLockToShutdownTimeoutMs), |
| 315 this, &SessionStateController::OnLockToShutdownTimeout); | 285 this, &SessionStateControllerImpl::OnLockToShutdownTimeout); |
| 316 } | 286 } |
| 317 | 287 |
| 318 | 288 |
| 319 void SessionStateController::OnLockToShutdownTimeout() { | 289 void SessionStateControllerImpl::OnLockToShutdownTimeout() { |
| 320 DCHECK_EQ(login_status_, user::LOGGED_IN_LOCKED); | 290 DCHECK(system_is_locked_); |
| 321 StartShutdownAnimation(); | 291 StartShutdownAnimation(); |
| 322 } | 292 } |
| 323 | 293 |
| 324 void SessionStateController::StartPreShutdownAnimationTimer() { | 294 void SessionStateControllerImpl::StartPreShutdownAnimationTimer() { |
| 325 pre_shutdown_timer_.Stop(); | 295 pre_shutdown_timer_.Stop(); |
| 326 pre_shutdown_timer_.Start( | 296 pre_shutdown_timer_.Start( |
| 327 FROM_HERE, | 297 FROM_HERE, |
| 328 base::TimeDelta::FromMilliseconds(kShutdownTimeoutMs), | 298 base::TimeDelta::FromMilliseconds(kShutdownTimeoutMs), |
| 329 this, &SessionStateController::OnPreShutdownAnimationTimeout); | 299 this, &SessionStateControllerImpl::OnPreShutdownAnimationTimeout); |
| 330 } | 300 } |
| 331 | 301 |
| 332 void SessionStateController::OnPreShutdownAnimationTimeout() { | 302 void SessionStateControllerImpl::OnPreShutdownAnimationTimeout() { |
| 333 if (!shutting_down_) | 303 if (!shutting_down_) |
| 334 RequestShutdownImpl(); | 304 RequestShutdownImpl(); |
| 335 } | 305 } |
| 336 | 306 |
| 337 void SessionStateController::StartRealShutdownTimer() { | 307 void SessionStateControllerImpl::StartRealShutdownTimer() { |
| 338 real_shutdown_timer_.Start( | 308 real_shutdown_timer_.Start( |
| 339 FROM_HERE, | 309 FROM_HERE, |
| 340 base::TimeDelta::FromMilliseconds(kFastCloseAnimMs + | 310 base::TimeDelta::FromMilliseconds(kFastCloseAnimMs + |
| 341 kShutdownRequestDelayMs), | 311 kShutdownRequestDelayMs), |
| 342 this, &SessionStateController::OnRealShutdownTimeout); | 312 this, &SessionStateControllerImpl::OnRealShutdownTimeout); |
| 343 } | 313 } |
| 344 | 314 |
| 345 void SessionStateController::OnRealShutdownTimeout() { | 315 void SessionStateControllerImpl::OnRealShutdownTimeout() { |
| 346 DCHECK(shutting_down_); | 316 DCHECK(shutting_down_); |
| 347 #if defined(OS_CHROMEOS) | 317 #if defined(OS_CHROMEOS) |
| 348 if (!base::chromeos::IsRunningOnChromeOS()) { | 318 if (!base::chromeos::IsRunningOnChromeOS()) { |
| 349 ShellDelegate* delegate = Shell::GetInstance()->delegate(); | 319 ShellDelegate* delegate = Shell::GetInstance()->delegate(); |
| 350 if (delegate) { | 320 if (delegate) { |
| 351 delegate->Exit(); | 321 delegate->Exit(); |
| 352 return; | 322 return; |
| 353 } | 323 } |
| 354 } | 324 } |
| 355 #endif | 325 #endif |
| 356 delegate_->RequestShutdown(); | 326 delegate_->RequestShutdown(); |
| 357 } | 327 } |
| 358 | 328 |
| 359 } // namespace ash | 329 } // namespace ash |
| OLD | NEW |