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

Unified Diff: athena/system/power_button_controller.cc

Issue 451753002: Add fade to white animation when power button is pressed on Athena (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 side-by-side diff with in-line comments
Download patch
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
« athena/screen/public/screen_manager.h ('K') | « athena/system/power_button_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698