OLD | NEW |
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 #ifndef ATHENA_SYSTEM_POWER_BUTTON_CONTROLLER_H_ | 5 #ifndef ATHENA_SYSTEM_POWER_BUTTON_CONTROLLER_H_ |
6 #define ATHENA_SYSTEM_POWER_BUTTON_CONTROLLER_H_ | 6 #define ATHENA_SYSTEM_POWER_BUTTON_CONTROLLER_H_ |
7 | 7 |
| 8 #include "base/time/time.h" |
8 #include "chromeos/dbus/power_manager_client.h" | 9 #include "chromeos/dbus/power_manager_client.h" |
| 10 #include "ui/compositor/layer_animation_observer.h" |
9 | 11 |
10 namespace athena { | 12 namespace athena { |
11 | 13 |
12 // Shuts down in response to the power button being pressed. | 14 // Shuts down in response to the power button being pressed. |
13 class PowerButtonController : public chromeos::PowerManagerClient::Observer { | 15 class PowerButtonController : public chromeos::PowerManagerClient::Observer, |
| 16 public ui::ImplicitAnimationObserver { |
14 public: | 17 public: |
15 PowerButtonController(); | 18 PowerButtonController(); |
16 virtual ~PowerButtonController(); | 19 virtual ~PowerButtonController(); |
17 | 20 |
| 21 private: |
| 22 // Starts an animation of the root window to |target| brightness and |
| 23 // grayscale. |
| 24 void StartGrayscaleAndBrightnessAnimation(float target, |
| 25 int duration_ms, |
| 26 gfx::Tween::Type tween_type); |
| 27 |
| 28 // Requests system shutdown on the D-Bus. |
| 29 void Shutdown(); |
| 30 |
18 // chromeos::PowerManagerClient::Observer: | 31 // chromeos::PowerManagerClient::Observer: |
19 virtual void BrightnessChanged(int level, bool user_initiated) OVERRIDE; | 32 virtual void BrightnessChanged(int level, bool user_initiated) OVERRIDE; |
20 virtual void PowerButtonEventReceived( | 33 virtual void PowerButtonEventReceived( |
21 bool down, | 34 bool down, |
22 const base::TimeTicks& timestamp) OVERRIDE; | 35 const base::TimeTicks& timestamp) OVERRIDE; |
23 | 36 |
24 private: | 37 // ui::ImplicitAnimationObserver: |
| 38 virtual void OnImplicitAnimationsCompleted() OVERRIDE; |
| 39 |
25 // Whether the screen brightness was reduced to 0%. | 40 // Whether the screen brightness was reduced to 0%. |
26 bool brightness_is_zero_; | 41 bool brightness_is_zero_; |
27 | 42 |
28 // The last time at which the screen brightness was 0%. | 43 // The last time at which the screen brightness was 0%. |
29 base::TimeTicks zero_brightness_end_time_; | 44 base::TimeTicks zero_brightness_end_time_; |
30 | 45 |
31 // Whether shutdown was requested. | 46 // Whether shutdown was requested. |
32 bool shutdown_requested_; | 47 bool shutdown_requested_; |
33 | 48 |
| 49 // Whether the shutdown request can be canceled. |
| 50 bool can_cancel_shutdown_; |
| 51 |
34 DISALLOW_COPY_AND_ASSIGN(PowerButtonController); | 52 DISALLOW_COPY_AND_ASSIGN(PowerButtonController); |
35 }; | 53 }; |
36 | 54 |
37 } // namespace athena | 55 } // namespace athena |
38 | 56 |
39 #endif // ATHENA_SYSTEM_POWER_BUTTON_CONTROLLER_H_ | 57 #endif // ATHENA_SYSTEM_POWER_BUTTON_CONTROLLER_H_ |
OLD | NEW |