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

Side by Side Diff: ash/wm/lock_state_controller.h

Issue 776093004: Add device policy to disallow shutdown (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: modifications suggested by stevenjb Created 6 years 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_WM_LOCK_STATE_CONTROLLER_H_ 5 #ifndef ASH_WM_LOCK_STATE_CONTROLLER_H_
6 #define ASH_WM_LOCK_STATE_CONTROLLER_H_ 6 #define ASH_WM_LOCK_STATE_CONTROLLER_H_
7 7
8 #include "ash/ash_export.h" 8 #include "ash/ash_export.h"
9 #include "ash/shell_observer.h" 9 #include "ash/shell_observer.h"
10 #include "ash/wm/lock_state_observer.h" 10 #include "ash/wm/lock_state_observer.h"
(...skipping 22 matching lines...) Expand all
33 class PowerButtonControllerTest; 33 class PowerButtonControllerTest;
34 } 34 }
35 35
36 // Performs system-related functions on behalf of LockStateController. 36 // Performs system-related functions on behalf of LockStateController.
37 class ASH_EXPORT LockStateControllerDelegate { 37 class ASH_EXPORT LockStateControllerDelegate {
38 public: 38 public:
39 LockStateControllerDelegate() {} 39 LockStateControllerDelegate() {}
40 virtual ~LockStateControllerDelegate() {} 40 virtual ~LockStateControllerDelegate() {}
41 41
42 virtual void RequestLockScreen() = 0; 42 virtual void RequestLockScreen() = 0;
43 virtual void RequestRestart() = 0;
43 virtual void RequestShutdown() = 0; 44 virtual void RequestShutdown() = 0;
44 45
45 private: 46 private:
46 DISALLOW_COPY_AND_ASSIGN(LockStateControllerDelegate); 47 DISALLOW_COPY_AND_ASSIGN(LockStateControllerDelegate);
47 }; 48 };
48 49
49 // Displays onscreen animations and locks or suspends the system in response to 50 // Displays onscreen animations and locks or suspends the system in response to
50 // the power button being pressed or released. 51 // the power button being pressed or released.
51 // Lock workflow: 52 // Lock workflow:
52 // Entry points: 53 // Entry points:
(...skipping 12 matching lines...) Expand all
65 // 66 //
66 // Unlock workflow: 67 // Unlock workflow:
67 // WebUI does first part of animation, and calls OnLockScreenHide(callback) that 68 // WebUI does first part of animation, and calls OnLockScreenHide(callback) that
68 // triggers StartUnlockAnimationBeforeUIDestroyed(callback). Once callback is 69 // triggers StartUnlockAnimationBeforeUIDestroyed(callback). Once callback is
69 // called at the end of the animation, lock UI is deleted, system unlocks, and 70 // called at the end of the animation, lock UI is deleted, system unlocks, and
70 // OnLockStateChanged is called. It leads to 71 // OnLockStateChanged is called. It leads to
71 // StartUnlockAnimationAfterUIDestroyed. 72 // StartUnlockAnimationAfterUIDestroyed.
72 class ASH_EXPORT LockStateController : public aura::WindowTreeHostObserver, 73 class ASH_EXPORT LockStateController : public aura::WindowTreeHostObserver,
73 public ShellObserver { 74 public ShellObserver {
74 public: 75 public:
76 // ShutdownMode determines whether the device will power off or reboot when
77 // RequestShutdown is invoked.
78 enum ShutdownMode { POWER_OFF, RESTART };
79
75 // Amount of time that the power button needs to be held before we lock the 80 // Amount of time that the power button needs to be held before we lock the
76 // screen. 81 // screen.
77 static const int kLockTimeoutMs; 82 static const int kLockTimeoutMs;
78 83
79 // Amount of time that the power button needs to be held before we shut down. 84 // Amount of time that the power button needs to be held before we shut down.
80 static const int kShutdownTimeoutMs; 85 static const int kShutdownTimeoutMs;
81 86
82 // Amount of time to wait for our lock requests to be honored before giving 87 // Amount of time to wait for our lock requests to be honored before giving
83 // up. 88 // up.
84 static const int kLockFailTimeoutMs; 89 static const int kLockFailTimeoutMs;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 } 130 }
126 void trigger_lock_to_shutdown_timeout() { 131 void trigger_lock_to_shutdown_timeout() {
127 controller_->OnLockToShutdownTimeout(); 132 controller_->OnLockToShutdownTimeout();
128 controller_->lock_to_shutdown_timer_.Stop(); 133 controller_->lock_to_shutdown_timer_.Stop();
129 } 134 }
130 void trigger_shutdown_timeout() { 135 void trigger_shutdown_timeout() {
131 controller_->OnPreShutdownAnimationTimeout(); 136 controller_->OnPreShutdownAnimationTimeout();
132 controller_->pre_shutdown_timer_.Stop(); 137 controller_->pre_shutdown_timer_.Stop();
133 } 138 }
134 void trigger_real_shutdown_timeout() { 139 void trigger_real_shutdown_timeout() {
135 controller_->OnRealShutdownTimeout(); 140 controller_->OnRealPowerTimeout(POWER_OFF);
136 controller_->real_shutdown_timer_.Stop(); 141 controller_->real_shutdown_timer_.Stop();
137 } 142 }
138 143
139 private: 144 private:
140 LockStateController* controller_; // not owned 145 LockStateController* controller_; // not owned
141 146
142 DISALLOW_COPY_AND_ASSIGN(TestApi); 147 DISALLOW_COPY_AND_ASSIGN(TestApi);
143 }; 148 };
144 149
145 LockStateController(); 150 LockStateController();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 // Returns true if we are within cancellable shutdown timeframe. 186 // Returns true if we are within cancellable shutdown timeframe.
182 bool CanCancelShutdownAnimation(); 187 bool CanCancelShutdownAnimation();
183 188
184 // Cancels shutting down and reverts shutdown animation. 189 // Cancels shutting down and reverts shutdown animation.
185 void CancelShutdownAnimation(); 190 void CancelShutdownAnimation();
186 191
187 // Called when Chrome gets a request to display the lock screen. 192 // Called when Chrome gets a request to display the lock screen.
188 void OnStartingLock(); 193 void OnStartingLock();
189 194
190 // Displays the shutdown animation and requests shutdown when it's done. 195 // Displays the shutdown animation and requests shutdown when it's done.
191 void RequestShutdown(); 196 void RequestShutdown(ShutdownMode mode);
192 197
193 // Called when ScreenLocker is ready to close, but not yet destroyed. 198 // Called when ScreenLocker is ready to close, but not yet destroyed.
194 // Can be used to display "hiding" animations on unlock. 199 // Can be used to display "hiding" animations on unlock.
195 // |callback| will be called when all animations are done. 200 // |callback| will be called when all animations are done.
196 void OnLockScreenHide(base::Closure& callback); 201 void OnLockScreenHide(base::Closure& callback);
197 202
198 // Sets up the callback that should be called once lock animation is finished. 203 // Sets up the callback that should be called once lock animation is finished.
199 // Callback is guaranteed to be called once and then discarded. 204 // Callback is guaranteed to be called once and then discarded.
200 void SetLockScreenDisplayedCallback(const base::Closure& callback); 205 void SetLockScreenDisplayedCallback(const base::Closure& callback);
201 206
(...skipping 28 matching lines...) Expand all
230 235
231 // Starts timer for undoable shutdown animation. 236 // Starts timer for undoable shutdown animation.
232 void StartPreShutdownAnimationTimer(); 237 void StartPreShutdownAnimationTimer();
233 238
234 // Calls StartRealShutdownTimer(). 239 // Calls StartRealShutdownTimer().
235 void OnPreShutdownAnimationTimeout(); 240 void OnPreShutdownAnimationTimeout();
236 241
237 // Starts timer for final shutdown animation. 242 // Starts timer for final shutdown animation.
238 // If |with_animation_time| is true, it will also include time of "fade to 243 // If |with_animation_time| is true, it will also include time of "fade to
239 // white" shutdown animation. 244 // white" shutdown animation.
240 void StartRealShutdownTimer(bool with_animation_time); 245 // If |shutdown_mode| is set to RESTART, the device will reboot.
246 void StartRealShutdownTimer(bool with_animation_time,
247 ShutdownMode shutdown_mode);
241 248
242 // Requests that the machine be shut down. 249 // Request that the machine be either restarted or shut down depending on
243 void OnRealShutdownTimeout(); 250 // |shutdown_mode|.
251 void OnRealPowerTimeout(ShutdownMode shutdown_mode);
244 252
245 // Starts shutdown animation that can be cancelled and starts pre-shutdown 253 // Starts shutdown animation that can be cancelled and starts pre-shutdown
246 // timer. 254 // timer.
247 void StartCancellableShutdownAnimation(); 255 void StartCancellableShutdownAnimation();
248 256
249 // If |request_lock_on_completion| is true, a lock request will be sent 257 // If |request_lock_on_completion| is true, a lock request will be sent
250 // after the pre-lock animation completes. (The pre-lock animation is 258 // after the pre-lock animation completes. (The pre-lock animation is
251 // also displayed in response to already-in-progress lock requests; in 259 // also displayed in response to already-in-progress lock requests; in
252 // these cases an additional lock request is undesirable.) 260 // these cases an additional lock request is undesirable.)
253 void StartImmediatePreLockAnimation(bool request_lock_on_completion); 261 void StartImmediatePreLockAnimation(bool request_lock_on_completion);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 base::Closure lock_screen_displayed_callback_; 334 base::Closure lock_screen_displayed_callback_;
327 335
328 base::WeakPtrFactory<LockStateController> weak_ptr_factory_; 336 base::WeakPtrFactory<LockStateController> weak_ptr_factory_;
329 337
330 DISALLOW_COPY_AND_ASSIGN(LockStateController); 338 DISALLOW_COPY_AND_ASSIGN(LockStateController);
331 }; 339 };
332 340
333 } // namespace ash 341 } // namespace ash
334 342
335 #endif // ASH_WM_LOCK_STATE_CONTROLLER_H_ 343 #endif // ASH_WM_LOCK_STATE_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698