| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 ASH_WM_POWER_BUTTON_CONTROLLER_H_ | 5 #ifndef ASH_WM_POWER_BUTTON_CONTROLLER_H_ |
| 6 #define ASH_WM_POWER_BUTTON_CONTROLLER_H_ | 6 #define ASH_WM_POWER_BUTTON_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
| 9 #include "ash/wm/session_state_animator.h" | 9 #include "ash/wm/session_state_animator.h" |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 | 11 |
| 12 namespace gfx { | 12 namespace gfx { |
| 13 class Rect; | 13 class Rect; |
| 14 class Size; | 14 class Size; |
| 15 } | 15 } |
| 16 | 16 |
| 17 namespace ui { | 17 namespace ui { |
| 18 class Layer; | 18 class Layer; |
| 19 } | 19 } |
| 20 | 20 |
| 21 namespace ash { | 21 namespace ash { |
| 22 | 22 |
| 23 namespace test { | 23 namespace test { |
| 24 class PowerButtonControllerTest; | 24 class PowerButtonControllerTest; |
| 25 } | 25 } |
| 26 | 26 |
| 27 class SessionStateController; | 27 class SessionLockStateController; |
| 28 | 28 |
| 29 // Displays onscreen animations and locks or suspends the system in response to | 29 // Displays onscreen animations and locks or suspends the system in response to |
| 30 // the power button being pressed or released. | 30 // the power button being pressed or released. |
| 31 class ASH_EXPORT PowerButtonController { | 31 class ASH_EXPORT PowerButtonController { |
| 32 public: | 32 public: |
| 33 | 33 |
| 34 explicit PowerButtonController(SessionStateController* controller); | 34 explicit PowerButtonController(SessionLockStateController* controller); |
| 35 virtual ~PowerButtonController(); | 35 virtual ~PowerButtonController(); |
| 36 | 36 |
| 37 void set_has_legacy_power_button_for_test(bool legacy) { | 37 void set_has_legacy_power_button_for_test(bool legacy) { |
| 38 has_legacy_power_button_ = legacy; | 38 has_legacy_power_button_ = legacy; |
| 39 } | 39 } |
| 40 | 40 |
| 41 // Called when the current screen brightness changes. | 41 // Called when the current screen brightness changes. |
| 42 void OnScreenBrightnessChanged(double percent); | 42 void OnScreenBrightnessChanged(double percent); |
| 43 | 43 |
| 44 // Called when the power or lock buttons are pressed or released. | 44 // Called when the power or lock buttons are pressed or released. |
| 45 void OnPowerButtonEvent(bool down, const base::TimeTicks& timestamp); | 45 void OnPowerButtonEvent(bool down, const base::TimeTicks& timestamp); |
| 46 void OnLockButtonEvent(bool down, const base::TimeTicks& timestamp); | 46 void OnLockButtonEvent(bool down, const base::TimeTicks& timestamp); |
| 47 | 47 |
| 48 private: | 48 private: |
| 49 friend class test::PowerButtonControllerTest; | 49 friend class test::PowerButtonControllerTest; |
| 50 | 50 |
| 51 // Are the power or lock buttons currently held? | 51 // Are the power or lock buttons currently held? |
| 52 bool power_button_down_; | 52 bool power_button_down_; |
| 53 bool lock_button_down_; | 53 bool lock_button_down_; |
| 54 | 54 |
| 55 // Is the screen currently turned off? | 55 // Is the screen currently turned off? |
| 56 bool screen_is_off_; | 56 bool screen_is_off_; |
| 57 | 57 |
| 58 // Was a command-line switch set telling us that we're running on hardware | 58 // Was a command-line switch set telling us that we're running on hardware |
| 59 // that misreports power button releases? | 59 // that misreports power button releases? |
| 60 bool has_legacy_power_button_; | 60 bool has_legacy_power_button_; |
| 61 | 61 |
| 62 SessionStateController* controller_; // Not owned. | 62 SessionLockStateController* controller_; // Not owned. |
| 63 | 63 |
| 64 DISALLOW_COPY_AND_ASSIGN(PowerButtonController); | 64 DISALLOW_COPY_AND_ASSIGN(PowerButtonController); |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 } // namespace ash | 67 } // namespace ash |
| 68 | 68 |
| 69 #endif // ASH_WM_POWER_BUTTON_CONTROLLER_H_ | 69 #endif // ASH_WM_POWER_BUTTON_CONTROLLER_H_ |
| OLD | NEW |