Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(171)

Side by Side Diff: ash/wm/lock_state_controller.cc

Issue 435083002: ash: Fix a screen-locking crash. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: diff against correct branch again Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
591 // Don't do anything (including starting the lock-fail timer) if the screen
592 // was already locked while the animation was going.
593 if (system_is_locked_) {
594 DCHECK(!request_lock) << "Got request to lock already-locked system "
595 << "at completion of pre-lock animation";
596 return;
597 }
598
589 if (request_lock) { 599 if (request_lock) {
590 Shell::GetInstance()->metrics()->RecordUserMetricsAction( 600 Shell::GetInstance()->metrics()->RecordUserMetricsAction(
591 shutdown_after_lock_ ? 601 shutdown_after_lock_ ?
592 UMA_ACCEL_LOCK_SCREEN_POWER_BUTTON : 602 UMA_ACCEL_LOCK_SCREEN_POWER_BUTTON :
593 UMA_ACCEL_LOCK_SCREEN_LOCK_BUTTON); 603 UMA_ACCEL_LOCK_SCREEN_LOCK_BUTTON);
594 delegate_->RequestLockScreen(); 604 delegate_->RequestLockScreen();
595 } 605 }
596 606
597 int lock_timeout = kLockFailTimeoutMs; 607 base::TimeDelta timeout =
598 608 base::TimeDelta::FromMilliseconds(kLockFailTimeoutMs);
599 #if defined(OS_CHROMEOS) 609 #if defined(OS_CHROMEOS)
600 std::string board = base::SysInfo::GetLsbReleaseBoard();
601
602 // Increase lock timeout for slower hardware, see http://crbug.com/350628 610 // Increase lock timeout for slower hardware, see http://crbug.com/350628
611 const std::string board = base::SysInfo::GetLsbReleaseBoard();
603 if (board == "x86-mario" || 612 if (board == "x86-mario" ||
604 board.substr(0, 8) == "x86-alex" || 613 StartsWithASCII(board, "x86-alex", true /* case_sensitive */) ||
605 board.substr(0, 7) == "x86-zgb") { 614 StartsWithASCII(board, "x86-zgb", true /* case_sensitive */)) {
606 lock_timeout *= 2; 615 timeout *= 2;
607 } 616 }
608 #endif 617 #endif
609
610 lock_fail_timer_.Start( 618 lock_fail_timer_.Start(
611 FROM_HERE, 619 FROM_HERE, timeout, this, &LockStateController::OnLockFailTimeout);
612 base::TimeDelta::FromMilliseconds(lock_timeout),
613 this,
614 &LockStateController::OnLockFailTimeout);
615 } 620 }
616 621
617 void LockStateController::PostLockAnimationFinished() { 622 void LockStateController::PostLockAnimationFinished() {
618 animating_lock_ = false; 623 animating_lock_ = false;
619 VLOG(1) << "PostLockAnimationFinished"; 624 VLOG(1) << "PostLockAnimationFinished";
620 FOR_EACH_OBSERVER(LockStateObserver, observers_, 625 FOR_EACH_OBSERVER(LockStateObserver, observers_,
621 OnLockStateEvent(LockStateObserver::EVENT_LOCK_ANIMATION_FINISHED)); 626 OnLockStateEvent(LockStateObserver::EVENT_LOCK_ANIMATION_FINISHED));
622 if (!lock_screen_displayed_callback_.is_null()) { 627 if (!lock_screen_displayed_callback_.is_null()) {
623 lock_screen_displayed_callback_.Run(); 628 lock_screen_displayed_callback_.Run();
624 lock_screen_displayed_callback_.Reset(); 629 lock_screen_displayed_callback_.Reset();
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 unlocked_properties_->background_is_hidden) { 686 unlocked_properties_->background_is_hidden) {
682 animator_->StartAnimationWithObserver( 687 animator_->StartAnimationWithObserver(
683 SessionStateAnimator::DESKTOP_BACKGROUND, 688 SessionStateAnimator::DESKTOP_BACKGROUND,
684 SessionStateAnimator::ANIMATION_FADE_OUT, 689 SessionStateAnimator::ANIMATION_FADE_OUT,
685 speed, 690 speed,
686 observer); 691 observer);
687 } 692 }
688 } 693 }
689 694
690 } // namespace ash 695 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698