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 | 8 |
9 #include "ash/accessibility_delegate.h" | 9 #include "ash/accessibility_delegate.h" |
10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
11 #include "ash/cancel_mode.h" | 11 #include "ash/cancel_mode.h" |
12 #include "ash/metrics/user_metrics_recorder.h" | 12 #include "ash/metrics/user_metrics_recorder.h" |
13 #include "ash/shell.h" | 13 #include "ash/shell.h" |
14 #include "ash/shell_delegate.h" | 14 #include "ash/shell_delegate.h" |
15 #include "ash/shell_window_ids.h" | 15 #include "ash/shell_window_ids.h" |
16 #include "ash/wm/session_state_animator.h" | 16 #include "ash/wm/session_state_animator.h" |
17 #include "base/bind_helpers.h" | 17 #include "base/bind_helpers.h" |
18 #include "base/command_line.h" | 18 #include "base/command_line.h" |
19 #include "base/strings/string_util.h" | |
19 #include "base/timer/timer.h" | 20 #include "base/timer/timer.h" |
20 #include "ui/aura/window_tree_host.h" | 21 #include "ui/aura/window_tree_host.h" |
21 #include "ui/compositor/layer_animation_sequence.h" | 22 #include "ui/compositor/layer_animation_sequence.h" |
22 #include "ui/compositor/scoped_layer_animation_settings.h" | 23 #include "ui/compositor/scoped_layer_animation_settings.h" |
23 #include "ui/views/controls/menu/menu_controller.h" | 24 #include "ui/views/controls/menu/menu_controller.h" |
24 #include "ui/wm/core/compound_event_filter.h" | 25 #include "ui/wm/core/compound_event_filter.h" |
25 | 26 |
26 #if defined(OS_CHROMEOS) | 27 #if defined(OS_CHROMEOS) |
27 #include "base/sys_info.h" | 28 #include "base/sys_info.h" |
28 #include "media/audio/sounds/sounds_manager.h" | 29 #include "media/audio/sounds/sounds_manager.h" |
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
577 SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, observer); | 578 SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, observer); |
578 observer->Unpause(); | 579 observer->Unpause(); |
579 } | 580 } |
580 | 581 |
581 void LockStateController::LockAnimationCancelled() { | 582 void LockStateController::LockAnimationCancelled() { |
582 can_cancel_lock_animation_ = false; | 583 can_cancel_lock_animation_ = false; |
583 RestoreUnlockedProperties(); | 584 RestoreUnlockedProperties(); |
584 } | 585 } |
585 | 586 |
586 void LockStateController::PreLockAnimationFinished(bool request_lock) { | 587 void LockStateController::PreLockAnimationFinished(bool request_lock) { |
588 VLOG(1) << "PreLockAnimationFinished"; | |
587 can_cancel_lock_animation_ = false; | 589 can_cancel_lock_animation_ = false; |
588 VLOG(1) << "PreLockAnimationFinished"; | 590 |
589 if (request_lock) { | 591 if (request_lock) { |
592 DCHECK(!system_is_locked_) << "Got request to lock already-locked system " | |
593 << "at completion of pre-lock animation"; | |
590 Shell::GetInstance()->metrics()->RecordUserMetricsAction( | 594 Shell::GetInstance()->metrics()->RecordUserMetricsAction( |
591 shutdown_after_lock_ ? | 595 shutdown_after_lock_ ? |
592 UMA_ACCEL_LOCK_SCREEN_POWER_BUTTON : | 596 UMA_ACCEL_LOCK_SCREEN_POWER_BUTTON : |
593 UMA_ACCEL_LOCK_SCREEN_LOCK_BUTTON); | 597 UMA_ACCEL_LOCK_SCREEN_LOCK_BUTTON); |
594 delegate_->RequestLockScreen(); | 598 delegate_->RequestLockScreen(); |
595 } | 599 } |
596 | 600 |
597 int lock_timeout = kLockFailTimeoutMs; | 601 // Don't start the lock-fail timer if the screen was already locked while the |
598 | 602 // animation was going. |
603 if (!system_is_locked_) { | |
stevenjb
2014/08/01 23:23:56
nit: Early exit
Daniel Erat
2014/08/01 23:52:06
Done.
| |
604 base::TimeDelta timeout = | |
605 base::TimeDelta::FromMilliseconds(kLockFailTimeoutMs); | |
599 #if defined(OS_CHROMEOS) | 606 #if defined(OS_CHROMEOS) |
600 std::string board = base::SysInfo::GetLsbReleaseBoard(); | 607 // Increase lock timeout for slower hardware, see http://crbug.com/350628 |
601 | 608 const std::string board = base::SysInfo::GetLsbReleaseBoard(); |
602 // Increase lock timeout for slower hardware, see http://crbug.com/350628 | 609 if (board == "x86-mario" || |
603 if (board == "x86-mario" || | 610 StartsWithASCII(board, "x86-alex", true) || |
604 board.substr(0, 8) == "x86-alex" || | 611 StartsWithASCII(board, "x86-zgb", true)) { |
stevenjb
2014/08/01 23:23:56
nit: what is "true"?
Daniel Erat
2014/08/01 23:52:06
done (but just because it still fits without wrapp
| |
605 board.substr(0, 7) == "x86-zgb") { | 612 timeout *= 2; |
606 lock_timeout *= 2; | 613 } |
614 #endif | |
615 lock_fail_timer_.Start( | |
616 FROM_HERE, timeout, this, &LockStateController::OnLockFailTimeout); | |
607 } | 617 } |
608 #endif | |
609 | |
610 lock_fail_timer_.Start( | |
611 FROM_HERE, | |
612 base::TimeDelta::FromMilliseconds(lock_timeout), | |
613 this, | |
614 &LockStateController::OnLockFailTimeout); | |
615 } | 618 } |
616 | 619 |
617 void LockStateController::PostLockAnimationFinished() { | 620 void LockStateController::PostLockAnimationFinished() { |
618 animating_lock_ = false; | 621 animating_lock_ = false; |
619 VLOG(1) << "PostLockAnimationFinished"; | 622 VLOG(1) << "PostLockAnimationFinished"; |
620 FOR_EACH_OBSERVER(LockStateObserver, observers_, | 623 FOR_EACH_OBSERVER(LockStateObserver, observers_, |
621 OnLockStateEvent(LockStateObserver::EVENT_LOCK_ANIMATION_FINISHED)); | 624 OnLockStateEvent(LockStateObserver::EVENT_LOCK_ANIMATION_FINISHED)); |
622 if (!lock_screen_displayed_callback_.is_null()) { | 625 if (!lock_screen_displayed_callback_.is_null()) { |
623 lock_screen_displayed_callback_.Run(); | 626 lock_screen_displayed_callback_.Run(); |
624 lock_screen_displayed_callback_.Reset(); | 627 lock_screen_displayed_callback_.Reset(); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
681 unlocked_properties_->background_is_hidden) { | 684 unlocked_properties_->background_is_hidden) { |
682 animator_->StartAnimationWithObserver( | 685 animator_->StartAnimationWithObserver( |
683 SessionStateAnimator::DESKTOP_BACKGROUND, | 686 SessionStateAnimator::DESKTOP_BACKGROUND, |
684 SessionStateAnimator::ANIMATION_FADE_OUT, | 687 SessionStateAnimator::ANIMATION_FADE_OUT, |
685 speed, | 688 speed, |
686 observer); | 689 observer); |
687 } | 690 } |
688 } | 691 } |
689 | 692 |
690 } // namespace ash | 693 } // namespace ash |
OLD | NEW |