| 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 StartImmediatePreLockAnimation(false /* request_lock_on_completion */); | 155 StartImmediatePreLockAnimation(false /* request_lock_on_completion */); |
| 156 } | 156 } |
| 157 | 157 |
| 158 void LockStateController::RequestShutdown() { | 158 void LockStateController::RequestShutdown() { |
| 159 if (shutting_down_) | 159 if (shutting_down_) |
| 160 return; | 160 return; |
| 161 | 161 |
| 162 shutting_down_ = true; | 162 shutting_down_ = true; |
| 163 | 163 |
| 164 Shell* shell = Shell::GetInstance(); | 164 Shell* shell = Shell::GetInstance(); |
| 165 shell->cursor_manager()->HideCursor(); | 165 // TODO(derat): Remove these null checks once mash instantiates a |
| 166 shell->cursor_manager()->LockCursor(); | 166 // CursorManager. |
| 167 if (shell->cursor_manager()) { |
| 168 shell->cursor_manager()->HideCursor(); |
| 169 shell->cursor_manager()->LockCursor(); |
| 170 } |
| 167 | 171 |
| 168 animator_->StartAnimation( | 172 animator_->StartAnimation( |
| 169 SessionStateAnimator::ROOT_CONTAINER, | 173 SessionStateAnimator::ROOT_CONTAINER, |
| 170 SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS, | 174 SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS, |
| 171 SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); | 175 SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); |
| 172 StartRealShutdownTimer(true); | 176 StartRealShutdownTimer(true); |
| 173 } | 177 } |
| 174 | 178 |
| 175 void LockStateController::OnLockScreenHide( | 179 void LockStateController::OnLockScreenHide( |
| 176 base::Callback<void(void)>& callback) { | 180 base::Callback<void(void)>& callback) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 193 system_is_locked_ = (status == LoginStatus::LOCKED); | 197 system_is_locked_ = (status == LoginStatus::LOCKED); |
| 194 } | 198 } |
| 195 | 199 |
| 196 void LockStateController::OnAppTerminating() { | 200 void LockStateController::OnAppTerminating() { |
| 197 // If we hear that Chrome is exiting but didn't request it ourselves, all we | 201 // If we hear that Chrome is exiting but didn't request it ourselves, all we |
| 198 // can really hope for is that we'll have time to clear the screen. | 202 // can really hope for is that we'll have time to clear the screen. |
| 199 // This is also the case when the user signs off. | 203 // This is also the case when the user signs off. |
| 200 if (!shutting_down_) { | 204 if (!shutting_down_) { |
| 201 shutting_down_ = true; | 205 shutting_down_ = true; |
| 202 Shell* shell = Shell::GetInstance(); | 206 Shell* shell = Shell::GetInstance(); |
| 203 shell->cursor_manager()->HideCursor(); | 207 if (shell->cursor_manager()) { |
| 204 shell->cursor_manager()->LockCursor(); | 208 shell->cursor_manager()->HideCursor(); |
| 209 shell->cursor_manager()->LockCursor(); |
| 210 } |
| 205 animator_->StartAnimation(SessionStateAnimator::kAllNonRootContainersMask, | 211 animator_->StartAnimation(SessionStateAnimator::kAllNonRootContainersMask, |
| 206 SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY, | 212 SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY, |
| 207 SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); | 213 SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); |
| 208 } | 214 } |
| 209 } | 215 } |
| 210 | 216 |
| 211 void LockStateController::OnLockStateChanged(bool locked) { | 217 void LockStateController::OnLockStateChanged(bool locked) { |
| 212 DCHECK((lock_fail_timer_.IsRunning() && lock_duration_timer_ != nullptr) || | 218 DCHECK((lock_fail_timer_.IsRunning() && lock_duration_timer_ != nullptr) || |
| 213 (!lock_fail_timer_.IsRunning() && lock_duration_timer_ == nullptr)); | 219 (!lock_fail_timer_.IsRunning() && lock_duration_timer_ == nullptr)); |
| 214 VLOG(1) << "OnLockStateChanged called with locked: " << locked | 220 VLOG(1) << "OnLockStateChanged called with locked: " << locked |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 FROM_HERE, | 270 FROM_HERE, |
| 265 animator_->GetDuration(SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN), | 271 animator_->GetDuration(SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN), |
| 266 this, &LockStateController::OnPreShutdownAnimationTimeout); | 272 this, &LockStateController::OnPreShutdownAnimationTimeout); |
| 267 } | 273 } |
| 268 | 274 |
| 269 void LockStateController::OnPreShutdownAnimationTimeout() { | 275 void LockStateController::OnPreShutdownAnimationTimeout() { |
| 270 VLOG(1) << "OnPreShutdownAnimationTimeout"; | 276 VLOG(1) << "OnPreShutdownAnimationTimeout"; |
| 271 shutting_down_ = true; | 277 shutting_down_ = true; |
| 272 | 278 |
| 273 Shell* shell = Shell::GetInstance(); | 279 Shell* shell = Shell::GetInstance(); |
| 274 shell->cursor_manager()->HideCursor(); | 280 if (shell->cursor_manager()) |
| 281 shell->cursor_manager()->HideCursor(); |
| 275 | 282 |
| 276 StartRealShutdownTimer(false); | 283 StartRealShutdownTimer(false); |
| 277 } | 284 } |
| 278 | 285 |
| 279 void LockStateController::StartRealShutdownTimer(bool with_animation_time) { | 286 void LockStateController::StartRealShutdownTimer(bool with_animation_time) { |
| 280 base::TimeDelta duration = | 287 base::TimeDelta duration = |
| 281 base::TimeDelta::FromMilliseconds(kShutdownRequestDelayMs); | 288 base::TimeDelta::FromMilliseconds(kShutdownRequestDelayMs); |
| 282 if (with_animation_time) { | 289 if (with_animation_time) { |
| 283 duration += | 290 duration += |
| 284 animator_->GetDuration(SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); | 291 animator_->GetDuration(SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 300 VLOG(1) << "OnRealPowerTimeout"; | 307 VLOG(1) << "OnRealPowerTimeout"; |
| 301 DCHECK(shutting_down_); | 308 DCHECK(shutting_down_); |
| 302 WmShell::Get()->RecordUserMetricsAction(UMA_ACCEL_SHUT_DOWN_POWER_BUTTON); | 309 WmShell::Get()->RecordUserMetricsAction(UMA_ACCEL_SHUT_DOWN_POWER_BUTTON); |
| 303 // Shut down or reboot based on device policy. | 310 // Shut down or reboot based on device policy. |
| 304 shutdown_controller_->ShutDownOrReboot(); | 311 shutdown_controller_->ShutDownOrReboot(); |
| 305 } | 312 } |
| 306 | 313 |
| 307 void LockStateController::StartCancellableShutdownAnimation() { | 314 void LockStateController::StartCancellableShutdownAnimation() { |
| 308 Shell* shell = Shell::GetInstance(); | 315 Shell* shell = Shell::GetInstance(); |
| 309 // Hide cursor, but let it reappear if the mouse moves. | 316 // Hide cursor, but let it reappear if the mouse moves. |
| 310 shell->cursor_manager()->HideCursor(); | 317 if (shell->cursor_manager()) |
| 318 shell->cursor_manager()->HideCursor(); |
| 311 | 319 |
| 312 animator_->StartAnimation( | 320 animator_->StartAnimation( |
| 313 SessionStateAnimator::ROOT_CONTAINER, | 321 SessionStateAnimator::ROOT_CONTAINER, |
| 314 SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS, | 322 SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS, |
| 315 SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); | 323 SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); |
| 316 StartPreShutdownAnimationTimer(); | 324 StartPreShutdownAnimationTimer(); |
| 317 } | 325 } |
| 318 | 326 |
| 319 void LockStateController::StartImmediatePreLockAnimation( | 327 void LockStateController::StartImmediatePreLockAnimation( |
| 320 bool request_lock_on_completion) { | 328 bool request_lock_on_completion) { |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 SessionStateAnimator::AnimationSpeed speed, | 559 SessionStateAnimator::AnimationSpeed speed, |
| 552 SessionStateAnimator::AnimationSequence* animation_sequence) { | 560 SessionStateAnimator::AnimationSequence* animation_sequence) { |
| 553 if (unlocked_properties_.get() && unlocked_properties_->wallpaper_is_hidden) { | 561 if (unlocked_properties_.get() && unlocked_properties_->wallpaper_is_hidden) { |
| 554 animation_sequence->StartAnimation(SessionStateAnimator::WALLPAPER, | 562 animation_sequence->StartAnimation(SessionStateAnimator::WALLPAPER, |
| 555 SessionStateAnimator::ANIMATION_FADE_OUT, | 563 SessionStateAnimator::ANIMATION_FADE_OUT, |
| 556 speed); | 564 speed); |
| 557 } | 565 } |
| 558 } | 566 } |
| 559 | 567 |
| 560 } // namespace ash | 568 } // namespace ash |
| OLD | NEW |