| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef ATHENA_INPUT_POWER_BUTTON_CONTROLLER_H_ | |
| 6 #define ATHENA_INPUT_POWER_BUTTON_CONTROLLER_H_ | |
| 7 | |
| 8 #include "athena/input/public/accelerator_manager.h" | |
| 9 #include "athena/input/public/input_manager.h" | |
| 10 #include "base/observer_list.h" | |
| 11 #include "base/timer/timer.h" | |
| 12 #include "chromeos/dbus/power_manager_client.h" | |
| 13 | |
| 14 namespace athena { | |
| 15 | |
| 16 class PowerButtonController : public chromeos::PowerManagerClient::Observer, | |
| 17 public AcceleratorHandler { | |
| 18 public: | |
| 19 PowerButtonController(); | |
| 20 ~PowerButtonController() override; | |
| 21 | |
| 22 void AddPowerButtonObserver(PowerButtonObserver* observer); | |
| 23 void RemovePowerButtonObserver(PowerButtonObserver* observer); | |
| 24 | |
| 25 void InstallAccelerators(); | |
| 26 | |
| 27 // A timer callabck to notify the long press event. | |
| 28 int SetPowerButtonTimeoutMsForTest(int timeout); | |
| 29 | |
| 30 private: | |
| 31 // chromeos::PowerManagerClient::Observer: | |
| 32 virtual void BrightnessChanged(int level, bool user_initiated) override; | |
| 33 virtual void PowerButtonEventReceived( | |
| 34 bool down, | |
| 35 const base::TimeTicks& timestamp) override; | |
| 36 | |
| 37 // AcceleratorHandler: | |
| 38 virtual bool IsCommandEnabled(int command_id) const override; | |
| 39 virtual bool OnAcceleratorFired(int command_id, | |
| 40 const ui::Accelerator& accelerator) override; | |
| 41 | |
| 42 void NotifyLongPress(); | |
| 43 | |
| 44 int power_button_timeout_ms_; | |
| 45 ObserverList<PowerButtonObserver> observers_; | |
| 46 // The last time at which the screen brightness was 0%. | |
| 47 base::TimeTicks zero_brightness_end_time_; | |
| 48 bool brightness_is_zero_; | |
| 49 base::OneShotTimer<PowerButtonController> timer_; | |
| 50 | |
| 51 DISALLOW_COPY_AND_ASSIGN(PowerButtonController); | |
| 52 }; | |
| 53 | |
| 54 } // namespace athena | |
| 55 | |
| 56 #endif // ATHENA_INPUT_POWER_BUTTON_CONTROLLER_H_ | |
| OLD | NEW |