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 "athena/input/public/input_manager.h" | |
8 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
9 #include "base/time/time.h" | 10 #include "base/time/time.h" |
10 #include "base/timer/timer.h" | 11 #include "base/timer/timer.h" |
11 #include "chromeos/dbus/power_manager_client.h" | |
12 | 12 |
13 namespace aura { | 13 namespace aura { |
14 class Window; | 14 class Window; |
15 } | 15 } |
16 | 16 |
17 namespace views { | 17 namespace views { |
18 class Widget; | 18 class Widget; |
19 } | 19 } |
20 | 20 |
21 namespace athena { | 21 namespace athena { |
22 | 22 |
23 // Shuts down in response to the power button being pressed. | 23 // Shuts down in response to the power button being pressed. |
24 class PowerButtonController : public chromeos::PowerManagerClient::Observer { | 24 class PowerButtonController : public PowerButtonObserver { |
oshima
2014/10/15 22:28:53
This class should probably be renamed to something
| |
25 public: | 25 public: |
26 explicit PowerButtonController(aura::Window* dialog_container); | 26 explicit PowerButtonController(aura::Window* dialog_container); |
27 virtual ~PowerButtonController(); | 27 virtual ~PowerButtonController(); |
28 | 28 |
29 private: | 29 private: |
30 enum State { | 30 enum State { |
31 // Releasing the power button sends a suspend request. | 31 // Releasing the power button sends a suspend request. |
32 STATE_SUSPEND_ON_RELEASE, | 32 STATE_SUSPEND_ON_RELEASE, |
33 | 33 |
34 // A warning that the device is about to be shutdown is visible. Releasing | 34 // A warning that the device is about to be shutdown is visible. Releasing |
35 // the power button does not send a suspend or a shutdown request. | 35 // the power button does not send a suspend or a shutdown request. |
36 STATE_SHUTDOWN_WARNING_VISIBLE, | 36 STATE_SHUTDOWN_WARNING_VISIBLE, |
37 | 37 |
38 // A D-Bus shutdown request has been sent. Shutdown cannot be canceled. | 38 // A D-Bus shutdown request has been sent. Shutdown cannot be canceled. |
39 STATE_SHUTDOWN_REQUESTED, | 39 STATE_SHUTDOWN_REQUESTED, |
40 | 40 |
41 STATE_OTHER | 41 STATE_OTHER |
42 }; | 42 }; |
43 | 43 |
44 // Shows the shutdown warning dialog. | 44 // Shows the shutdown warning dialog. |
45 void ShowShutdownWarningDialog(); | 45 void ShowShutdownWarningDialog(); |
46 | 46 |
47 // Requests shutdown. | 47 // Requests shutdown. |
48 void Shutdown(); | 48 void Shutdown(); |
49 | 49 |
50 // chromeos::PowerManagerClient::Observer: | 50 // PowerButtonObserver: |
51 virtual void BrightnessChanged(int level, bool user_initiated) override; | 51 virtual void OnPowerButtonStateChanged( |
52 virtual void PowerButtonEventReceived( | 52 PowerButtonObserver::State state) override; |
53 bool down, | |
54 const base::TimeTicks& timestamp) override; | |
55 | 53 |
56 // |shutdown_warning_message_|'s parent container. | 54 // |shutdown_warning_message_|'s parent container. |
57 aura::Window* warning_message_container_; | 55 aura::Window* warning_message_container_; |
58 | 56 |
59 // Shows a warning that the device is about to be shutdown. | 57 // Shows a warning that the device is about to be shutdown. |
60 scoped_ptr<views::Widget> shutdown_warning_message_; | 58 scoped_ptr<views::Widget> shutdown_warning_message_; |
61 | 59 |
62 // Whether the screen brightness was reduced to 0%. | |
63 bool brightness_is_zero_; | |
64 | |
65 // The last time at which the screen brightness was 0%. | |
66 base::TimeTicks zero_brightness_end_time_; | |
67 | |
68 State state_; | 60 State state_; |
69 | 61 |
70 base::OneShotTimer<PowerButtonController> timer_; | 62 base::OneShotTimer<PowerButtonController> timer_; |
71 | 63 |
72 DISALLOW_COPY_AND_ASSIGN(PowerButtonController); | 64 DISALLOW_COPY_AND_ASSIGN(PowerButtonController); |
73 }; | 65 }; |
74 | 66 |
75 } // namespace athena | 67 } // namespace athena |
76 | 68 |
77 #endif // ATHENA_SYSTEM_POWER_BUTTON_CONTROLLER_H_ | 69 #endif // ATHENA_SYSTEM_POWER_BUTTON_CONTROLLER_H_ |
OLD | NEW |