| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_SYSTEM_CHROMEOS_POWER_TABLET_POWER_BUTTON_CONTROLLER_H_ | 5 #ifndef ASH_SYSTEM_CHROMEOS_POWER_TABLET_POWER_BUTTON_CONTROLLER_H_ |
| 6 #define ASH_SYSTEM_CHROMEOS_POWER_TABLET_POWER_BUTTON_CONTROLLER_H_ | 6 #define ASH_SYSTEM_CHROMEOS_POWER_TABLET_POWER_BUTTON_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "ash/ash_export.h" | 10 #include "ash/ash_export.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 public: | 35 public: |
| 36 explicit TestApi(TabletPowerButtonController* controller); | 36 explicit TestApi(TabletPowerButtonController* controller); |
| 37 ~TestApi(); | 37 ~TestApi(); |
| 38 | 38 |
| 39 // Returns true when |shutdown_timer_| is running. | 39 // Returns true when |shutdown_timer_| is running. |
| 40 bool ShutdownTimerIsRunning() const; | 40 bool ShutdownTimerIsRunning() const; |
| 41 | 41 |
| 42 // Emulates |shutdown_timer_| timeout. | 42 // Emulates |shutdown_timer_| timeout. |
| 43 void TriggerShutdownTimeout(); | 43 void TriggerShutdownTimeout(); |
| 44 | 44 |
| 45 // Returns true when |lock_screen_timer_| is running. |
| 46 bool LockScreenTimerIsRunning() const; |
| 47 |
| 48 // Emulates |lock_screen_timer_| timeout. |
| 49 void TriggerLockScreenTimeout(); |
| 50 |
| 45 private: | 51 private: |
| 46 TabletPowerButtonController* controller_; // Not owned. | 52 TabletPowerButtonController* controller_; // Not owned. |
| 47 | 53 |
| 48 DISALLOW_COPY_AND_ASSIGN(TestApi); | 54 DISALLOW_COPY_AND_ASSIGN(TestApi); |
| 49 }; | 55 }; |
| 50 | 56 |
| 51 explicit TabletPowerButtonController(LockStateController* controller); | 57 explicit TabletPowerButtonController(LockStateController* controller); |
| 52 ~TabletPowerButtonController() override; | 58 ~TabletPowerButtonController() override; |
| 53 | 59 |
| 54 // Returns true if power button events should be handled by this class instead | 60 // Returns true if power button events should be handled by this class instead |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 // tablet mode. | 100 // tablet mode. |
| 95 void StartShutdownTimer(); | 101 void StartShutdownTimer(); |
| 96 | 102 |
| 97 // Called by |shutdown_timer_| to start the pre-shutdown animation. | 103 // Called by |shutdown_timer_| to start the pre-shutdown animation. |
| 98 void OnShutdownTimeout(); | 104 void OnShutdownTimeout(); |
| 99 | 105 |
| 100 // Locks the screen if the "require password to wake from sleep" pref is set | 106 // Locks the screen if the "require password to wake from sleep" pref is set |
| 101 // and locking is possible. | 107 // and locking is possible. |
| 102 void LockScreenIfRequired(); | 108 void LockScreenIfRequired(); |
| 103 | 109 |
| 110 // Called by |lock_screen_timer_| to start locking screen. |
| 111 void OnLockScreenTimeout(); |
| 112 |
| 104 // True if the brightness level is currently set to off. | 113 // True if the brightness level is currently set to off. |
| 105 bool brightness_level_is_zero_ = false; | 114 bool brightness_level_is_zero_ = false; |
| 106 | 115 |
| 107 // Current forced-off state of backlights. | 116 // Current forced-off state of backlights. |
| 108 bool backlights_forced_off_ = false; | 117 bool backlights_forced_off_ = false; |
| 109 | 118 |
| 110 // True if the screen was off when the power button was pressed. | 119 // True if the screen was off when the power button was pressed. |
| 111 bool screen_off_when_power_button_down_ = false; | 120 bool screen_off_when_power_button_down_ = false; |
| 112 | 121 |
| 113 // Time source for performed action times. | 122 // Time source for performed action times. |
| 114 std::unique_ptr<base::TickClock> tick_clock_; | 123 std::unique_ptr<base::TickClock> tick_clock_; |
| 115 | 124 |
| 116 // Saves the most recent timestamp that powerd is resuming from suspend, | 125 // Saves the most recent timestamp that powerd is resuming from suspend, |
| 117 // updated in SuspendDone(). | 126 // updated in SuspendDone(). |
| 118 base::TimeTicks last_resume_time_; | 127 base::TimeTicks last_resume_time_; |
| 119 | 128 |
| 120 // True if power button released should force off display. | 129 // True if power button released should force off display. |
| 121 bool force_off_on_button_up_; | 130 bool force_off_on_button_up_; |
| 122 | 131 |
| 123 // Started when the tablet power button is pressed and stopped when it's | 132 // Started when the tablet power button is pressed and stopped when it's |
| 124 // released. Runs OnShutdownTimeout() to start shutdown. | 133 // released. Runs OnShutdownTimeout() to start shutdown. |
| 125 base::OneShotTimer shutdown_timer_; | 134 base::OneShotTimer shutdown_timer_; |
| 126 | 135 |
| 136 // Used to provide a grace period between forcing the display off and locking |
| 137 // the screen. Runs OnLockScreenTimeout(). |
| 138 base::OneShotTimer lock_screen_timer_; |
| 139 |
| 127 LockStateController* controller_; // Not owned. | 140 LockStateController* controller_; // Not owned. |
| 128 | 141 |
| 129 base::WeakPtrFactory<TabletPowerButtonController> weak_ptr_factory_; | 142 base::WeakPtrFactory<TabletPowerButtonController> weak_ptr_factory_; |
| 130 | 143 |
| 131 DISALLOW_COPY_AND_ASSIGN(TabletPowerButtonController); | 144 DISALLOW_COPY_AND_ASSIGN(TabletPowerButtonController); |
| 132 }; | 145 }; |
| 133 | 146 |
| 134 } // namespace ash | 147 } // namespace ash |
| 135 | 148 |
| 136 #endif // ASH_SYSTEM_CHROMEOS_POWER_TABLET_POWER_BUTTON_CONTROLLER_H_ | 149 #endif // ASH_SYSTEM_CHROMEOS_POWER_TABLET_POWER_BUTTON_CONTROLLER_H_ |
| OLD | NEW |