| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/power_button_controller.h" | 5 #include "ash/wm/power_button_controller.h" |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/shell_delegate.h" | 9 #include "ash/shell_delegate.h" |
| 10 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
| 11 #include "ash/wm/session_state_animator.h" | 11 #include "ash/wm/session_state_animator.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "ui/aura/root_window.h" | 13 #include "ui/aura/root_window.h" |
| 14 #include "ui/aura/shared/compound_event_filter.h" | 14 #include "ui/aura/shared/compound_event_filter.h" |
| 15 | 15 |
| 16 #if defined(OS_CHROMEOS) | |
| 17 #include "base/chromeos/chromeos_version.h" | |
| 18 #endif | |
| 19 | |
| 20 namespace ash { | 16 namespace ash { |
| 21 | 17 |
| 22 namespace { | 18 namespace { |
| 23 | 19 |
| 24 // Amount of time that the power button needs to be held before we lock the | 20 // Amount of time that the power button needs to be held before we lock the |
| 25 // screen. | 21 // screen. |
| 26 const int kLockTimeoutMs = 400; | 22 const int kLockTimeoutMs = 400; |
| 27 | 23 |
| 28 // Amount of time that the power button needs to be held before we shut down. | 24 // Amount of time that the power button needs to be held before we shut down. |
| 29 const int kShutdownTimeoutMs = 400; | 25 const int kShutdownTimeoutMs = 400; |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 StartShutdownTimer(); | 300 StartShutdownTimer(); |
| 305 } | 301 } |
| 306 | 302 |
| 307 void PowerButtonController::OnShutdownTimeout() { | 303 void PowerButtonController::OnShutdownTimeout() { |
| 308 if (!shutting_down_) | 304 if (!shutting_down_) |
| 309 StartShutdownAnimationAndRequestShutdown(); | 305 StartShutdownAnimationAndRequestShutdown(); |
| 310 } | 306 } |
| 311 | 307 |
| 312 void PowerButtonController::OnRealShutdownTimeout() { | 308 void PowerButtonController::OnRealShutdownTimeout() { |
| 313 DCHECK(shutting_down_); | 309 DCHECK(shutting_down_); |
| 314 #if defined(OS_CHROMEOS) | |
| 315 if (!base::chromeos::IsRunningOnChromeOS()) { | |
| 316 ShellDelegate* delegate = Shell::GetInstance()->delegate(); | |
| 317 if (delegate) | |
| 318 delegate->Exit(); | |
| 319 } | |
| 320 #endif | |
| 321 delegate_->RequestShutdown(); | 310 delegate_->RequestShutdown(); |
| 322 } | 311 } |
| 323 | 312 |
| 324 void PowerButtonController::StartLockTimer() { | 313 void PowerButtonController::StartLockTimer() { |
| 325 animator_->ShowBlackLayer(); | 314 animator_->ShowBlackLayer(); |
| 326 animator_->StartAnimation( | 315 animator_->StartAnimation( |
| 327 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, | 316 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
| 328 internal::SessionStateAnimator::ANIMATION_SLOW_CLOSE); | 317 internal::SessionStateAnimator::ANIMATION_SLOW_CLOSE); |
| 329 lock_timer_.Stop(); | 318 lock_timer_.Stop(); |
| 330 lock_timer_.Start(FROM_HERE, | 319 lock_timer_.Start(FROM_HERE, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 } | 360 } |
| 372 | 361 |
| 373 real_shutdown_timer_.Start( | 362 real_shutdown_timer_.Start( |
| 374 FROM_HERE, | 363 FROM_HERE, |
| 375 base::TimeDelta::FromMilliseconds( | 364 base::TimeDelta::FromMilliseconds( |
| 376 kFastCloseAnimMs + kShutdownRequestDelayMs), | 365 kFastCloseAnimMs + kShutdownRequestDelayMs), |
| 377 this, &PowerButtonController::OnRealShutdownTimeout); | 366 this, &PowerButtonController::OnRealShutdownTimeout); |
| 378 } | 367 } |
| 379 | 368 |
| 380 } // namespace ash | 369 } // namespace ash |
| OLD | NEW |