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

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

Issue 2652093002: mash: Make the power button shut the system down. (Closed)
Patch Set: remove WmShell::RequestShutdown 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
« no previous file with comments | « ash/shell.cc ('k') | no next file » | 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 #include "ash/wm/lock_state_controller.h" 5 #include "ash/wm/lock_state_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 StartImmediatePreLockAnimation(false /* request_lock_on_completion */); 155 StartImmediatePreLockAnimation(false /* request_lock_on_completion */);
156 } 156 }
157 157
158 void LockStateController::RequestShutdown() { 158 void LockStateController::RequestShutdown() {
159 if (shutting_down_) 159 if (shutting_down_)
160 return; 160 return;
161 161
162 shutting_down_ = true; 162 shutting_down_ = true;
163 163
164 Shell* shell = Shell::GetInstance(); 164 Shell* shell = Shell::GetInstance();
165 shell->cursor_manager()->HideCursor(); 165 if (shell->cursor_manager()) {
James Cook 2017/01/25 02:40:26 optional: WDYT of calling !WmShell::Get()->IsRunni
Daniel Erat 2017/01/25 05:22:21 presumably we're going to have a ws-aware CursorMa
166 shell->cursor_manager()->LockCursor(); 166 shell->cursor_manager()->HideCursor();
167 shell->cursor_manager()->LockCursor();
168 }
167 169
168 animator_->StartAnimation( 170 animator_->StartAnimation(
169 SessionStateAnimator::ROOT_CONTAINER, 171 SessionStateAnimator::ROOT_CONTAINER,
170 SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS, 172 SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS,
171 SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); 173 SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN);
172 StartRealShutdownTimer(true); 174 StartRealShutdownTimer(true);
173 } 175 }
174 176
175 void LockStateController::OnLockScreenHide( 177 void LockStateController::OnLockScreenHide(
176 base::Callback<void(void)>& callback) { 178 base::Callback<void(void)>& callback) {
(...skipping 16 matching lines...) Expand all
193 system_is_locked_ = (status == LoginStatus::LOCKED); 195 system_is_locked_ = (status == LoginStatus::LOCKED);
194 } 196 }
195 197
196 void LockStateController::OnAppTerminating() { 198 void LockStateController::OnAppTerminating() {
197 // If we hear that Chrome is exiting but didn't request it ourselves, all we 199 // If we hear that Chrome is exiting but didn't request it ourselves, all we
198 // can really hope for is that we'll have time to clear the screen. 200 // can really hope for is that we'll have time to clear the screen.
199 // This is also the case when the user signs off. 201 // This is also the case when the user signs off.
200 if (!shutting_down_) { 202 if (!shutting_down_) {
201 shutting_down_ = true; 203 shutting_down_ = true;
202 Shell* shell = Shell::GetInstance(); 204 Shell* shell = Shell::GetInstance();
203 shell->cursor_manager()->HideCursor(); 205 if (shell->cursor_manager()) {
204 shell->cursor_manager()->LockCursor(); 206 shell->cursor_manager()->HideCursor();
207 shell->cursor_manager()->LockCursor();
208 }
205 animator_->StartAnimation(SessionStateAnimator::kAllNonRootContainersMask, 209 animator_->StartAnimation(SessionStateAnimator::kAllNonRootContainersMask,
206 SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY, 210 SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY,
207 SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); 211 SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE);
208 } 212 }
209 } 213 }
210 214
211 void LockStateController::OnLockStateChanged(bool locked) { 215 void LockStateController::OnLockStateChanged(bool locked) {
212 DCHECK((lock_fail_timer_.IsRunning() && lock_duration_timer_ != nullptr) || 216 DCHECK((lock_fail_timer_.IsRunning() && lock_duration_timer_ != nullptr) ||
213 (!lock_fail_timer_.IsRunning() && lock_duration_timer_ == nullptr)); 217 (!lock_fail_timer_.IsRunning() && lock_duration_timer_ == nullptr));
214 VLOG(1) << "OnLockStateChanged called with locked: " << locked 218 VLOG(1) << "OnLockStateChanged called with locked: " << locked
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 FROM_HERE, 268 FROM_HERE,
265 animator_->GetDuration(SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN), 269 animator_->GetDuration(SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN),
266 this, &LockStateController::OnPreShutdownAnimationTimeout); 270 this, &LockStateController::OnPreShutdownAnimationTimeout);
267 } 271 }
268 272
269 void LockStateController::OnPreShutdownAnimationTimeout() { 273 void LockStateController::OnPreShutdownAnimationTimeout() {
270 VLOG(1) << "OnPreShutdownAnimationTimeout"; 274 VLOG(1) << "OnPreShutdownAnimationTimeout";
271 shutting_down_ = true; 275 shutting_down_ = true;
272 276
273 Shell* shell = Shell::GetInstance(); 277 Shell* shell = Shell::GetInstance();
274 shell->cursor_manager()->HideCursor(); 278 if (shell->cursor_manager())
279 shell->cursor_manager()->HideCursor();
275 280
276 StartRealShutdownTimer(false); 281 StartRealShutdownTimer(false);
277 } 282 }
278 283
279 void LockStateController::StartRealShutdownTimer(bool with_animation_time) { 284 void LockStateController::StartRealShutdownTimer(bool with_animation_time) {
280 base::TimeDelta duration = 285 base::TimeDelta duration =
281 base::TimeDelta::FromMilliseconds(kShutdownRequestDelayMs); 286 base::TimeDelta::FromMilliseconds(kShutdownRequestDelayMs);
282 if (with_animation_time) { 287 if (with_animation_time) {
283 duration += 288 duration +=
284 animator_->GetDuration(SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); 289 animator_->GetDuration(SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN);
(...skipping 15 matching lines...) Expand all
300 VLOG(1) << "OnRealPowerTimeout"; 305 VLOG(1) << "OnRealPowerTimeout";
301 DCHECK(shutting_down_); 306 DCHECK(shutting_down_);
302 WmShell::Get()->RecordUserMetricsAction(UMA_ACCEL_SHUT_DOWN_POWER_BUTTON); 307 WmShell::Get()->RecordUserMetricsAction(UMA_ACCEL_SHUT_DOWN_POWER_BUTTON);
303 // Shut down or reboot based on device policy. 308 // Shut down or reboot based on device policy.
304 shutdown_controller_->ShutDownOrReboot(); 309 shutdown_controller_->ShutDownOrReboot();
305 } 310 }
306 311
307 void LockStateController::StartCancellableShutdownAnimation() { 312 void LockStateController::StartCancellableShutdownAnimation() {
308 Shell* shell = Shell::GetInstance(); 313 Shell* shell = Shell::GetInstance();
309 // Hide cursor, but let it reappear if the mouse moves. 314 // Hide cursor, but let it reappear if the mouse moves.
310 shell->cursor_manager()->HideCursor(); 315 if (shell->cursor_manager())
316 shell->cursor_manager()->HideCursor();
311 317
312 animator_->StartAnimation( 318 animator_->StartAnimation(
313 SessionStateAnimator::ROOT_CONTAINER, 319 SessionStateAnimator::ROOT_CONTAINER,
314 SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS, 320 SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS,
315 SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); 321 SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN);
316 StartPreShutdownAnimationTimer(); 322 StartPreShutdownAnimationTimer();
317 } 323 }
318 324
319 void LockStateController::StartImmediatePreLockAnimation( 325 void LockStateController::StartImmediatePreLockAnimation(
320 bool request_lock_on_completion) { 326 bool request_lock_on_completion) {
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 SessionStateAnimator::AnimationSpeed speed, 557 SessionStateAnimator::AnimationSpeed speed,
552 SessionStateAnimator::AnimationSequence* animation_sequence) { 558 SessionStateAnimator::AnimationSequence* animation_sequence) {
553 if (unlocked_properties_.get() && unlocked_properties_->wallpaper_is_hidden) { 559 if (unlocked_properties_.get() && unlocked_properties_->wallpaper_is_hidden) {
554 animation_sequence->StartAnimation(SessionStateAnimator::WALLPAPER, 560 animation_sequence->StartAnimation(SessionStateAnimator::WALLPAPER,
555 SessionStateAnimator::ANIMATION_FADE_OUT, 561 SessionStateAnimator::ANIMATION_FADE_OUT,
556 speed); 562 speed);
557 } 563 }
558 } 564 }
559 565
560 } // namespace ash 566 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shell.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698