Chromium Code Reviews| 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 if (!request_lock) |
| 589 if (request_lock) { | 591 return; |
| 590 Shell::GetInstance()->metrics()->RecordUserMetricsAction( | 592 |
| 591 shutdown_after_lock_ ? | 593 if (system_is_locked_) { |
|
Daniel Erat
2014/08/01 22:55:07
another option would be structuring the body of th
| |
| 592 UMA_ACCEL_LOCK_SCREEN_POWER_BUTTON : | 594 LOG(DFATAL) << "Got request to lock already-locked system at completion " |
| 593 UMA_ACCEL_LOCK_SCREEN_LOCK_BUTTON); | 595 << "of pre-lock animation"; |
| 594 delegate_->RequestLockScreen(); | 596 return; |
| 595 } | 597 } |
| 596 | 598 |
| 597 int lock_timeout = kLockFailTimeoutMs; | 599 Shell::GetInstance()->metrics()->RecordUserMetricsAction( |
| 600 shutdown_after_lock_ ? | |
| 601 UMA_ACCEL_LOCK_SCREEN_POWER_BUTTON : | |
| 602 UMA_ACCEL_LOCK_SCREEN_LOCK_BUTTON); | |
| 603 delegate_->RequestLockScreen(); | |
| 598 | 604 |
| 605 base::TimeDelta timeout = | |
| 606 base::TimeDelta::FromMilliseconds(kLockFailTimeoutMs); | |
| 599 #if defined(OS_CHROMEOS) | 607 #if defined(OS_CHROMEOS) |
| 600 std::string board = base::SysInfo::GetLsbReleaseBoard(); | |
| 601 | |
| 602 // Increase lock timeout for slower hardware, see http://crbug.com/350628 | 608 // Increase lock timeout for slower hardware, see http://crbug.com/350628 |
| 609 const std::string board = base::SysInfo::GetLsbReleaseBoard(); | |
| 603 if (board == "x86-mario" || | 610 if (board == "x86-mario" || |
| 604 board.substr(0, 8) == "x86-alex" || | 611 StartsWithASCII(board, "x86-alex", true) || |
| 605 board.substr(0, 7) == "x86-zgb") { | 612 StartsWithASCII(board, "x86-zgb", true)) { |
| 606 lock_timeout *= 2; | 613 timeout *= 2; |
| 607 } | 614 } |
| 608 #endif | 615 #endif |
| 609 | |
| 610 lock_fail_timer_.Start( | 616 lock_fail_timer_.Start( |
| 611 FROM_HERE, | 617 FROM_HERE, timeout, this, &LockStateController::OnLockFailTimeout); |
| 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 |