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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "athena/system/power_button_controller.h" 5 #include "athena/system/power_button_controller.h"
6 6
7 #include "athena/screen/public/screen_animator.h"
8 #include "athena/screen/public/screen_manager.h"
7 #include "chromeos/dbus/dbus_thread_manager.h" 9 #include "chromeos/dbus/dbus_thread_manager.h"
8 10
9 namespace athena { 11 namespace athena {
10 12
11 PowerButtonController::PowerButtonController() 13 PowerButtonController::PowerButtonController()
12 : brightness_is_zero_(false), 14 : animator_(ScreenManager::Get()->CreateScreenAnimator()),
13 shutdown_requested_(false) { 15 brightness_is_zero_(false),
16 state_(STATE_OTHER) {
14 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver( 17 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(
15 this); 18 this);
16 } 19 }
17 20
18 PowerButtonController::~PowerButtonController() { 21 PowerButtonController::~PowerButtonController() {
19 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver( 22 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(
20 this); 23 this);
21 } 24 }
22 25
23 void PowerButtonController::BrightnessChanged(int level, bool user_initiated) { 26 void PowerButtonController::BrightnessChanged(int level, bool user_initiated) {
24 if (brightness_is_zero_) 27 if (brightness_is_zero_)
25 zero_brightness_end_time_ = base::TimeTicks::Now(); 28 zero_brightness_end_time_ = base::TimeTicks::Now();
26 brightness_is_zero_ = (level == 0); 29 brightness_is_zero_ = (level == 0);
27 } 30 }
28 31
29 void PowerButtonController::PowerButtonEventReceived( 32 void PowerButtonController::PowerButtonEventReceived(
30 bool down, 33 bool down,
31 const base::TimeTicks& details) { 34 const base::TimeTicks& timestamp) {
32 // Avoid requesting a shutdown if the power button is pressed while the screen 35 // Avoid requesting a shutdown if the power button is pressed while the screen
33 // is off (http://crbug.com/128451) 36 // is off (http://crbug.com/128451)
34 base::TimeDelta time_since_zero_brightness = brightness_is_zero_ ? 37 base::TimeDelta time_since_zero_brightness = brightness_is_zero_ ?
35 base::TimeDelta() : (base::TimeTicks::Now() - zero_brightness_end_time_); 38 base::TimeDelta() : (base::TimeTicks::Now() - zero_brightness_end_time_);
36 const int kShortTimeMs = 10; 39 const int kShortTimeMs = 10;
37 if (time_since_zero_brightness.InMilliseconds() <= kShortTimeMs) 40 if (time_since_zero_brightness.InMilliseconds() <= kShortTimeMs)
38 return; 41 return;
39 42
40 if (down && !shutdown_requested_) { 43 if (state_ == STATE_SHUTDOWN_REQUESTED)
41 shutdown_requested_ = true; 44 return;
42 chromeos::DBusThreadManager::Get() 45
43 ->GetPowerManagerClient() 46 StopObservingImplicitAnimations();
44 ->RequestShutdown(); 47 if (down) {
48 state_ = STATE_PRE_SHUTDOWN_ANIMATION;
49 animator_->StartAnimation(ScreenAnimator::ANIMATION_SHUTDOWN, this);
50 } else {
51 state_ = STATE_OTHER;
52 animator_->StartAnimation(ScreenAnimator::ANIMATION_CANCEL_SHUTDOWN, NULL);
45 } 53 }
46 } 54 }
47 55
56 void PowerButtonController::OnImplicitAnimationsCompleted() {
57 DCHECK_EQ(STATE_PRE_SHUTDOWN_ANIMATION, state_);
58 state_ = STATE_SHUTDOWN_REQUESTED;
59 chromeos::DBusThreadManager::Get()
60 ->GetPowerManagerClient()
61 ->RequestShutdown();
62 }
63
48 } // namespace athena 64 } // namespace athena
OLDNEW
« 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