Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: ash/system/chromeos/power/tablet_power_button_controller.h

Issue 2620383003: ash: Add one second grace period For LockScreenIfRequired (Closed)
Patch Set: reset |lock_screen_timer_| in SetDisplayForcedOff and add test coverage Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 // Starts |lock_screen_timer_| when lock screen is required.
111 void StartLockScreenTimer();
112
113 // Called by |lock_screen_timer_| to start locking screen.
114 void OnLockScreenTimeout();
115
104 // True if the brightness level is currently set to off. 116 // True if the brightness level is currently set to off.
105 bool brightness_level_is_zero_ = false; 117 bool brightness_level_is_zero_ = false;
106 118
107 // Current forced-off state of backlights. 119 // Current forced-off state of backlights.
108 bool backlights_forced_off_ = false; 120 bool backlights_forced_off_ = false;
109 121
110 // True if the screen was off when the power button was pressed. 122 // True if the screen was off when the power button was pressed.
111 bool screen_off_when_power_button_down_ = false; 123 bool screen_off_when_power_button_down_ = false;
112 124
113 // Time source for performed action times. 125 // Time source for performed action times.
114 std::unique_ptr<base::TickClock> tick_clock_; 126 std::unique_ptr<base::TickClock> tick_clock_;
115 127
116 // Saves the most recent timestamp that powerd is resuming from suspend, 128 // Saves the most recent timestamp that powerd is resuming from suspend,
117 // updated in SuspendDone(). 129 // updated in SuspendDone().
118 base::TimeTicks last_resume_time_; 130 base::TimeTicks last_resume_time_;
119 131
120 // True if power button released should force off display. 132 // True if power button released should force off display.
121 bool force_off_on_button_up_; 133 bool force_off_on_button_up_;
122 134
123 // Started when the tablet power button is pressed and stopped when it's 135 // Started when the tablet power button is pressed and stopped when it's
124 // released. Runs OnShutdownTimeout() to start shutdown. 136 // released. Runs OnShutdownTimeout() to start shutdown.
125 base::OneShotTimer shutdown_timer_; 137 base::OneShotTimer shutdown_timer_;
126 138
139 // Started when |shutdown_timer_| is still running when tablet power button is
140 // released and it should set display off, and stopped when it timeouts.
Daniel Erat 2017/01/11 23:09:06 nit: s/timeouts/times out/
Qiang(Joe) Xu 2017/01/12 00:04:45 Done.
141 // Run OnLockScreenTimeout() to start locking screen.
Daniel Erat 2017/01/11 23:09:06 nit: s/Run/Runs/
Qiang(Joe) Xu 2017/01/12 00:04:45 Done.
142 base::OneShotTimer lock_screen_timer_;
143
127 LockStateController* controller_; // Not owned. 144 LockStateController* controller_; // Not owned.
128 145
129 base::WeakPtrFactory<TabletPowerButtonController> weak_ptr_factory_; 146 base::WeakPtrFactory<TabletPowerButtonController> weak_ptr_factory_;
130 147
131 DISALLOW_COPY_AND_ASSIGN(TabletPowerButtonController); 148 DISALLOW_COPY_AND_ASSIGN(TabletPowerButtonController);
132 }; 149 };
133 150
134 } // namespace ash 151 } // namespace ash
135 152
136 #endif // ASH_SYSTEM_CHROMEOS_POWER_TABLET_POWER_BUTTON_CONTROLLER_H_ 153 #endif // ASH_SYSTEM_CHROMEOS_POWER_TABLET_POWER_BUTTON_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698