| 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 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 } | 82 } |
| 83 | 83 |
| 84 LockStateController::LockStateController() | 84 LockStateController::LockStateController() |
| 85 : animator_(new SessionStateAnimatorImpl()), | 85 : animator_(new SessionStateAnimatorImpl()), |
| 86 login_status_(LoginStatus::NOT_LOGGED_IN), | 86 login_status_(LoginStatus::NOT_LOGGED_IN), |
| 87 system_is_locked_(false), | 87 system_is_locked_(false), |
| 88 shutting_down_(false), | 88 shutting_down_(false), |
| 89 shutdown_after_lock_(false), | 89 shutdown_after_lock_(false), |
| 90 animating_lock_(false), | 90 animating_lock_(false), |
| 91 can_cancel_lock_animation_(false), | 91 can_cancel_lock_animation_(false), |
| 92 lock_fail_timer_is_stopped_(true), | |
| 93 weak_ptr_factory_(this) { | 92 weak_ptr_factory_(this) { |
| 94 Shell::GetPrimaryRootWindow()->GetHost()->AddObserver(this); | 93 Shell::GetPrimaryRootWindow()->GetHost()->AddObserver(this); |
| 95 } | 94 } |
| 96 | 95 |
| 97 LockStateController::~LockStateController() { | 96 LockStateController::~LockStateController() { |
| 98 Shell::GetPrimaryRootWindow()->GetHost()->RemoveObserver(this); | 97 Shell::GetPrimaryRootWindow()->GetHost()->RemoveObserver(this); |
| 99 } | 98 } |
| 100 | 99 |
| 101 void LockStateController::SetDelegate( | 100 void LockStateController::SetDelegate( |
| 102 std::unique_ptr<LockStateControllerDelegate> delegate) { | 101 std::unique_ptr<LockStateControllerDelegate> delegate) { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 131 | 130 |
| 132 void LockStateController::StartLockAnimationAndLockImmediately( | 131 void LockStateController::StartLockAnimationAndLockImmediately( |
| 133 bool shutdown_after_lock) { | 132 bool shutdown_after_lock) { |
| 134 if (animating_lock_) | 133 if (animating_lock_) |
| 135 return; | 134 return; |
| 136 shutdown_after_lock_ = shutdown_after_lock; | 135 shutdown_after_lock_ = shutdown_after_lock; |
| 137 StartImmediatePreLockAnimation(true /* request_lock_on_completion */); | 136 StartImmediatePreLockAnimation(true /* request_lock_on_completion */); |
| 138 } | 137 } |
| 139 | 138 |
| 140 bool LockStateController::LockRequested() { | 139 bool LockStateController::LockRequested() { |
| 141 // TODO(jdufault): Remove DCHECK after resolving crbug.com/452599; this is not | |
| 142 // expected to trigger. The DCHECK is only present to assert all assumptions. | |
| 143 DCHECK(lock_fail_timer_is_stopped_ != lock_fail_timer_.IsRunning()); | |
| 144 return lock_fail_timer_.IsRunning(); | 140 return lock_fail_timer_.IsRunning(); |
| 145 } | 141 } |
| 146 | 142 |
| 147 bool LockStateController::ShutdownRequested() { | 143 bool LockStateController::ShutdownRequested() { |
| 148 return shutting_down_; | 144 return shutting_down_; |
| 149 } | 145 } |
| 150 | 146 |
| 151 bool LockStateController::CanCancelLockAnimation() { | 147 bool LockStateController::CanCancelLockAnimation() { |
| 152 return can_cancel_lock_animation_; | 148 return can_cancel_lock_animation_; |
| 153 } | 149 } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 const base::Closure& callback) { | 215 const base::Closure& callback) { |
| 220 lock_screen_displayed_callback_ = callback; | 216 lock_screen_displayed_callback_ = callback; |
| 221 } | 217 } |
| 222 | 218 |
| 223 void LockStateController::OnHostCloseRequested( | 219 void LockStateController::OnHostCloseRequested( |
| 224 const aura::WindowTreeHost* host) { | 220 const aura::WindowTreeHost* host) { |
| 225 Shell::GetInstance()->delegate()->Exit(); | 221 Shell::GetInstance()->delegate()->Exit(); |
| 226 } | 222 } |
| 227 | 223 |
| 228 void LockStateController::OnLoginStateChanged(LoginStatus status) { | 224 void LockStateController::OnLoginStateChanged(LoginStatus status) { |
| 229 // TODO(jdufault): Remove after resolving crbug.com/452599. | |
| 230 VLOG(0) << "LockStateController::OnLoginStateChanged login_status_: " | |
| 231 << static_cast<int>(login_status_) | |
| 232 << ", status: " << static_cast<int>(status); | |
| 233 if (status != LoginStatus::LOCKED) | 225 if (status != LoginStatus::LOCKED) |
| 234 login_status_ = status; | 226 login_status_ = status; |
| 235 system_is_locked_ = (status == LoginStatus::LOCKED); | 227 system_is_locked_ = (status == LoginStatus::LOCKED); |
| 236 } | 228 } |
| 237 | 229 |
| 238 void LockStateController::OnAppTerminating() { | 230 void LockStateController::OnAppTerminating() { |
| 239 // If we hear that Chrome is exiting but didn't request it ourselves, all we | 231 // If we hear that Chrome is exiting but didn't request it ourselves, all we |
| 240 // can really hope for is that we'll have time to clear the screen. | 232 // can really hope for is that we'll have time to clear the screen. |
| 241 // This is also the case when the user signs off. | 233 // This is also the case when the user signs off. |
| 242 if (!shutting_down_) { | 234 if (!shutting_down_) { |
| 243 shutting_down_ = true; | 235 shutting_down_ = true; |
| 244 Shell* shell = ash::Shell::GetInstance(); | 236 Shell* shell = ash::Shell::GetInstance(); |
| 245 shell->cursor_manager()->HideCursor(); | 237 shell->cursor_manager()->HideCursor(); |
| 246 shell->cursor_manager()->LockCursor(); | 238 shell->cursor_manager()->LockCursor(); |
| 247 animator_->StartAnimation(SessionStateAnimator::kAllNonRootContainersMask, | 239 animator_->StartAnimation(SessionStateAnimator::kAllNonRootContainersMask, |
| 248 SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY, | 240 SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY, |
| 249 SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); | 241 SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); |
| 250 } | 242 } |
| 251 } | 243 } |
| 252 | 244 |
| 253 void LockStateController::OnLockStateChanged(bool locked) { | 245 void LockStateController::OnLockStateChanged(bool locked) { |
| 254 DCHECK((lock_fail_timer_.IsRunning() && lock_duration_timer_ != nullptr) || | 246 DCHECK((lock_fail_timer_.IsRunning() && lock_duration_timer_ != nullptr) || |
| 255 (!lock_fail_timer_.IsRunning() && lock_duration_timer_ == nullptr)); | 247 (!lock_fail_timer_.IsRunning() && lock_duration_timer_ == nullptr)); |
| 256 VLOG(1) << "OnLockStateChanged called with locked: " << locked | 248 VLOG(1) << "OnLockStateChanged called with locked: " << locked |
| 257 << ", shutting_down_: " << shutting_down_ | 249 << ", shutting_down_: " << shutting_down_ |
| 258 << ", system_is_locked_: " << system_is_locked_ | 250 << ", system_is_locked_: " << system_is_locked_ |
| 259 << ", lock_fail_timer_.IsRunning(): " << lock_fail_timer_.IsRunning() | 251 << ", lock_fail_timer_.IsRunning(): " << lock_fail_timer_.IsRunning(); |
| 260 << ", lock_fail_timer_is_stopped_: " << lock_fail_timer_is_stopped_; | |
| 261 | 252 |
| 262 if (shutting_down_ || (system_is_locked_ == locked)) | 253 if (shutting_down_ || (system_is_locked_ == locked)) |
| 263 return; | 254 return; |
| 264 | 255 |
| 265 system_is_locked_ = locked; | 256 system_is_locked_ = locked; |
| 266 | 257 |
| 267 if (locked) { | 258 if (locked) { |
| 268 StartPostLockAnimation(); | 259 StartPostLockAnimation(); |
| 269 | 260 |
| 270 // TODO(jdufault): Remove after resolving crbug.com/452599. | |
| 271 VLOG(0) << "Stopping lock_fail_timer_"; | |
| 272 lock_fail_timer_.Stop(); | 261 lock_fail_timer_.Stop(); |
| 273 lock_fail_timer_is_stopped_ = true; | |
| 274 | 262 |
| 275 if (lock_duration_timer_) { | 263 if (lock_duration_timer_) { |
| 276 UMA_HISTOGRAM_LOCK_TIMES("Ash.WindowManager.Lock.Success", | 264 UMA_HISTOGRAM_LOCK_TIMES("Ash.WindowManager.Lock.Success", |
| 277 lock_duration_timer_->Elapsed()); | 265 lock_duration_timer_->Elapsed()); |
| 278 lock_duration_timer_.reset(); | 266 lock_duration_timer_.reset(); |
| 279 } | 267 } |
| 280 } else { | 268 } else { |
| 281 StartUnlockAnimationAfterUIDestroyed(); | 269 StartUnlockAnimationAfterUIDestroyed(); |
| 282 } | 270 } |
| 283 } | 271 } |
| 284 | 272 |
| 285 void LockStateController::OnLockFailTimeout() { | 273 void LockStateController::OnLockFailTimeout() { |
| 286 UMA_HISTOGRAM_LOCK_TIMES("Ash.WindowManager.Lock.Timeout", | 274 UMA_HISTOGRAM_LOCK_TIMES("Ash.WindowManager.Lock.Timeout", |
| 287 lock_duration_timer_->Elapsed()); | 275 lock_duration_timer_->Elapsed()); |
| 288 lock_duration_timer_.reset(); | 276 lock_duration_timer_.reset(); |
| 289 DCHECK(!system_is_locked_); | 277 DCHECK(!system_is_locked_); |
| 290 | 278 |
| 291 std::string loading_webpage = "unknown"; | 279 LOG(FATAL) << "Screen lock took too long; crashing intentionally"; |
| 292 if (delegate_) | |
| 293 loading_webpage = delegate_->IsLoading() ? "true" : "false"; | |
| 294 | |
| 295 LOG(FATAL) << "Screen lock took too long; crashing intentionally " | |
| 296 << "(loading webpage: " << loading_webpage | |
| 297 << ", lock_fail_timer.IsRunning: " << lock_fail_timer_.IsRunning() | |
| 298 << ", lock_fail_timer_is_stopped_: " << lock_fail_timer_is_stopped_ | |
| 299 << ")"; | |
| 300 } | 280 } |
| 301 | 281 |
| 302 void LockStateController::StartLockToShutdownTimer() { | 282 void LockStateController::StartLockToShutdownTimer() { |
| 303 shutdown_after_lock_ = false; | 283 shutdown_after_lock_ = false; |
| 304 lock_to_shutdown_timer_.Stop(); | 284 lock_to_shutdown_timer_.Stop(); |
| 305 lock_to_shutdown_timer_.Start( | 285 lock_to_shutdown_timer_.Start( |
| 306 FROM_HERE, | 286 FROM_HERE, |
| 307 base::TimeDelta::FromMilliseconds(kLockToShutdownTimeoutMs), | 287 base::TimeDelta::FromMilliseconds(kLockToShutdownTimeoutMs), |
| 308 this, &LockStateController::OnLockToShutdownTimeout); | 288 this, &LockStateController::OnLockToShutdownTimeout); |
| 309 } | 289 } |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 #if defined(OS_CHROMEOS) | 530 #if defined(OS_CHROMEOS) |
| 551 // Increase lock timeout for slower hardware, see http://crbug.com/350628 | 531 // Increase lock timeout for slower hardware, see http://crbug.com/350628 |
| 552 const std::string board = base::SysInfo::GetLsbReleaseBoard(); | 532 const std::string board = base::SysInfo::GetLsbReleaseBoard(); |
| 553 if (board == "x86-mario" || | 533 if (board == "x86-mario" || |
| 554 base::StartsWith(board, "x86-alex", base::CompareCase::SENSITIVE) || | 534 base::StartsWith(board, "x86-alex", base::CompareCase::SENSITIVE) || |
| 555 base::StartsWith(board, "x86-zgb", base::CompareCase::SENSITIVE) || | 535 base::StartsWith(board, "x86-zgb", base::CompareCase::SENSITIVE) || |
| 556 base::StartsWith(board, "daisy", base::CompareCase::SENSITIVE)) { | 536 base::StartsWith(board, "daisy", base::CompareCase::SENSITIVE)) { |
| 557 timeout *= 2; | 537 timeout *= 2; |
| 558 } | 538 } |
| 559 #endif | 539 #endif |
| 560 // TODO(jdufault): Remove after resolving crbug.com/452599. | |
| 561 VLOG(0) << "Starting LockFailTimer with a timeout of " << timeout << "s"; | |
| 562 lock_fail_timer_.Start( | 540 lock_fail_timer_.Start( |
| 563 FROM_HERE, timeout, this, &LockStateController::OnLockFailTimeout); | 541 FROM_HERE, timeout, this, &LockStateController::OnLockFailTimeout); |
| 564 lock_fail_timer_is_stopped_ = false; | |
| 565 | 542 |
| 566 lock_duration_timer_.reset(new base::ElapsedTimer()); | 543 lock_duration_timer_.reset(new base::ElapsedTimer()); |
| 567 } | 544 } |
| 568 | 545 |
| 569 void LockStateController::PostLockAnimationFinished() { | 546 void LockStateController::PostLockAnimationFinished() { |
| 570 animating_lock_ = false; | 547 animating_lock_ = false; |
| 571 VLOG(1) << "PostLockAnimationFinished"; | 548 VLOG(1) << "PostLockAnimationFinished"; |
| 572 FOR_EACH_OBSERVER(LockStateObserver, observers_, | 549 FOR_EACH_OBSERVER(LockStateObserver, observers_, |
| 573 OnLockStateEvent(LockStateObserver::EVENT_LOCK_ANIMATION_FINISHED)); | 550 OnLockStateEvent(LockStateObserver::EVENT_LOCK_ANIMATION_FINISHED)); |
| 574 if (!lock_screen_displayed_callback_.is_null()) { | 551 if (!lock_screen_displayed_callback_.is_null()) { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 if (unlocked_properties_.get() && | 609 if (unlocked_properties_.get() && |
| 633 unlocked_properties_->background_is_hidden) { | 610 unlocked_properties_->background_is_hidden) { |
| 634 animation_sequence->StartAnimation( | 611 animation_sequence->StartAnimation( |
| 635 SessionStateAnimator::DESKTOP_BACKGROUND, | 612 SessionStateAnimator::DESKTOP_BACKGROUND, |
| 636 SessionStateAnimator::ANIMATION_FADE_OUT, | 613 SessionStateAnimator::ANIMATION_FADE_OUT, |
| 637 speed); | 614 speed); |
| 638 } | 615 } |
| 639 } | 616 } |
| 640 | 617 |
| 641 } // namespace ash | 618 } // namespace ash |
| OLD | NEW |