| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/lock_state_controller.h" | 5 #include "ash/wm/lock_state_controller.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "ash/accessibility_delegate.h" | 10 #include "ash/accessibility_delegate.h" |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 } | 160 } |
| 161 | 161 |
| 162 void LockStateController::OnStartingLock() { | 162 void LockStateController::OnStartingLock() { |
| 163 if (shutting_down_ || system_is_locked_) | 163 if (shutting_down_ || system_is_locked_) |
| 164 return; | 164 return; |
| 165 if (animating_lock_) | 165 if (animating_lock_) |
| 166 return; | 166 return; |
| 167 StartImmediatePreLockAnimation(false /* request_lock_on_completion */); | 167 StartImmediatePreLockAnimation(false /* request_lock_on_completion */); |
| 168 } | 168 } |
| 169 | 169 |
| 170 void LockStateController::RequestShutdown(ShutdownMode mode) { | 170 void LockStateController::RequestShutdownOrRestart() { |
| 171 if (shutting_down_) | 171 if (shutting_down_) |
| 172 return; | 172 return; |
| 173 | 173 |
| 174 shutting_down_ = true; | 174 shutting_down_ = true; |
| 175 | 175 |
| 176 Shell* shell = ash::Shell::GetInstance(); | 176 Shell* shell = ash::Shell::GetInstance(); |
| 177 shell->cursor_manager()->HideCursor(); | 177 shell->cursor_manager()->HideCursor(); |
| 178 shell->cursor_manager()->LockCursor(); | 178 shell->cursor_manager()->LockCursor(); |
| 179 | 179 |
| 180 animator_->StartAnimation( | 180 animator_->StartAnimation( |
| 181 SessionStateAnimator::ROOT_CONTAINER, | 181 SessionStateAnimator::ROOT_CONTAINER, |
| 182 SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS, | 182 SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS, |
| 183 SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); | 183 SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); |
| 184 StartRealShutdownTimer(true, mode); | 184 StartRealShutdownTimer(true); |
| 185 } | 185 } |
| 186 | 186 |
| 187 void LockStateController::OnLockScreenHide( | 187 void LockStateController::OnLockScreenHide( |
| 188 base::Callback<void(void)>& callback) { | 188 base::Callback<void(void)>& callback) { |
| 189 StartUnlockAnimationBeforeUIDestroyed(callback); | 189 StartUnlockAnimationBeforeUIDestroyed(callback); |
| 190 } | 190 } |
| 191 | 191 |
| 192 void LockStateController::SetLockScreenDisplayedCallback( | 192 void LockStateController::SetLockScreenDisplayedCallback( |
| 193 const base::Closure& callback) { | 193 const base::Closure& callback) { |
| 194 lock_screen_displayed_callback_ = callback; | 194 lock_screen_displayed_callback_ = callback; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 &LockStateController::OnPreShutdownAnimationTimeout); | 265 &LockStateController::OnPreShutdownAnimationTimeout); |
| 266 } | 266 } |
| 267 | 267 |
| 268 void LockStateController::OnPreShutdownAnimationTimeout() { | 268 void LockStateController::OnPreShutdownAnimationTimeout() { |
| 269 VLOG(1) << "OnPreShutdownAnimationTimeout"; | 269 VLOG(1) << "OnPreShutdownAnimationTimeout"; |
| 270 shutting_down_ = true; | 270 shutting_down_ = true; |
| 271 | 271 |
| 272 Shell* shell = ash::Shell::GetInstance(); | 272 Shell* shell = ash::Shell::GetInstance(); |
| 273 shell->cursor_manager()->HideCursor(); | 273 shell->cursor_manager()->HideCursor(); |
| 274 | 274 |
| 275 StartRealShutdownTimer(false, POWER_OFF); | 275 StartRealShutdownTimer(false); |
| 276 } | 276 } |
| 277 | 277 |
| 278 void LockStateController::StartRealShutdownTimer(bool with_animation_time, | 278 void LockStateController::StartRealShutdownTimer(bool with_animation_time) { |
| 279 ShutdownMode shutdown_mode) { | |
| 280 base::TimeDelta duration = | 279 base::TimeDelta duration = |
| 281 base::TimeDelta::FromMilliseconds(kShutdownRequestDelayMs); | 280 base::TimeDelta::FromMilliseconds(kShutdownRequestDelayMs); |
| 282 if (with_animation_time) { | 281 if (with_animation_time) { |
| 283 duration += | 282 duration += |
| 284 animator_->GetDuration(SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); | 283 animator_->GetDuration(SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); |
| 285 } | 284 } |
| 286 | 285 |
| 287 #if defined(OS_CHROMEOS) | 286 #if defined(OS_CHROMEOS) |
| 288 const AccessibilityDelegate* const delegate = | 287 const AccessibilityDelegate* const delegate = |
| 289 Shell::GetInstance()->accessibility_delegate(); | 288 Shell::GetInstance()->accessibility_delegate(); |
| 290 base::TimeDelta sound_duration = delegate->PlayShutdownSound(); | 289 base::TimeDelta sound_duration = delegate->PlayShutdownSound(); |
| 291 sound_duration = | 290 sound_duration = |
| 292 std::min(sound_duration, | 291 std::min(sound_duration, |
| 293 base::TimeDelta::FromMilliseconds(kMaxShutdownSoundDurationMs)); | 292 base::TimeDelta::FromMilliseconds(kMaxShutdownSoundDurationMs)); |
| 294 duration = std::max(duration, sound_duration); | 293 duration = std::max(duration, sound_duration); |
| 295 #endif | 294 #endif |
| 296 | 295 |
| 297 real_shutdown_timer_.Start( | 296 real_shutdown_timer_.Start( |
| 298 FROM_HERE, duration, base::Bind(&LockStateController::OnRealPowerTimeout, | 297 FROM_HERE, duration, base::Bind(&LockStateController::OnRealPowerTimeout, |
| 299 base::Unretained(this), shutdown_mode)); | 298 base::Unretained(this))); |
| 300 } | 299 } |
| 301 | 300 |
| 302 void LockStateController::OnRealPowerTimeout(ShutdownMode shutdown_mode) { | 301 void LockStateController::OnRealPowerTimeout() { |
| 303 VLOG(1) << "OnRealPowerTimeout"; | 302 VLOG(1) << "OnRealPowerTimeout"; |
| 304 DCHECK(shutting_down_); | 303 DCHECK(shutting_down_); |
| 305 #if defined(OS_CHROMEOS) | 304 #if defined(OS_CHROMEOS) |
| 306 if (!base::SysInfo::IsRunningOnChromeOS()) { | 305 if (!base::SysInfo::IsRunningOnChromeOS()) { |
| 307 ShellDelegate* delegate = Shell::GetInstance()->delegate(); | 306 ShellDelegate* delegate = Shell::GetInstance()->delegate(); |
| 308 if (delegate) { | 307 if (delegate) { |
| 309 delegate->Exit(); | 308 delegate->Exit(); |
| 310 return; | 309 return; |
| 311 } | 310 } |
| 312 } | 311 } |
| 313 #endif | 312 #endif |
| 314 if (shutdown_mode == POWER_OFF) { | |
| 315 Shell::GetInstance()->metrics()->RecordUserMetricsAction( | |
| 316 UMA_ACCEL_SHUT_DOWN_POWER_BUTTON); | |
| 317 delegate_->RequestShutdown(); | |
| 318 return; | |
| 319 } | |
| 320 Shell::GetInstance()->metrics()->RecordUserMetricsAction( | 313 Shell::GetInstance()->metrics()->RecordUserMetricsAction( |
| 321 UMA_ACCEL_RESTART_POWER_BUTTON); | 314 UMA_ACCEL_SHUT_DOWN_POWER_BUTTON); |
| 322 delegate_->RequestRestart(); | 315 delegate_->RequestShutdownOrRestart(); |
| 323 } | 316 } |
| 324 | 317 |
| 325 void LockStateController::StartCancellableShutdownAnimation() { | 318 void LockStateController::StartCancellableShutdownAnimation() { |
| 326 Shell* shell = ash::Shell::GetInstance(); | 319 Shell* shell = ash::Shell::GetInstance(); |
| 327 // Hide cursor, but let it reappear if the mouse moves. | 320 // Hide cursor, but let it reappear if the mouse moves. |
| 328 shell->cursor_manager()->HideCursor(); | 321 shell->cursor_manager()->HideCursor(); |
| 329 | 322 |
| 330 animator_->StartAnimation( | 323 animator_->StartAnimation( |
| 331 SessionStateAnimator::ROOT_CONTAINER, | 324 SessionStateAnimator::ROOT_CONTAINER, |
| 332 SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS, | 325 SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS, |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 576 if (unlocked_properties_.get() && | 569 if (unlocked_properties_.get() && |
| 577 unlocked_properties_->background_is_hidden) { | 570 unlocked_properties_->background_is_hidden) { |
| 578 animation_sequence->StartAnimation( | 571 animation_sequence->StartAnimation( |
| 579 SessionStateAnimator::DESKTOP_BACKGROUND, | 572 SessionStateAnimator::DESKTOP_BACKGROUND, |
| 580 SessionStateAnimator::ANIMATION_FADE_OUT, | 573 SessionStateAnimator::ANIMATION_FADE_OUT, |
| 581 speed); | 574 speed); |
| 582 } | 575 } |
| 583 } | 576 } |
| 584 | 577 |
| 585 } // namespace ash | 578 } // namespace ash |
| OLD | NEW |