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::RequestShutdown() { |
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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 &LockStateController::OnPreShutdownAnimationTimeout); | 264 &LockStateController::OnPreShutdownAnimationTimeout); |
265 } | 265 } |
266 | 266 |
267 void LockStateController::OnPreShutdownAnimationTimeout() { | 267 void LockStateController::OnPreShutdownAnimationTimeout() { |
268 VLOG(1) << "OnPreShutdownAnimationTimeout"; | 268 VLOG(1) << "OnPreShutdownAnimationTimeout"; |
269 shutting_down_ = true; | 269 shutting_down_ = true; |
270 | 270 |
271 Shell* shell = ash::Shell::GetInstance(); | 271 Shell* shell = ash::Shell::GetInstance(); |
272 shell->cursor_manager()->HideCursor(); | 272 shell->cursor_manager()->HideCursor(); |
273 | 273 |
274 StartRealShutdownTimer(false, POWER_OFF); | 274 StartRealShutdownTimer(false); |
275 } | 275 } |
276 | 276 |
277 void LockStateController::StartRealShutdownTimer(bool with_animation_time, | 277 void LockStateController::StartRealShutdownTimer(bool with_animation_time) { |
278 ShutdownMode shutdown_mode) { | |
279 base::TimeDelta duration = | 278 base::TimeDelta duration = |
280 base::TimeDelta::FromMilliseconds(kShutdownRequestDelayMs); | 279 base::TimeDelta::FromMilliseconds(kShutdownRequestDelayMs); |
281 if (with_animation_time) { | 280 if (with_animation_time) { |
282 duration += | 281 duration += |
283 animator_->GetDuration(SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); | 282 animator_->GetDuration(SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); |
284 } | 283 } |
285 | 284 |
286 #if defined(OS_CHROMEOS) | 285 #if defined(OS_CHROMEOS) |
287 const AccessibilityDelegate* const delegate = | 286 const AccessibilityDelegate* const delegate = |
288 Shell::GetInstance()->accessibility_delegate(); | 287 Shell::GetInstance()->accessibility_delegate(); |
289 base::TimeDelta sound_duration = delegate->PlayShutdownSound(); | 288 base::TimeDelta sound_duration = delegate->PlayShutdownSound(); |
290 sound_duration = | 289 sound_duration = |
291 std::min(sound_duration, | 290 std::min(sound_duration, |
292 base::TimeDelta::FromMilliseconds(kMaxShutdownSoundDurationMs)); | 291 base::TimeDelta::FromMilliseconds(kMaxShutdownSoundDurationMs)); |
293 duration = std::max(duration, sound_duration); | 292 duration = std::max(duration, sound_duration); |
294 #endif | 293 #endif |
295 | 294 |
296 real_shutdown_timer_.Start( | 295 real_shutdown_timer_.Start( |
297 FROM_HERE, duration, base::Bind(&LockStateController::OnRealPowerTimeout, | 296 FROM_HERE, duration, base::Bind(&LockStateController::OnRealPowerTimeout, |
298 base::Unretained(this), shutdown_mode)); | 297 base::Unretained(this))); |
299 } | 298 } |
300 | 299 |
301 void LockStateController::OnRealPowerTimeout(ShutdownMode shutdown_mode) { | 300 void LockStateController::OnRealPowerTimeout() { |
302 VLOG(1) << "OnRealPowerTimeout"; | 301 VLOG(1) << "OnRealPowerTimeout"; |
303 DCHECK(shutting_down_); | 302 DCHECK(shutting_down_); |
304 #if defined(OS_CHROMEOS) | 303 #if defined(OS_CHROMEOS) |
305 if (!base::SysInfo::IsRunningOnChromeOS()) { | 304 if (!base::SysInfo::IsRunningOnChromeOS()) { |
306 ShellDelegate* delegate = Shell::GetInstance()->delegate(); | 305 ShellDelegate* delegate = Shell::GetInstance()->delegate(); |
307 if (delegate) { | 306 if (delegate) { |
308 delegate->Exit(); | 307 delegate->Exit(); |
309 return; | 308 return; |
310 } | 309 } |
311 } | 310 } |
312 #endif | 311 #endif |
313 if (shutdown_mode == POWER_OFF) { | |
314 Shell::GetInstance()->metrics()->RecordUserMetricsAction( | |
315 UMA_ACCEL_SHUT_DOWN_POWER_BUTTON); | |
316 delegate_->RequestShutdown(); | |
317 return; | |
318 } | |
319 Shell::GetInstance()->metrics()->RecordUserMetricsAction( | 312 Shell::GetInstance()->metrics()->RecordUserMetricsAction( |
320 UMA_ACCEL_RESTART_POWER_BUTTON); | 313 UMA_ACCEL_SHUT_DOWN_POWER_BUTTON); |
321 delegate_->RequestRestart(); | 314 delegate_->RequestShutdown(); |
322 } | 315 } |
323 | 316 |
324 void LockStateController::StartCancellableShutdownAnimation() { | 317 void LockStateController::StartCancellableShutdownAnimation() { |
325 Shell* shell = ash::Shell::GetInstance(); | 318 Shell* shell = ash::Shell::GetInstance(); |
326 // Hide cursor, but let it reappear if the mouse moves. | 319 // Hide cursor, but let it reappear if the mouse moves. |
327 shell->cursor_manager()->HideCursor(); | 320 shell->cursor_manager()->HideCursor(); |
328 | 321 |
329 animator_->StartAnimation( | 322 animator_->StartAnimation( |
330 SessionStateAnimator::ROOT_CONTAINER, | 323 SessionStateAnimator::ROOT_CONTAINER, |
331 SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS, | 324 SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS, |
(...skipping 244 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 |