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

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

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

Powered by Google App Engine
This is Rietveld 408576698