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

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: based on ps2's comments 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 // 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 // Started when |shutdown_timer_| is still running when tablet power button is
137 // released and it should SetDisplayForcedOff(true), and stopped when it times
138 // out. Resets timer whenever there is a call of SetDisplayForcedOff(false).
Daniel Erat 2017/01/12 01:40:47 this is a pretty complicated comment. could you us
Qiang(Joe) Xu 2017/01/12 15:05:55 done, thanks
139 // Runs OnLockScreenTimeout() to start locking screen.
140 base::OneShotTimer lock_screen_timer_;
141
127 LockStateController* controller_; // Not owned. 142 LockStateController* controller_; // Not owned.
128 143
129 base::WeakPtrFactory<TabletPowerButtonController> weak_ptr_factory_; 144 base::WeakPtrFactory<TabletPowerButtonController> weak_ptr_factory_;
130 145
131 DISALLOW_COPY_AND_ASSIGN(TabletPowerButtonController); 146 DISALLOW_COPY_AND_ASSIGN(TabletPowerButtonController);
132 }; 147 };
133 148
134 } // namespace ash 149 } // namespace ash
135 150
136 #endif // ASH_SYSTEM_CHROMEOS_POWER_TABLET_POWER_BUTTON_CONTROLLER_H_ 151 #endif // ASH_SYSTEM_CHROMEOS_POWER_TABLET_POWER_BUTTON_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698