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

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

Issue 2497123002: chromeos: Move device shutdown handling out of chrome into ash (Closed)
Patch Set: rebase Created 4 years, 1 month 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/wm/lock_state_controller.h ('k') | ash/wm/lock_state_controller_unittest.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 #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
11 #include "ash/cancel_mode.h" 11 #include "ash/cancel_mode.h"
12 #include "ash/common/accessibility_delegate.h" 12 #include "ash/common/accessibility_delegate.h"
13 #include "ash/common/shell_delegate.h" 13 #include "ash/common/shell_delegate.h"
14 #include "ash/common/shutdown_controller.h"
14 #include "ash/common/wm_shell.h" 15 #include "ash/common/wm_shell.h"
15 #include "ash/public/cpp/shell_window_ids.h" 16 #include "ash/public/cpp/shell_window_ids.h"
16 #include "ash/public/interfaces/shutdown.mojom.h" 17 #include "ash/public/interfaces/shutdown.mojom.h"
17 #include "ash/shell.h" 18 #include "ash/shell.h"
18 #include "ash/wm/session_state_animator.h" 19 #include "ash/wm/session_state_animator.h"
19 #include "ash/wm/session_state_animator_impl.h" 20 #include "ash/wm/session_state_animator_impl.h"
20 #include "ash/wm/shutdown_client_proxy.h"
21 #include "base/bind.h" 21 #include "base/bind.h"
22 #include "base/bind_helpers.h" 22 #include "base/bind_helpers.h"
23 #include "base/command_line.h" 23 #include "base/command_line.h"
24 #include "base/location.h" 24 #include "base/location.h"
25 #include "base/logging.h" 25 #include "base/logging.h"
26 #include "base/metrics/histogram_macros.h" 26 #include "base/metrics/histogram_macros.h"
27 #include "base/strings/string_util.h" 27 #include "base/strings/string_util.h"
28 #include "base/timer/timer.h" 28 #include "base/timer/timer.h"
29 #include "ui/aura/window_tree_host.h" 29 #include "ui/aura/window_tree_host.h"
30 #include "ui/views/controls/menu/menu_controller.h" 30 #include "ui/views/controls/menu/menu_controller.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 defined(SYZYASAN) 65 defined(SYZYASAN)
66 static const int kTimeoutMultiplier = 2; 66 static const int kTimeoutMultiplier = 2;
67 #else 67 #else
68 static const int kTimeoutMultiplier = 1; 68 static const int kTimeoutMultiplier = 1;
69 #endif 69 #endif
70 70
71 const int LockStateController::kLockFailTimeoutMs = 8000 * kTimeoutMultiplier; 71 const int LockStateController::kLockFailTimeoutMs = 8000 * kTimeoutMultiplier;
72 const int LockStateController::kLockToShutdownTimeoutMs = 150; 72 const int LockStateController::kLockToShutdownTimeoutMs = 150;
73 const int LockStateController::kShutdownRequestDelayMs = 50; 73 const int LockStateController::kShutdownRequestDelayMs = 50;
74 74
75 LockStateController::LockStateController(service_manager::Connector* connector) 75 LockStateController::LockStateController(
76 ShutdownController* shutdown_controller)
76 : animator_(new SessionStateAnimatorImpl()), 77 : animator_(new SessionStateAnimatorImpl()),
77 login_status_(LoginStatus::NOT_LOGGED_IN), 78 login_status_(LoginStatus::NOT_LOGGED_IN),
78 system_is_locked_(false), 79 system_is_locked_(false),
79 shutting_down_(false), 80 shutting_down_(false),
80 shutdown_after_lock_(false), 81 shutdown_after_lock_(false),
81 animating_lock_(false), 82 animating_lock_(false),
82 can_cancel_lock_animation_(false), 83 can_cancel_lock_animation_(false),
83 shutdown_client_(base::MakeUnique<ShutdownClientProxy>(connector)), 84 shutdown_controller_(shutdown_controller),
84 weak_ptr_factory_(this) { 85 weak_ptr_factory_(this) {
86 DCHECK(shutdown_controller_);
85 Shell::GetPrimaryRootWindow()->GetHost()->AddObserver(this); 87 Shell::GetPrimaryRootWindow()->GetHost()->AddObserver(this);
86 } 88 }
87 89
88 LockStateController::~LockStateController() { 90 LockStateController::~LockStateController() {
89 Shell::GetPrimaryRootWindow()->GetHost()->RemoveObserver(this); 91 Shell::GetPrimaryRootWindow()->GetHost()->RemoveObserver(this);
90 } 92 }
91 93
92 void LockStateController::StartLockAnimation(bool shutdown_after_lock) { 94 void LockStateController::StartLockAnimation(bool shutdown_after_lock) {
93 if (animating_lock_) 95 if (animating_lock_)
94 return; 96 return;
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 #endif 303 #endif
302 304
303 real_shutdown_timer_.Start( 305 real_shutdown_timer_.Start(
304 FROM_HERE, duration, base::Bind(&LockStateController::OnRealPowerTimeout, 306 FROM_HERE, duration, base::Bind(&LockStateController::OnRealPowerTimeout,
305 base::Unretained(this))); 307 base::Unretained(this)));
306 } 308 }
307 309
308 void LockStateController::OnRealPowerTimeout() { 310 void LockStateController::OnRealPowerTimeout() {
309 VLOG(1) << "OnRealPowerTimeout"; 311 VLOG(1) << "OnRealPowerTimeout";
310 DCHECK(shutting_down_); 312 DCHECK(shutting_down_);
311 #if defined(OS_CHROMEOS)
312 if (!base::SysInfo::IsRunningOnChromeOS()) {
313 ShellDelegate* delegate = WmShell::Get()->delegate();
314 if (delegate) {
315 delegate->Exit();
316 return;
317 }
318 }
319 #endif
320 WmShell::Get()->RecordUserMetricsAction(UMA_ACCEL_SHUT_DOWN_POWER_BUTTON); 313 WmShell::Get()->RecordUserMetricsAction(UMA_ACCEL_SHUT_DOWN_POWER_BUTTON);
321 314 // Shut down or reboot based on device policy.
322 // Connect to the browser to tell it to shutdown the computer. It will either 315 shutdown_controller_->ShutDownOrReboot();
323 // shut down or restart the computer based on the device settings.
324 //
325 // TODO(erg): Once CrosSettings has been moved out of chrome/,
326 // LockStateController should become a preference observer of it, and we
327 // should move the current content_browser implementation here.
328 // crbug.com/628792
329 shutdown_client_->RequestShutdown();
330 } 316 }
331 317
332 void LockStateController::StartCancellableShutdownAnimation() { 318 void LockStateController::StartCancellableShutdownAnimation() {
333 Shell* shell = Shell::GetInstance(); 319 Shell* shell = Shell::GetInstance();
334 // Hide cursor, but let it reappear if the mouse moves. 320 // Hide cursor, but let it reappear if the mouse moves.
335 shell->cursor_manager()->HideCursor(); 321 shell->cursor_manager()->HideCursor();
336 322
337 animator_->StartAnimation( 323 animator_->StartAnimation(
338 SessionStateAnimator::ROOT_CONTAINER, 324 SessionStateAnimator::ROOT_CONTAINER,
339 SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS, 325 SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS,
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 SessionStateAnimator::AnimationSpeed speed, 563 SessionStateAnimator::AnimationSpeed speed,
578 SessionStateAnimator::AnimationSequence* animation_sequence) { 564 SessionStateAnimator::AnimationSequence* animation_sequence) {
579 if (unlocked_properties_.get() && unlocked_properties_->wallpaper_is_hidden) { 565 if (unlocked_properties_.get() && unlocked_properties_->wallpaper_is_hidden) {
580 animation_sequence->StartAnimation(SessionStateAnimator::WALLPAPER, 566 animation_sequence->StartAnimation(SessionStateAnimator::WALLPAPER,
581 SessionStateAnimator::ANIMATION_FADE_OUT, 567 SessionStateAnimator::ANIMATION_FADE_OUT,
582 speed); 568 speed);
583 } 569 }
584 } 570 }
585 571
586 } // namespace ash 572 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/lock_state_controller.h ('k') | ash/wm/lock_state_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698