| Index: athena/system/power_button_controller.cc
|
| diff --git a/athena/system/power_button_controller.cc b/athena/system/power_button_controller.cc
|
| index c54ca46419af9bc7481d2a02ec9f42e08ee8942d..bcafa1c61a45f6f35d699ed91927f8d6e1583704 100644
|
| --- a/athena/system/power_button_controller.cc
|
| +++ b/athena/system/power_button_controller.cc
|
| @@ -4,13 +4,16 @@
|
|
|
| #include "athena/system/power_button_controller.h"
|
|
|
| +#include "athena/screen/public/screen_animator.h"
|
| +#include "athena/screen/public/screen_manager.h"
|
| #include "chromeos/dbus/dbus_thread_manager.h"
|
|
|
| namespace athena {
|
|
|
| PowerButtonController::PowerButtonController()
|
| - : brightness_is_zero_(false),
|
| - shutdown_requested_(false) {
|
| + : animator_(ScreenManager::Get()->CreateScreenAnimator()),
|
| + brightness_is_zero_(false),
|
| + state_(STATE_OTHER) {
|
| chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(
|
| this);
|
| }
|
| @@ -28,7 +31,7 @@ void PowerButtonController::BrightnessChanged(int level, bool user_initiated) {
|
|
|
| void PowerButtonController::PowerButtonEventReceived(
|
| bool down,
|
| - const base::TimeTicks& details) {
|
| + const base::TimeTicks& timestamp) {
|
| // Avoid requesting a shutdown if the power button is pressed while the screen
|
| // is off (http://crbug.com/128451)
|
| base::TimeDelta time_since_zero_brightness = brightness_is_zero_ ?
|
| @@ -37,12 +40,25 @@ void PowerButtonController::PowerButtonEventReceived(
|
| if (time_since_zero_brightness.InMilliseconds() <= kShortTimeMs)
|
| return;
|
|
|
| - if (down && !shutdown_requested_) {
|
| - shutdown_requested_ = true;
|
| - chromeos::DBusThreadManager::Get()
|
| - ->GetPowerManagerClient()
|
| - ->RequestShutdown();
|
| + if (state_ == STATE_SHUTDOWN_REQUESTED)
|
| + return;
|
| +
|
| + StopObservingImplicitAnimations();
|
| + if (down) {
|
| + state_ = STATE_PRE_SHUTDOWN_ANIMATION;
|
| + animator_->StartAnimation(ScreenAnimator::ANIMATION_SHUTDOWN, this);
|
| + } else {
|
| + state_ = STATE_OTHER;
|
| + animator_->StartAnimation(ScreenAnimator::ANIMATION_CANCEL_SHUTDOWN, NULL);
|
| }
|
| }
|
|
|
| +void PowerButtonController::OnImplicitAnimationsCompleted() {
|
| + DCHECK_EQ(STATE_PRE_SHUTDOWN_ANIMATION, state_);
|
| + state_ = STATE_SHUTDOWN_REQUESTED;
|
| + chromeos::DBusThreadManager::Get()
|
| + ->GetPowerManagerClient()
|
| + ->RequestShutdown();
|
| +}
|
| +
|
| } // namespace athena
|
|
|