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. 4 5#ifndef ASH_WM_POWER_BUTTON_CONTROLLER_H_ 6#define ASH_WM_POWER_BUTTON_CONTROLLER_H_ 7 8#include "ash/ash_export.h" 9#include "ash/wm/session_state_animator.h" 10#include "base/basictypes.h" 11 12namespace gfx { 13class Rect; 14class Size; 15} 16 17namespace ui { 18class Layer; 19} 20 21namespace ash { 22 23namespace test { 24class PowerButtonControllerTest; 25} 26 27class LockStateController; 28 29// Displays onscreen animations and locks or suspends the system in response to 30// the power button being pressed or released. 31class ASH_EXPORT PowerButtonController { 32 public: 33 34 explicit PowerButtonController(LockStateController* controller); 35 virtual ~PowerButtonController(); 36 37 void set_has_legacy_power_button_for_test(bool legacy) { 38 has_legacy_power_button_ = legacy; 39 } 40 41 // Called when the current screen brightness changes. 42 void OnScreenBrightnessChanged(double percent); 43 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); 47 48 private: 49 friend class test::PowerButtonControllerTest; 50 51 // Are the power or lock buttons currently held? 52 bool power_button_down_; 53 bool lock_button_down_; 54 55 // Is the screen currently turned off? 56 bool screen_is_off_; 57 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_; 61 62 LockStateController* controller_; // Not owned. 63 64 DISALLOW_COPY_AND_ASSIGN(PowerButtonController); 65}; 66 67} // namespace ash 68 69#endif // ASH_WM_POWER_BUTTON_CONTROLLER_H_ 70