| 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_impl2.h" | 5 #include "ash/wm/lock_state_controller_impl2.h" |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/cancel_mode.h" | 8 #include "ash/cancel_mode.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/shell_delegate.h" | 10 #include "ash/shell_delegate.h" |
| 11 #include "ash/shell_window_ids.h" | 11 #include "ash/shell_window_ids.h" |
| 12 #include "ash/wm/session_state_animator.h" | 12 #include "ash/wm/session_state_animator.h" |
| 13 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/timer.h" | 15 #include "base/timer.h" |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 // Number of sequences either ended or aborted. | 128 // Number of sequences either ended or aborted. |
| 129 int sequences_completed_; | 129 int sequences_completed_; |
| 130 | 130 |
| 131 bool paused_; | 131 bool paused_; |
| 132 | 132 |
| 133 DISALLOW_COPY_AND_ASSIGN(AnimationFinishedObserver); | 133 DISALLOW_COPY_AND_ASSIGN(AnimationFinishedObserver); |
| 134 }; | 134 }; |
| 135 | 135 |
| 136 } // namespace | 136 } // namespace |
| 137 | 137 |
| 138 SessionStateControllerImpl2::TestApi::TestApi( | 138 LockStateControllerImpl2::TestApi::TestApi( |
| 139 SessionStateControllerImpl2* controller) | 139 LockStateControllerImpl2* controller) |
| 140 : controller_(controller) { | 140 : controller_(controller) { |
| 141 } | 141 } |
| 142 | 142 |
| 143 SessionStateControllerImpl2::TestApi::~TestApi() { | 143 LockStateControllerImpl2::TestApi::~TestApi() { |
| 144 } | 144 } |
| 145 | 145 |
| 146 SessionStateControllerImpl2::SessionStateControllerImpl2() | 146 LockStateControllerImpl2::LockStateControllerImpl2() |
| 147 : login_status_(user::LOGGED_IN_NONE), | 147 : login_status_(user::LOGGED_IN_NONE), |
| 148 system_is_locked_(false), | 148 system_is_locked_(false), |
| 149 shutting_down_(false), | 149 shutting_down_(false), |
| 150 shutdown_after_lock_(false), | 150 shutdown_after_lock_(false), |
| 151 animating_lock_(false), | 151 animating_lock_(false), |
| 152 can_cancel_lock_animation_(false) { | 152 can_cancel_lock_animation_(false) { |
| 153 Shell::GetPrimaryRootWindow()->AddRootWindowObserver(this); | 153 Shell::GetPrimaryRootWindow()->AddRootWindowObserver(this); |
| 154 } | 154 } |
| 155 | 155 |
| 156 SessionStateControllerImpl2::~SessionStateControllerImpl2() { | 156 LockStateControllerImpl2::~LockStateControllerImpl2() { |
| 157 Shell::GetPrimaryRootWindow()->RemoveRootWindowObserver(this); | 157 Shell::GetPrimaryRootWindow()->RemoveRootWindowObserver(this); |
| 158 } | 158 } |
| 159 | 159 |
| 160 void SessionStateControllerImpl2::OnLoginStateChanged( | 160 void LockStateControllerImpl2::OnLoginStateChanged( |
| 161 user::LoginStatus status) { | 161 user::LoginStatus status) { |
| 162 if (status != user::LOGGED_IN_LOCKED) | 162 if (status != user::LOGGED_IN_LOCKED) |
| 163 login_status_ = status; | 163 login_status_ = status; |
| 164 system_is_locked_ = (status == user::LOGGED_IN_LOCKED); | 164 system_is_locked_ = (status == user::LOGGED_IN_LOCKED); |
| 165 } | 165 } |
| 166 | 166 |
| 167 void SessionStateControllerImpl2::OnAppTerminating() { | 167 void LockStateControllerImpl2::OnAppTerminating() { |
| 168 // If we hear that Chrome is exiting but didn't request it ourselves, all we | 168 // If we hear that Chrome is exiting but didn't request it ourselves, all we |
| 169 // can really hope for is that we'll have time to clear the screen. | 169 // can really hope for is that we'll have time to clear the screen. |
| 170 // This is also the case when the user signs off. | 170 // This is also the case when the user signs off. |
| 171 if (!shutting_down_) { | 171 if (!shutting_down_) { |
| 172 shutting_down_ = true; | 172 shutting_down_ = true; |
| 173 Shell* shell = ash::Shell::GetInstance(); | 173 Shell* shell = ash::Shell::GetInstance(); |
| 174 shell->env_filter()->set_cursor_hidden_by_filter(false); | 174 shell->env_filter()->set_cursor_hidden_by_filter(false); |
| 175 shell->cursor_manager()->HideCursor(); | 175 shell->cursor_manager()->HideCursor(); |
| 176 animator_->StartAnimation( | 176 animator_->StartAnimation( |
| 177 internal::SessionStateAnimator::kAllContainersMask, | 177 internal::SessionStateAnimator::kAllContainersMask, |
| 178 internal::SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY, | 178 internal::SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY, |
| 179 internal::SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); | 179 internal::SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); |
| 180 } | 180 } |
| 181 } | 181 } |
| 182 | 182 |
| 183 void SessionStateControllerImpl2::OnLockStateChanged(bool locked) { | 183 void LockStateControllerImpl2::OnLockStateChanged(bool locked) { |
| 184 if (shutting_down_ || (system_is_locked_ == locked)) | 184 if (shutting_down_ || (system_is_locked_ == locked)) |
| 185 return; | 185 return; |
| 186 | 186 |
| 187 system_is_locked_ = locked; | 187 system_is_locked_ = locked; |
| 188 | 188 |
| 189 if (locked) { | 189 if (locked) { |
| 190 StartPostLockAnimation(); | 190 StartPostLockAnimation(); |
| 191 lock_fail_timer_.Stop(); | 191 lock_fail_timer_.Stop(); |
| 192 } else { | 192 } else { |
| 193 StartUnlockAnimationAfterUIDestroyed(); | 193 StartUnlockAnimationAfterUIDestroyed(); |
| 194 } | 194 } |
| 195 } | 195 } |
| 196 | 196 |
| 197 void SessionStateControllerImpl2::SetLockScreenDisplayedCallback( | 197 void LockStateControllerImpl2::SetLockScreenDisplayedCallback( |
| 198 base::Closure& callback) { | 198 base::Closure& callback) { |
| 199 lock_screen_displayed_callback_ = callback; | 199 lock_screen_displayed_callback_ = callback; |
| 200 } | 200 } |
| 201 | 201 |
| 202 void SessionStateControllerImpl2::OnStartingLock() { | 202 void LockStateControllerImpl2::OnStartingLock() { |
| 203 if (shutting_down_ || system_is_locked_) | 203 if (shutting_down_ || system_is_locked_) |
| 204 return; | 204 return; |
| 205 if (animating_lock_) | 205 if (animating_lock_) |
| 206 return; | 206 return; |
| 207 StartImmediatePreLockAnimation(false /* request_lock_on_completion */); | 207 StartImmediatePreLockAnimation(false /* request_lock_on_completion */); |
| 208 } | 208 } |
| 209 | 209 |
| 210 void SessionStateControllerImpl2::StartLockAnimationAndLockImmediately() { | 210 void LockStateControllerImpl2::StartLockAnimationAndLockImmediately() { |
| 211 if (animating_lock_) | 211 if (animating_lock_) |
| 212 return; | 212 return; |
| 213 StartImmediatePreLockAnimation(true /* request_lock_on_completion */); | 213 StartImmediatePreLockAnimation(true /* request_lock_on_completion */); |
| 214 } | 214 } |
| 215 | 215 |
| 216 void SessionStateControllerImpl2::StartLockAnimation(bool shutdown_after_lock) { | 216 void LockStateControllerImpl2::StartLockAnimation( |
| 217 bool shutdown_after_lock) { |
| 217 if (animating_lock_) | 218 if (animating_lock_) |
| 218 return; | 219 return; |
| 219 shutdown_after_lock_ = shutdown_after_lock; | 220 shutdown_after_lock_ = shutdown_after_lock; |
| 220 can_cancel_lock_animation_ = true; | 221 can_cancel_lock_animation_ = true; |
| 221 | 222 |
| 222 StartCancellablePreLockAnimation(); | 223 StartCancellablePreLockAnimation(); |
| 223 } | 224 } |
| 224 | 225 |
| 225 bool SessionStateControllerImpl2::LockRequested() { | 226 bool LockStateControllerImpl2::LockRequested() { |
| 226 return lock_fail_timer_.IsRunning(); | 227 return lock_fail_timer_.IsRunning(); |
| 227 } | 228 } |
| 228 | 229 |
| 229 bool SessionStateControllerImpl2::ShutdownRequested() { | 230 bool LockStateControllerImpl2::ShutdownRequested() { |
| 230 return shutting_down_; | 231 return shutting_down_; |
| 231 } | 232 } |
| 232 | 233 |
| 233 bool SessionStateControllerImpl2::CanCancelLockAnimation() { | 234 bool LockStateControllerImpl2::CanCancelLockAnimation() { |
| 234 return can_cancel_lock_animation_; | 235 return can_cancel_lock_animation_; |
| 235 } | 236 } |
| 236 | 237 |
| 237 void SessionStateControllerImpl2::CancelLockAnimation() { | 238 void LockStateControllerImpl2::CancelLockAnimation() { |
| 238 if (!CanCancelLockAnimation()) | 239 if (!CanCancelLockAnimation()) |
| 239 return; | 240 return; |
| 240 shutdown_after_lock_ = false; | 241 shutdown_after_lock_ = false; |
| 241 animating_lock_ = false; | 242 animating_lock_ = false; |
| 242 CancelPreLockAnimation(); | 243 CancelPreLockAnimation(); |
| 243 } | 244 } |
| 244 | 245 |
| 245 bool SessionStateControllerImpl2::CanCancelShutdownAnimation() { | 246 bool LockStateControllerImpl2::CanCancelShutdownAnimation() { |
| 246 return pre_shutdown_timer_.IsRunning() || | 247 return pre_shutdown_timer_.IsRunning() || |
| 247 shutdown_after_lock_ || | 248 shutdown_after_lock_ || |
| 248 lock_to_shutdown_timer_.IsRunning(); | 249 lock_to_shutdown_timer_.IsRunning(); |
| 249 } | 250 } |
| 250 | 251 |
| 251 void SessionStateControllerImpl2::StartShutdownAnimation() { | 252 void LockStateControllerImpl2::StartShutdownAnimation() { |
| 252 StartCancellableShutdownAnimation(); | 253 StartCancellableShutdownAnimation(); |
| 253 } | 254 } |
| 254 | 255 |
| 255 void SessionStateControllerImpl2::CancelShutdownAnimation() { | 256 void LockStateControllerImpl2::CancelShutdownAnimation() { |
| 256 if (!CanCancelShutdownAnimation()) | 257 if (!CanCancelShutdownAnimation()) |
| 257 return; | 258 return; |
| 258 if (lock_to_shutdown_timer_.IsRunning()) { | 259 if (lock_to_shutdown_timer_.IsRunning()) { |
| 259 lock_to_shutdown_timer_.Stop(); | 260 lock_to_shutdown_timer_.Stop(); |
| 260 return; | 261 return; |
| 261 } | 262 } |
| 262 if (shutdown_after_lock_) { | 263 if (shutdown_after_lock_) { |
| 263 shutdown_after_lock_ = false; | 264 shutdown_after_lock_ = false; |
| 264 return; | 265 return; |
| 265 } | 266 } |
| 266 | 267 |
| 267 animator_->StartGlobalAnimation( | 268 animator_->StartGlobalAnimation( |
| 268 internal::SessionStateAnimator::ANIMATION_UNDO_GRAYSCALE_BRIGHTNESS, | 269 internal::SessionStateAnimator::ANIMATION_UNDO_GRAYSCALE_BRIGHTNESS, |
| 269 internal::SessionStateAnimator::ANIMATION_SPEED_REVERT_SHUTDOWN); | 270 internal::SessionStateAnimator::ANIMATION_SPEED_REVERT_SHUTDOWN); |
| 270 pre_shutdown_timer_.Stop(); | 271 pre_shutdown_timer_.Stop(); |
| 271 } | 272 } |
| 272 | 273 |
| 273 void SessionStateControllerImpl2::RequestShutdown() { | 274 void LockStateControllerImpl2::RequestShutdown() { |
| 274 if (!shutting_down_) | 275 if (!shutting_down_) |
| 275 RequestShutdownImpl(); | 276 RequestShutdownImpl(); |
| 276 } | 277 } |
| 277 | 278 |
| 278 void SessionStateControllerImpl2::RequestShutdownImpl() { | 279 void LockStateControllerImpl2::RequestShutdownImpl() { |
| 279 DCHECK(!shutting_down_); | 280 DCHECK(!shutting_down_); |
| 280 shutting_down_ = true; | 281 shutting_down_ = true; |
| 281 | 282 |
| 282 Shell* shell = ash::Shell::GetInstance(); | 283 Shell* shell = ash::Shell::GetInstance(); |
| 283 shell->env_filter()->set_cursor_hidden_by_filter(false); | 284 shell->env_filter()->set_cursor_hidden_by_filter(false); |
| 284 shell->cursor_manager()->HideCursor(); | 285 shell->cursor_manager()->HideCursor(); |
| 285 | 286 |
| 286 StartShutdownAnimationImpl(); | 287 StartShutdownAnimationImpl(); |
| 287 } | 288 } |
| 288 | 289 |
| 289 void SessionStateControllerImpl2::OnRootWindowHostCloseRequested( | 290 void LockStateControllerImpl2::OnRootWindowHostCloseRequested( |
| 290 const aura::RootWindow*) { | 291 const aura::RootWindow*) { |
| 291 Shell::GetInstance()->delegate()->Exit(); | 292 Shell::GetInstance()->delegate()->Exit(); |
| 292 } | 293 } |
| 293 | 294 |
| 294 void SessionStateControllerImpl2::OnLockFailTimeout() { | 295 void LockStateControllerImpl2::OnLockFailTimeout() { |
| 295 DCHECK(!system_is_locked_); | 296 DCHECK(!system_is_locked_); |
| 296 // Undo lock animation. | 297 // Undo lock animation. |
| 297 StartUnlockAnimationAfterUIDestroyed(); | 298 StartUnlockAnimationAfterUIDestroyed(); |
| 298 } | 299 } |
| 299 | 300 |
| 300 void SessionStateControllerImpl2::StartLockToShutdownTimer() { | 301 void LockStateControllerImpl2::StartLockToShutdownTimer() { |
| 301 shutdown_after_lock_ = false; | 302 shutdown_after_lock_ = false; |
| 302 lock_to_shutdown_timer_.Stop(); | 303 lock_to_shutdown_timer_.Stop(); |
| 303 lock_to_shutdown_timer_.Start( | 304 lock_to_shutdown_timer_.Start( |
| 304 FROM_HERE, | 305 FROM_HERE, |
| 305 base::TimeDelta::FromMilliseconds(kLockToShutdownTimeoutMs), | 306 base::TimeDelta::FromMilliseconds(kLockToShutdownTimeoutMs), |
| 306 this, &SessionStateControllerImpl2::OnLockToShutdownTimeout); | 307 this, &LockStateControllerImpl2::OnLockToShutdownTimeout); |
| 307 } | 308 } |
| 308 | 309 |
| 309 void SessionStateControllerImpl2::OnLockToShutdownTimeout() { | 310 void LockStateControllerImpl2::OnLockToShutdownTimeout() { |
| 310 DCHECK(system_is_locked_); | 311 DCHECK(system_is_locked_); |
| 311 StartCancellableShutdownAnimation(); | 312 StartCancellableShutdownAnimation(); |
| 312 } | 313 } |
| 313 | 314 |
| 314 void SessionStateControllerImpl2::StartCancellableShutdownAnimation() { | 315 void LockStateControllerImpl2::StartCancellableShutdownAnimation() { |
| 315 Shell* shell = ash::Shell::GetInstance(); | 316 Shell* shell = ash::Shell::GetInstance(); |
| 316 // Hide cursor, but let it reappear if the mouse moves. | 317 // Hide cursor, but let it reappear if the mouse moves. |
| 317 shell->env_filter()->set_cursor_hidden_by_filter(true); | 318 shell->env_filter()->set_cursor_hidden_by_filter(true); |
| 318 shell->cursor_manager()->HideCursor(); | 319 shell->cursor_manager()->HideCursor(); |
| 319 | 320 |
| 320 animator_->StartGlobalAnimation( | 321 animator_->StartGlobalAnimation( |
| 321 internal::SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS, | 322 internal::SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS, |
| 322 internal::SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); | 323 internal::SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); |
| 323 StartPreShutdownAnimationTimer(); | 324 StartPreShutdownAnimationTimer(); |
| 324 } | 325 } |
| 325 | 326 |
| 326 void SessionStateControllerImpl2::StartShutdownAnimationImpl() { | 327 void LockStateControllerImpl2::StartShutdownAnimationImpl() { |
| 327 animator_->StartGlobalAnimation( | 328 animator_->StartGlobalAnimation( |
| 328 internal::SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS, | 329 internal::SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS, |
| 329 internal::SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); | 330 internal::SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); |
| 330 StartRealShutdownTimer(true); | 331 StartRealShutdownTimer(true); |
| 331 } | 332 } |
| 332 | 333 |
| 333 void SessionStateControllerImpl2::StartPreShutdownAnimationTimer() { | 334 void LockStateControllerImpl2::StartPreShutdownAnimationTimer() { |
| 334 pre_shutdown_timer_.Stop(); | 335 pre_shutdown_timer_.Stop(); |
| 335 pre_shutdown_timer_.Start( | 336 pre_shutdown_timer_.Start( |
| 336 FROM_HERE, | 337 FROM_HERE, |
| 337 animator_-> | 338 animator_-> |
| 338 GetDuration(internal::SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN), | 339 GetDuration(internal::SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN), |
| 339 this, | 340 this, |
| 340 &SessionStateControllerImpl2::OnPreShutdownAnimationTimeout); | 341 &LockStateControllerImpl2::OnPreShutdownAnimationTimeout); |
| 341 } | 342 } |
| 342 | 343 |
| 343 void SessionStateControllerImpl2::OnPreShutdownAnimationTimeout() { | 344 void LockStateControllerImpl2::OnPreShutdownAnimationTimeout() { |
| 344 shutting_down_ = true; | 345 shutting_down_ = true; |
| 345 | 346 |
| 346 Shell* shell = ash::Shell::GetInstance(); | 347 Shell* shell = ash::Shell::GetInstance(); |
| 347 shell->env_filter()->set_cursor_hidden_by_filter(false); | 348 shell->env_filter()->set_cursor_hidden_by_filter(false); |
| 348 shell->cursor_manager()->HideCursor(); | 349 shell->cursor_manager()->HideCursor(); |
| 349 | 350 |
| 350 StartRealShutdownTimer(false); | 351 StartRealShutdownTimer(false); |
| 351 } | 352 } |
| 352 | 353 |
| 353 void SessionStateControllerImpl2::StartRealShutdownTimer( | 354 void LockStateControllerImpl2::StartRealShutdownTimer( |
| 354 bool with_animation_time) { | 355 bool with_animation_time) { |
| 355 base::TimeDelta duration = | 356 base::TimeDelta duration = |
| 356 base::TimeDelta::FromMilliseconds(kShutdownRequestDelayMs); | 357 base::TimeDelta::FromMilliseconds(kShutdownRequestDelayMs); |
| 357 if (with_animation_time) { | 358 if (with_animation_time) { |
| 358 duration += animator_->GetDuration( | 359 duration += animator_->GetDuration( |
| 359 internal::SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); | 360 internal::SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); |
| 360 } | 361 } |
| 361 real_shutdown_timer_.Start( | 362 real_shutdown_timer_.Start( |
| 362 FROM_HERE, | 363 FROM_HERE, |
| 363 duration, | 364 duration, |
| 364 this, | 365 this, |
| 365 &SessionStateControllerImpl2::OnRealShutdownTimeout); | 366 &LockStateControllerImpl2::OnRealShutdownTimeout); |
| 366 } | 367 } |
| 367 | 368 |
| 368 void SessionStateControllerImpl2::OnRealShutdownTimeout() { | 369 void LockStateControllerImpl2::OnRealShutdownTimeout() { |
| 369 DCHECK(shutting_down_); | 370 DCHECK(shutting_down_); |
| 370 #if defined(OS_CHROMEOS) | 371 #if defined(OS_CHROMEOS) |
| 371 if (!base::chromeos::IsRunningOnChromeOS()) { | 372 if (!base::chromeos::IsRunningOnChromeOS()) { |
| 372 ShellDelegate* delegate = Shell::GetInstance()->delegate(); | 373 ShellDelegate* delegate = Shell::GetInstance()->delegate(); |
| 373 if (delegate) { | 374 if (delegate) { |
| 374 delegate->Exit(); | 375 delegate->Exit(); |
| 375 return; | 376 return; |
| 376 } | 377 } |
| 377 } | 378 } |
| 378 #endif | 379 #endif |
| 379 Shell::GetInstance()->delegate()->RecordUserMetricsAction( | 380 Shell::GetInstance()->delegate()->RecordUserMetricsAction( |
| 380 UMA_ACCEL_SHUT_DOWN_POWER_BUTTON); | 381 UMA_ACCEL_SHUT_DOWN_POWER_BUTTON); |
| 381 delegate_->RequestShutdown(); | 382 delegate_->RequestShutdown(); |
| 382 } | 383 } |
| 383 | 384 |
| 384 void SessionStateControllerImpl2::OnLockScreenHide( | 385 void LockStateControllerImpl2::OnLockScreenHide( |
| 385 base::Callback<void(void)>& callback) { | 386 base::Callback<void(void)>& callback) { |
| 386 StartUnlockAnimationBeforeUIDestroyed(callback); | 387 StartUnlockAnimationBeforeUIDestroyed(callback); |
| 387 } | 388 } |
| 388 | 389 |
| 389 void SessionStateControllerImpl2::LockAnimationCancelled() { | 390 void LockStateControllerImpl2::LockAnimationCancelled() { |
| 390 can_cancel_lock_animation_ = false; | 391 can_cancel_lock_animation_ = false; |
| 391 RestoreUnlockedProperties(); | 392 RestoreUnlockedProperties(); |
| 392 } | 393 } |
| 393 | 394 |
| 394 void SessionStateControllerImpl2::PreLockAnimationFinished(bool request_lock) { | 395 void LockStateControllerImpl2::PreLockAnimationFinished( |
| 396 bool request_lock) { |
| 395 can_cancel_lock_animation_ = false; | 397 can_cancel_lock_animation_ = false; |
| 396 | 398 |
| 397 if (request_lock) { | 399 if (request_lock) { |
| 398 Shell::GetInstance()->delegate()->RecordUserMetricsAction( | 400 Shell::GetInstance()->delegate()->RecordUserMetricsAction( |
| 399 shutdown_after_lock_ ? | 401 shutdown_after_lock_ ? |
| 400 UMA_ACCEL_LOCK_SCREEN_POWER_BUTTON : | 402 UMA_ACCEL_LOCK_SCREEN_POWER_BUTTON : |
| 401 UMA_ACCEL_LOCK_SCREEN_LOCK_BUTTON); | 403 UMA_ACCEL_LOCK_SCREEN_LOCK_BUTTON); |
| 402 delegate_->RequestLockScreen(); | 404 delegate_->RequestLockScreen(); |
| 403 } | 405 } |
| 404 | 406 |
| 405 lock_fail_timer_.Start( | 407 lock_fail_timer_.Start( |
| 406 FROM_HERE, | 408 FROM_HERE, |
| 407 base::TimeDelta::FromMilliseconds(kLockFailTimeoutMs), | 409 base::TimeDelta::FromMilliseconds(kLockFailTimeoutMs), |
| 408 this, | 410 this, |
| 409 &SessionStateControllerImpl2::OnLockFailTimeout); | 411 &LockStateControllerImpl2::OnLockFailTimeout); |
| 410 } | 412 } |
| 411 | 413 |
| 412 void SessionStateControllerImpl2::PostLockAnimationFinished() { | 414 void LockStateControllerImpl2::PostLockAnimationFinished() { |
| 413 animating_lock_ = false; | 415 animating_lock_ = false; |
| 414 | 416 |
| 415 FOR_EACH_OBSERVER(SessionStateObserver, observers_, | 417 FOR_EACH_OBSERVER(LockStateObserver, observers_, |
| 416 OnSessionStateEvent( | 418 OnLockStateEvent(LockStateObserver::EVENT_LOCK_ANIMATION_FINISHED)); |
| 417 SessionStateObserver::EVENT_LOCK_ANIMATION_FINISHED)); | |
| 418 if (!lock_screen_displayed_callback_.is_null()) { | 419 if (!lock_screen_displayed_callback_.is_null()) { |
| 419 lock_screen_displayed_callback_.Run(); | 420 lock_screen_displayed_callback_.Run(); |
| 420 lock_screen_displayed_callback_.Reset(); | 421 lock_screen_displayed_callback_.Reset(); |
| 421 } | 422 } |
| 422 if (shutdown_after_lock_) { | 423 if (shutdown_after_lock_) { |
| 423 shutdown_after_lock_ = false; | 424 shutdown_after_lock_ = false; |
| 424 StartLockToShutdownTimer(); | 425 StartLockToShutdownTimer(); |
| 425 } | 426 } |
| 426 } | 427 } |
| 427 | 428 |
| 428 void SessionStateControllerImpl2::UnlockAnimationAfterUIDestroyedFinished() { | 429 void LockStateControllerImpl2:: |
| 430 UnlockAnimationAfterUIDestroyedFinished() { |
| 429 RestoreUnlockedProperties(); | 431 RestoreUnlockedProperties(); |
| 430 } | 432 } |
| 431 | 433 |
| 432 void SessionStateControllerImpl2::StartImmediatePreLockAnimation( | 434 void LockStateControllerImpl2::StartImmediatePreLockAnimation( |
| 433 bool request_lock_on_completion) { | 435 bool request_lock_on_completion) { |
| 434 animating_lock_ = true; | 436 animating_lock_ = true; |
| 435 | 437 |
| 436 StoreUnlockedProperties(); | 438 StoreUnlockedProperties(); |
| 437 | 439 |
| 438 base::Closure next_animation_starter = | 440 base::Closure next_animation_starter = |
| 439 base::Bind(&SessionStateControllerImpl2::PreLockAnimationFinished, | 441 base::Bind(&LockStateControllerImpl2::PreLockAnimationFinished, |
| 440 base::Unretained(this), request_lock_on_completion); | 442 base::Unretained(this), request_lock_on_completion); |
| 441 AnimationFinishedObserver* observer = | 443 AnimationFinishedObserver* observer = |
| 442 new AnimationFinishedObserver(next_animation_starter); | 444 new AnimationFinishedObserver(next_animation_starter); |
| 443 | 445 |
| 444 observer->Pause(); | 446 observer->Pause(); |
| 445 | 447 |
| 446 animator_->StartAnimationWithObserver( | 448 animator_->StartAnimationWithObserver( |
| 447 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, | 449 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
| 448 internal::SessionStateAnimator::ANIMATION_LIFT, | 450 internal::SessionStateAnimator::ANIMATION_LIFT, |
| 449 internal::SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, | 451 internal::SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, |
| 450 observer); | 452 observer); |
| 451 animator_->StartAnimationWithObserver( | 453 animator_->StartAnimationWithObserver( |
| 452 internal::SessionStateAnimator::LAUNCHER, | 454 internal::SessionStateAnimator::LAUNCHER, |
| 453 internal::SessionStateAnimator::ANIMATION_FADE_OUT, | 455 internal::SessionStateAnimator::ANIMATION_FADE_OUT, |
| 454 internal::SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, | 456 internal::SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, |
| 455 observer); | 457 observer); |
| 456 // Hide the screen locker containers so we can raise them later. | 458 // Hide the screen locker containers so we can raise them later. |
| 457 animator_->StartAnimation( | 459 animator_->StartAnimation( |
| 458 internal::SessionStateAnimator::LOCK_SCREEN_CONTAINERS, | 460 internal::SessionStateAnimator::LOCK_SCREEN_CONTAINERS, |
| 459 internal::SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY, | 461 internal::SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY, |
| 460 internal::SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); | 462 internal::SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); |
| 461 AnimateBackgroundAppearanceIfNecessary( | 463 AnimateBackgroundAppearanceIfNecessary( |
| 462 internal::SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, | 464 internal::SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, |
| 463 observer); | 465 observer); |
| 464 | 466 |
| 465 observer->Unpause(); | 467 observer->Unpause(); |
| 466 | 468 |
| 467 DispatchCancelMode(); | 469 DispatchCancelMode(); |
| 468 FOR_EACH_OBSERVER(SessionStateObserver, observers_, | 470 FOR_EACH_OBSERVER(LockStateObserver, observers_, |
| 469 OnSessionStateEvent(SessionStateObserver::EVENT_LOCK_ANIMATION_STARTED)); | 471 OnLockStateEvent(LockStateObserver::EVENT_LOCK_ANIMATION_STARTED)); |
| 470 } | 472 } |
| 471 | 473 |
| 472 void SessionStateControllerImpl2::StartCancellablePreLockAnimation() { | 474 void LockStateControllerImpl2::StartCancellablePreLockAnimation() { |
| 473 animating_lock_ = true; | 475 animating_lock_ = true; |
| 474 StoreUnlockedProperties(); | 476 StoreUnlockedProperties(); |
| 475 | 477 |
| 476 base::Closure next_animation_starter = | 478 base::Closure next_animation_starter = |
| 477 base::Bind(&SessionStateControllerImpl2::PreLockAnimationFinished, | 479 base::Bind(&LockStateControllerImpl2::PreLockAnimationFinished, |
| 478 base::Unretained(this), true /* request_lock */); | 480 base::Unretained(this), true /* request_lock */); |
| 479 AnimationFinishedObserver* observer = | 481 AnimationFinishedObserver* observer = |
| 480 new AnimationFinishedObserver(next_animation_starter); | 482 new AnimationFinishedObserver(next_animation_starter); |
| 481 | 483 |
| 482 observer->Pause(); | 484 observer->Pause(); |
| 483 | 485 |
| 484 animator_->StartAnimationWithObserver( | 486 animator_->StartAnimationWithObserver( |
| 485 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, | 487 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
| 486 internal::SessionStateAnimator::ANIMATION_LIFT, | 488 internal::SessionStateAnimator::ANIMATION_LIFT, |
| 487 internal::SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, | 489 internal::SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, |
| 488 observer); | 490 observer); |
| 489 animator_->StartAnimationWithObserver( | 491 animator_->StartAnimationWithObserver( |
| 490 internal::SessionStateAnimator::LAUNCHER, | 492 internal::SessionStateAnimator::LAUNCHER, |
| 491 internal::SessionStateAnimator::ANIMATION_FADE_OUT, | 493 internal::SessionStateAnimator::ANIMATION_FADE_OUT, |
| 492 internal::SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, | 494 internal::SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, |
| 493 observer); | 495 observer); |
| 494 // Hide the screen locker containers so we can raise them later. | 496 // Hide the screen locker containers so we can raise them later. |
| 495 animator_->StartAnimation( | 497 animator_->StartAnimation( |
| 496 internal::SessionStateAnimator::LOCK_SCREEN_CONTAINERS, | 498 internal::SessionStateAnimator::LOCK_SCREEN_CONTAINERS, |
| 497 internal::SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY, | 499 internal::SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY, |
| 498 internal::SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); | 500 internal::SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); |
| 499 AnimateBackgroundAppearanceIfNecessary( | 501 AnimateBackgroundAppearanceIfNecessary( |
| 500 internal::SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, | 502 internal::SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, |
| 501 observer); | 503 observer); |
| 502 | 504 |
| 503 DispatchCancelMode(); | 505 DispatchCancelMode(); |
| 504 FOR_EACH_OBSERVER(SessionStateObserver, observers_, | 506 FOR_EACH_OBSERVER(LockStateObserver, observers_, |
| 505 OnSessionStateEvent( | 507 OnLockStateEvent(LockStateObserver::EVENT_PRELOCK_ANIMATION_STARTED)); |
| 506 SessionStateObserver::EVENT_PRELOCK_ANIMATION_STARTED)); | |
| 507 observer->Unpause(); | 508 observer->Unpause(); |
| 508 } | 509 } |
| 509 | 510 |
| 510 void SessionStateControllerImpl2::CancelPreLockAnimation() { | 511 void LockStateControllerImpl2::CancelPreLockAnimation() { |
| 511 base::Closure next_animation_starter = | 512 base::Closure next_animation_starter = |
| 512 base::Bind(&SessionStateControllerImpl2::LockAnimationCancelled, | 513 base::Bind(&LockStateControllerImpl2::LockAnimationCancelled, |
| 513 base::Unretained(this)); | 514 base::Unretained(this)); |
| 514 AnimationFinishedObserver* observer = | 515 AnimationFinishedObserver* observer = |
| 515 new AnimationFinishedObserver(next_animation_starter); | 516 new AnimationFinishedObserver(next_animation_starter); |
| 516 | 517 |
| 517 observer->Pause(); | 518 observer->Pause(); |
| 518 | 519 |
| 519 animator_->StartAnimationWithObserver( | 520 animator_->StartAnimationWithObserver( |
| 520 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, | 521 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
| 521 internal::SessionStateAnimator::ANIMATION_UNDO_LIFT, | 522 internal::SessionStateAnimator::ANIMATION_UNDO_LIFT, |
| 522 internal::SessionStateAnimator::ANIMATION_SPEED_UNDO_MOVE_WINDOWS, | 523 internal::SessionStateAnimator::ANIMATION_SPEED_UNDO_MOVE_WINDOWS, |
| 523 observer); | 524 observer); |
| 524 animator_->StartAnimationWithObserver( | 525 animator_->StartAnimationWithObserver( |
| 525 internal::SessionStateAnimator::LAUNCHER, | 526 internal::SessionStateAnimator::LAUNCHER, |
| 526 internal::SessionStateAnimator::ANIMATION_FADE_IN, | 527 internal::SessionStateAnimator::ANIMATION_FADE_IN, |
| 527 internal::SessionStateAnimator::ANIMATION_SPEED_UNDO_MOVE_WINDOWS, | 528 internal::SessionStateAnimator::ANIMATION_SPEED_UNDO_MOVE_WINDOWS, |
| 528 observer); | 529 observer); |
| 529 AnimateBackgroundHidingIfNecessary( | 530 AnimateBackgroundHidingIfNecessary( |
| 530 internal::SessionStateAnimator::ANIMATION_SPEED_UNDO_MOVE_WINDOWS, | 531 internal::SessionStateAnimator::ANIMATION_SPEED_UNDO_MOVE_WINDOWS, |
| 531 observer); | 532 observer); |
| 532 | 533 |
| 533 observer->Unpause(); | 534 observer->Unpause(); |
| 534 } | 535 } |
| 535 | 536 |
| 536 void SessionStateControllerImpl2::StartPostLockAnimation() { | 537 void LockStateControllerImpl2::StartPostLockAnimation() { |
| 537 base::Closure next_animation_starter = | 538 base::Closure next_animation_starter = |
| 538 base::Bind(&SessionStateControllerImpl2::PostLockAnimationFinished, | 539 base::Bind(&LockStateControllerImpl2::PostLockAnimationFinished, |
| 539 base::Unretained(this)); | 540 base::Unretained(this)); |
| 540 | 541 |
| 541 AnimationFinishedObserver* observer = | 542 AnimationFinishedObserver* observer = |
| 542 new AnimationFinishedObserver(next_animation_starter); | 543 new AnimationFinishedObserver(next_animation_starter); |
| 543 | 544 |
| 544 observer->Pause(); | 545 observer->Pause(); |
| 545 animator_->StartAnimationWithObserver( | 546 animator_->StartAnimationWithObserver( |
| 546 internal::SessionStateAnimator::LOCK_SCREEN_CONTAINERS, | 547 internal::SessionStateAnimator::LOCK_SCREEN_CONTAINERS, |
| 547 internal::SessionStateAnimator::ANIMATION_RAISE_TO_SCREEN, | 548 internal::SessionStateAnimator::ANIMATION_RAISE_TO_SCREEN, |
| 548 internal::SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, | 549 internal::SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, |
| 549 observer); | 550 observer); |
| 550 observer->Unpause(); | 551 observer->Unpause(); |
| 551 } | 552 } |
| 552 | 553 |
| 553 void SessionStateControllerImpl2::StartUnlockAnimationBeforeUIDestroyed( | 554 void LockStateControllerImpl2::StartUnlockAnimationBeforeUIDestroyed( |
| 554 base::Closure& callback) { | 555 base::Closure& callback) { |
| 555 animator_->StartAnimationWithCallback( | 556 animator_->StartAnimationWithCallback( |
| 556 internal::SessionStateAnimator::LOCK_SCREEN_CONTAINERS, | 557 internal::SessionStateAnimator::LOCK_SCREEN_CONTAINERS, |
| 557 internal::SessionStateAnimator::ANIMATION_LIFT, | 558 internal::SessionStateAnimator::ANIMATION_LIFT, |
| 558 internal::SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, | 559 internal::SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, |
| 559 callback); | 560 callback); |
| 560 } | 561 } |
| 561 | 562 |
| 562 void SessionStateControllerImpl2::StartUnlockAnimationAfterUIDestroyed() { | 563 void LockStateControllerImpl2::StartUnlockAnimationAfterUIDestroyed() { |
| 563 base::Closure next_animation_starter = | 564 base::Closure next_animation_starter = |
| 564 base::Bind( | 565 base::Bind( |
| 565 &SessionStateControllerImpl2::UnlockAnimationAfterUIDestroyedFinished, | 566 &LockStateControllerImpl2:: |
| 566 base::Unretained(this)); | 567 UnlockAnimationAfterUIDestroyedFinished, |
| 568 base::Unretained(this)); |
| 567 | 569 |
| 568 AnimationFinishedObserver* observer = | 570 AnimationFinishedObserver* observer = |
| 569 new AnimationFinishedObserver(next_animation_starter); | 571 new AnimationFinishedObserver(next_animation_starter); |
| 570 | 572 |
| 571 observer->Pause(); | 573 observer->Pause(); |
| 572 | 574 |
| 573 animator_->StartAnimationWithObserver( | 575 animator_->StartAnimationWithObserver( |
| 574 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, | 576 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
| 575 internal::SessionStateAnimator::ANIMATION_DROP, | 577 internal::SessionStateAnimator::ANIMATION_DROP, |
| 576 internal::SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, | 578 internal::SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, |
| 577 observer); | 579 observer); |
| 578 animator_->StartAnimationWithObserver( | 580 animator_->StartAnimationWithObserver( |
| 579 internal::SessionStateAnimator::LAUNCHER, | 581 internal::SessionStateAnimator::LAUNCHER, |
| 580 internal::SessionStateAnimator::ANIMATION_FADE_IN, | 582 internal::SessionStateAnimator::ANIMATION_FADE_IN, |
| 581 internal::SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, | 583 internal::SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, |
| 582 observer); | 584 observer); |
| 583 AnimateBackgroundHidingIfNecessary( | 585 AnimateBackgroundHidingIfNecessary( |
| 584 internal::SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, | 586 internal::SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, |
| 585 observer); | 587 observer); |
| 586 observer->Unpause(); | 588 observer->Unpause(); |
| 587 } | 589 } |
| 588 | 590 |
| 589 void SessionStateControllerImpl2::StoreUnlockedProperties() { | 591 void LockStateControllerImpl2::StoreUnlockedProperties() { |
| 590 if (!unlocked_properties_) { | 592 if (!unlocked_properties_) { |
| 591 unlocked_properties_.reset(new UnlockedStateProperties()); | 593 unlocked_properties_.reset(new UnlockedStateProperties()); |
| 592 unlocked_properties_->background_is_hidden = IsBackgroundHidden(); | 594 unlocked_properties_->background_is_hidden = IsBackgroundHidden(); |
| 593 } | 595 } |
| 594 if (unlocked_properties_->background_is_hidden) { | 596 if (unlocked_properties_->background_is_hidden) { |
| 595 // Hide background so that it can be animated later. | 597 // Hide background so that it can be animated later. |
| 596 animator_->StartAnimation( | 598 animator_->StartAnimation( |
| 597 internal::SessionStateAnimator::DESKTOP_BACKGROUND, | 599 internal::SessionStateAnimator::DESKTOP_BACKGROUND, |
| 598 internal::SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY, | 600 internal::SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY, |
| 599 internal::SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); | 601 internal::SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); |
| 600 ShowBackground(); | 602 ShowBackground(); |
| 601 } | 603 } |
| 602 } | 604 } |
| 603 | 605 |
| 604 void SessionStateControllerImpl2::RestoreUnlockedProperties() { | 606 void LockStateControllerImpl2::RestoreUnlockedProperties() { |
| 605 if (!unlocked_properties_) | 607 if (!unlocked_properties_) |
| 606 return; | 608 return; |
| 607 if (unlocked_properties_->background_is_hidden) { | 609 if (unlocked_properties_->background_is_hidden) { |
| 608 HideBackground(); | 610 HideBackground(); |
| 609 // Restore background visibility. | 611 // Restore background visibility. |
| 610 animator_->StartAnimation( | 612 animator_->StartAnimation( |
| 611 internal::SessionStateAnimator::DESKTOP_BACKGROUND, | 613 internal::SessionStateAnimator::DESKTOP_BACKGROUND, |
| 612 internal::SessionStateAnimator::ANIMATION_FADE_IN, | 614 internal::SessionStateAnimator::ANIMATION_FADE_IN, |
| 613 internal::SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); | 615 internal::SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); |
| 614 } | 616 } |
| 615 unlocked_properties_.reset(); | 617 unlocked_properties_.reset(); |
| 616 } | 618 } |
| 617 | 619 |
| 618 void SessionStateControllerImpl2::AnimateBackgroundAppearanceIfNecessary( | 620 void LockStateControllerImpl2::AnimateBackgroundAppearanceIfNecessary( |
| 619 internal::SessionStateAnimator::AnimationSpeed speed, | 621 internal::SessionStateAnimator::AnimationSpeed speed, |
| 620 ui::LayerAnimationObserver* observer) { | 622 ui::LayerAnimationObserver* observer) { |
| 621 if (unlocked_properties_.get() && | 623 if (unlocked_properties_.get() && |
| 622 unlocked_properties_->background_is_hidden) { | 624 unlocked_properties_->background_is_hidden) { |
| 623 animator_->StartAnimationWithObserver( | 625 animator_->StartAnimationWithObserver( |
| 624 internal::SessionStateAnimator::DESKTOP_BACKGROUND, | 626 internal::SessionStateAnimator::DESKTOP_BACKGROUND, |
| 625 internal::SessionStateAnimator::ANIMATION_FADE_IN, | 627 internal::SessionStateAnimator::ANIMATION_FADE_IN, |
| 626 speed, | 628 speed, |
| 627 observer); | 629 observer); |
| 628 } | 630 } |
| 629 } | 631 } |
| 630 | 632 |
| 631 void SessionStateControllerImpl2::AnimateBackgroundHidingIfNecessary( | 633 void LockStateControllerImpl2::AnimateBackgroundHidingIfNecessary( |
| 632 internal::SessionStateAnimator::AnimationSpeed speed, | 634 internal::SessionStateAnimator::AnimationSpeed speed, |
| 633 ui::LayerAnimationObserver* observer) { | 635 ui::LayerAnimationObserver* observer) { |
| 634 if (unlocked_properties_.get() && | 636 if (unlocked_properties_.get() && |
| 635 unlocked_properties_->background_is_hidden) { | 637 unlocked_properties_->background_is_hidden) { |
| 636 animator_->StartAnimationWithObserver( | 638 animator_->StartAnimationWithObserver( |
| 637 internal::SessionStateAnimator::DESKTOP_BACKGROUND, | 639 internal::SessionStateAnimator::DESKTOP_BACKGROUND, |
| 638 internal::SessionStateAnimator::ANIMATION_FADE_OUT, | 640 internal::SessionStateAnimator::ANIMATION_FADE_OUT, |
| 639 speed, | 641 speed, |
| 640 observer); | 642 observer); |
| 641 } | 643 } |
| 642 } | 644 } |
| 643 | 645 |
| 644 } // namespace ash | 646 } // namespace ash |
| OLD | NEW |