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 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "ash/accessibility_delegate.h" | 11 #include "ash/accessibility_delegate.h" |
12 #include "ash/cancel_mode.h" | 12 #include "ash/cancel_mode.h" |
13 #include "ash/public/cpp/shell_window_ids.h" | 13 #include "ash/public/cpp/shell_window_ids.h" |
14 #include "ash/public/interfaces/shutdown.mojom.h" | 14 #include "ash/public/interfaces/shutdown.mojom.h" |
15 #include "ash/shell.h" | 15 #include "ash/shell.h" |
16 #include "ash/shell_delegate.h" | 16 #include "ash/shell_delegate.h" |
| 17 #include "ash/shell_port.h" |
17 #include "ash/shutdown_controller.h" | 18 #include "ash/shutdown_controller.h" |
18 #include "ash/wm/session_state_animator.h" | 19 #include "ash/wm/session_state_animator.h" |
19 #include "ash/wm/session_state_animator_impl.h" | 20 #include "ash/wm/session_state_animator_impl.h" |
20 #include "ash/wm_shell.h" | |
21 #include "base/bind.h" | 21 #include "base/bind.h" |
22 #include "base/bind_helpers.h" | 22 #include "base/bind_helpers.h" |
23 #include "base/command_line.h" | 23 #include "base/command_line.h" |
24 #include "base/location.h" | 24 #include "base/location.h" |
25 #include "base/logging.h" | 25 #include "base/logging.h" |
26 #include "base/metrics/histogram_macros.h" | 26 #include "base/metrics/histogram_macros.h" |
27 #include "base/strings/string_util.h" | 27 #include "base/strings/string_util.h" |
28 #include "base/sys_info.h" | 28 #include "base/sys_info.h" |
29 #include "base/timer/timer.h" | 29 #include "base/timer/timer.h" |
30 #include "chromeos/dbus/dbus_thread_manager.h" | 30 #include "chromeos/dbus/dbus_thread_manager.h" |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 duration = std::max(duration, sound_duration); | 291 duration = std::max(duration, sound_duration); |
292 | 292 |
293 real_shutdown_timer_.Start( | 293 real_shutdown_timer_.Start( |
294 FROM_HERE, duration, base::Bind(&LockStateController::OnRealPowerTimeout, | 294 FROM_HERE, duration, base::Bind(&LockStateController::OnRealPowerTimeout, |
295 base::Unretained(this))); | 295 base::Unretained(this))); |
296 } | 296 } |
297 | 297 |
298 void LockStateController::OnRealPowerTimeout() { | 298 void LockStateController::OnRealPowerTimeout() { |
299 VLOG(1) << "OnRealPowerTimeout"; | 299 VLOG(1) << "OnRealPowerTimeout"; |
300 DCHECK(shutting_down_); | 300 DCHECK(shutting_down_); |
301 WmShell::Get()->RecordUserMetricsAction(UMA_ACCEL_SHUT_DOWN_POWER_BUTTON); | 301 ShellPort::Get()->RecordUserMetricsAction(UMA_ACCEL_SHUT_DOWN_POWER_BUTTON); |
302 // Shut down or reboot based on device policy. | 302 // Shut down or reboot based on device policy. |
303 shutdown_controller_->ShutDownOrReboot(); | 303 shutdown_controller_->ShutDownOrReboot(); |
304 } | 304 } |
305 | 305 |
306 void LockStateController::StartCancellableShutdownAnimation() { | 306 void LockStateController::StartCancellableShutdownAnimation() { |
307 Shell* shell = Shell::Get(); | 307 Shell* shell = Shell::Get(); |
308 // Hide cursor, but let it reappear if the mouse moves. | 308 // Hide cursor, but let it reappear if the mouse moves. |
309 if (shell->cursor_manager()) | 309 if (shell->cursor_manager()) |
310 shell->cursor_manager()->HideCursor(); | 310 shell->cursor_manager()->HideCursor(); |
311 | 311 |
(...skipping 26 matching lines...) Expand all Loading... |
338 // Hide the screen locker containers so we can raise them later. | 338 // Hide the screen locker containers so we can raise them later. |
339 animator_->StartAnimation(SessionStateAnimator::LOCK_SCREEN_CONTAINERS, | 339 animator_->StartAnimation(SessionStateAnimator::LOCK_SCREEN_CONTAINERS, |
340 SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY, | 340 SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY, |
341 SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); | 341 SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); |
342 AnimateWallpaperAppearanceIfNecessary( | 342 AnimateWallpaperAppearanceIfNecessary( |
343 SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, animation_sequence); | 343 SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, animation_sequence); |
344 | 344 |
345 animation_sequence->EndSequence(); | 345 animation_sequence->EndSequence(); |
346 | 346 |
347 DispatchCancelMode(); | 347 DispatchCancelMode(); |
348 WmShell::Get()->OnLockStateEvent( | 348 ShellPort::Get()->OnLockStateEvent( |
349 LockStateObserver::EVENT_LOCK_ANIMATION_STARTED); | 349 LockStateObserver::EVENT_LOCK_ANIMATION_STARTED); |
350 } | 350 } |
351 | 351 |
352 void LockStateController::StartCancellablePreLockAnimation() { | 352 void LockStateController::StartCancellablePreLockAnimation() { |
353 animating_lock_ = true; | 353 animating_lock_ = true; |
354 StoreUnlockedProperties(); | 354 StoreUnlockedProperties(); |
355 VLOG(1) << "StartCancellablePreLockAnimation"; | 355 VLOG(1) << "StartCancellablePreLockAnimation"; |
356 base::Closure next_animation_starter = | 356 base::Closure next_animation_starter = |
357 base::Bind(&LockStateController::PreLockAnimationFinished, | 357 base::Bind(&LockStateController::PreLockAnimationFinished, |
358 weak_ptr_factory_.GetWeakPtr(), true /* request_lock */); | 358 weak_ptr_factory_.GetWeakPtr(), true /* request_lock */); |
359 SessionStateAnimator::AnimationSequence* animation_sequence = | 359 SessionStateAnimator::AnimationSequence* animation_sequence = |
360 animator_->BeginAnimationSequence(next_animation_starter); | 360 animator_->BeginAnimationSequence(next_animation_starter); |
361 | 361 |
362 animation_sequence->StartAnimation( | 362 animation_sequence->StartAnimation( |
363 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, | 363 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
364 SessionStateAnimator::ANIMATION_LIFT, | 364 SessionStateAnimator::ANIMATION_LIFT, |
365 SessionStateAnimator::ANIMATION_SPEED_UNDOABLE); | 365 SessionStateAnimator::ANIMATION_SPEED_UNDOABLE); |
366 animation_sequence->StartAnimation( | 366 animation_sequence->StartAnimation( |
367 SessionStateAnimator::LAUNCHER, SessionStateAnimator::ANIMATION_FADE_OUT, | 367 SessionStateAnimator::LAUNCHER, SessionStateAnimator::ANIMATION_FADE_OUT, |
368 SessionStateAnimator::ANIMATION_SPEED_UNDOABLE); | 368 SessionStateAnimator::ANIMATION_SPEED_UNDOABLE); |
369 // Hide the screen locker containers so we can raise them later. | 369 // Hide the screen locker containers so we can raise them later. |
370 animator_->StartAnimation(SessionStateAnimator::LOCK_SCREEN_CONTAINERS, | 370 animator_->StartAnimation(SessionStateAnimator::LOCK_SCREEN_CONTAINERS, |
371 SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY, | 371 SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY, |
372 SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); | 372 SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); |
373 AnimateWallpaperAppearanceIfNecessary( | 373 AnimateWallpaperAppearanceIfNecessary( |
374 SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, animation_sequence); | 374 SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, animation_sequence); |
375 | 375 |
376 DispatchCancelMode(); | 376 DispatchCancelMode(); |
377 WmShell::Get()->OnLockStateEvent( | 377 ShellPort::Get()->OnLockStateEvent( |
378 LockStateObserver::EVENT_PRELOCK_ANIMATION_STARTED); | 378 LockStateObserver::EVENT_PRELOCK_ANIMATION_STARTED); |
379 animation_sequence->EndSequence(); | 379 animation_sequence->EndSequence(); |
380 } | 380 } |
381 | 381 |
382 void LockStateController::CancelPreLockAnimation() { | 382 void LockStateController::CancelPreLockAnimation() { |
383 VLOG(1) << "CancelPreLockAnimation"; | 383 VLOG(1) << "CancelPreLockAnimation"; |
384 base::Closure next_animation_starter = | 384 base::Closure next_animation_starter = |
385 base::Bind(&LockStateController::LockAnimationCancelled, | 385 base::Bind(&LockStateController::LockAnimationCancelled, |
386 weak_ptr_factory_.GetWeakPtr()); | 386 weak_ptr_factory_.GetWeakPtr()); |
387 SessionStateAnimator::AnimationSequence* animation_sequence = | 387 SessionStateAnimator::AnimationSequence* animation_sequence = |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 | 456 |
457 // Don't do anything (including starting the lock-fail timer) if the screen | 457 // Don't do anything (including starting the lock-fail timer) if the screen |
458 // was already locked while the animation was going. | 458 // was already locked while the animation was going. |
459 if (system_is_locked_) { | 459 if (system_is_locked_) { |
460 DCHECK(!request_lock) << "Got request to lock already-locked system " | 460 DCHECK(!request_lock) << "Got request to lock already-locked system " |
461 << "at completion of pre-lock animation"; | 461 << "at completion of pre-lock animation"; |
462 return; | 462 return; |
463 } | 463 } |
464 | 464 |
465 if (request_lock) { | 465 if (request_lock) { |
466 WmShell::Get()->RecordUserMetricsAction( | 466 ShellPort::Get()->RecordUserMetricsAction( |
467 shutdown_after_lock_ ? UMA_ACCEL_LOCK_SCREEN_POWER_BUTTON | 467 shutdown_after_lock_ ? UMA_ACCEL_LOCK_SCREEN_POWER_BUTTON |
468 : UMA_ACCEL_LOCK_SCREEN_LOCK_BUTTON); | 468 : UMA_ACCEL_LOCK_SCREEN_LOCK_BUTTON); |
469 chromeos::DBusThreadManager::Get() | 469 chromeos::DBusThreadManager::Get() |
470 ->GetSessionManagerClient() | 470 ->GetSessionManagerClient() |
471 ->RequestLockScreen(); | 471 ->RequestLockScreen(); |
472 } | 472 } |
473 | 473 |
474 base::TimeDelta timeout = | 474 base::TimeDelta timeout = |
475 base::TimeDelta::FromMilliseconds(kLockFailTimeoutMs); | 475 base::TimeDelta::FromMilliseconds(kLockFailTimeoutMs); |
476 // Increase lock timeout for slower hardware, see http://crbug.com/350628 | 476 // Increase lock timeout for slower hardware, see http://crbug.com/350628 |
477 // The devices with boards "x86-mario", "daisy", "x86-alex" and "x86-zgb" have | 477 // The devices with boards "x86-mario", "daisy", "x86-alex" and "x86-zgb" have |
478 // slower hardware. For "x86-alex" and "x86-zgb" there are some modifications | 478 // slower hardware. For "x86-alex" and "x86-zgb" there are some modifications |
479 // like "x86-alex-he". Also there's "daisy", "daisy_spring" and "daisy_skate", | 479 // like "x86-alex-he". Also there's "daisy", "daisy_spring" and "daisy_skate", |
480 // but they are all different devices and only "daisy" has slower hardware. | 480 // but they are all different devices and only "daisy" has slower hardware. |
481 const std::string board = base::SysInfo::GetStrippedReleaseBoard(); | 481 const std::string board = base::SysInfo::GetStrippedReleaseBoard(); |
482 if (board == "x86-mario" || board == "daisy" || | 482 if (board == "x86-mario" || board == "daisy" || |
483 base::StartsWith(board, "x86-alex", base::CompareCase::SENSITIVE) || | 483 base::StartsWith(board, "x86-alex", base::CompareCase::SENSITIVE) || |
484 base::StartsWith(board, "x86-zgb", base::CompareCase::SENSITIVE)) { | 484 base::StartsWith(board, "x86-zgb", base::CompareCase::SENSITIVE)) { |
485 timeout *= 2; | 485 timeout *= 2; |
486 } | 486 } |
487 lock_fail_timer_.Start(FROM_HERE, timeout, this, | 487 lock_fail_timer_.Start(FROM_HERE, timeout, this, |
488 &LockStateController::OnLockFailTimeout); | 488 &LockStateController::OnLockFailTimeout); |
489 | 489 |
490 lock_duration_timer_.reset(new base::ElapsedTimer()); | 490 lock_duration_timer_.reset(new base::ElapsedTimer()); |
491 } | 491 } |
492 | 492 |
493 void LockStateController::PostLockAnimationFinished() { | 493 void LockStateController::PostLockAnimationFinished() { |
494 animating_lock_ = false; | 494 animating_lock_ = false; |
495 VLOG(1) << "PostLockAnimationFinished"; | 495 VLOG(1) << "PostLockAnimationFinished"; |
496 WmShell::Get()->OnLockStateEvent( | 496 ShellPort::Get()->OnLockStateEvent( |
497 LockStateObserver::EVENT_LOCK_ANIMATION_FINISHED); | 497 LockStateObserver::EVENT_LOCK_ANIMATION_FINISHED); |
498 if (!lock_screen_displayed_callback_.is_null()) { | 498 if (!lock_screen_displayed_callback_.is_null()) { |
499 lock_screen_displayed_callback_.Run(); | 499 lock_screen_displayed_callback_.Run(); |
500 lock_screen_displayed_callback_.Reset(); | 500 lock_screen_displayed_callback_.Reset(); |
501 } | 501 } |
502 CHECK(!views::MenuController::GetActiveInstance()); | 502 CHECK(!views::MenuController::GetActiveInstance()); |
503 if (shutdown_after_lock_) { | 503 if (shutdown_after_lock_) { |
504 shutdown_after_lock_ = false; | 504 shutdown_after_lock_ = false; |
505 StartLockToShutdownTimer(); | 505 StartLockToShutdownTimer(); |
506 } | 506 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 SessionStateAnimator::AnimationSpeed speed, | 551 SessionStateAnimator::AnimationSpeed speed, |
552 SessionStateAnimator::AnimationSequence* animation_sequence) { | 552 SessionStateAnimator::AnimationSequence* animation_sequence) { |
553 if (unlocked_properties_.get() && unlocked_properties_->wallpaper_is_hidden) { | 553 if (unlocked_properties_.get() && unlocked_properties_->wallpaper_is_hidden) { |
554 animation_sequence->StartAnimation(SessionStateAnimator::WALLPAPER, | 554 animation_sequence->StartAnimation(SessionStateAnimator::WALLPAPER, |
555 SessionStateAnimator::ANIMATION_FADE_OUT, | 555 SessionStateAnimator::ANIMATION_FADE_OUT, |
556 speed); | 556 speed); |
557 } | 557 } |
558 } | 558 } |
559 | 559 |
560 } // namespace ash | 560 } // namespace ash |
OLD | NEW |