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
3 // found in the LICENSE file.
5 #ifndef ASH_WM_POWER_BUTTON_CONTROLLER_H_
6 #define ASH_WM_POWER_BUTTON_CONTROLLER_H_
8 #include "ash/ash_export.h"
9 #include "ash/wm/session_state_animator.h"
10 #include "base/basictypes.h"
24 class PowerButtonControllerTest
;
27 class SessionStateController
;
29 // Displays onscreen animations and locks or suspends the system in response to
30 // the power button being pressed or released.
31 class ASH_EXPORT PowerButtonController
{
34 explicit PowerButtonController(SessionStateController
* controller
);
35 virtual ~PowerButtonController();
37 void set_has_legacy_power_button_for_test(bool legacy
) {
38 has_legacy_power_button_
= legacy
;
41 // Called when the current screen brightness changes.
42 void OnScreenBrightnessChanged(double percent
);
44 // Called when the power or lock buttons are pressed or released.
45 void OnPowerButtonEvent(bool down
, const base::TimeTicks
& timestamp
);
46 void OnLockButtonEvent(bool down
, const base::TimeTicks
& timestamp
);
49 friend class test::PowerButtonControllerTest
;
51 // Are the power or lock buttons currently held?
52 bool power_button_down_
;
53 bool lock_button_down_
;
55 // Is the screen currently turned off?
58 // Was a command-line switch set telling us that we're running on hardware
59 // that misreports power button releases?
60 bool has_legacy_power_button_
;
62 SessionStateController
* controller_
; // Not owned.
64 DISALLOW_COPY_AND_ASSIGN(PowerButtonController
);
69 #endif // ASH_WM_POWER_BUTTON_CONTROLLER_H_