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

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

Issue 2471643002: mash: remove the LockStateControllerDelegate. (Closed)
Patch Set: Add bug links + modify other overlay.json file. 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
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/wm_shell.h" 14 #include "ash/common/wm_shell.h"
15 #include "ash/public/cpp/shell_window_ids.h" 15 #include "ash/public/cpp/shell_window_ids.h"
16 #include "ash/public/interfaces/shutdown.mojom.h"
16 #include "ash/shell.h" 17 #include "ash/shell.h"
17 #include "ash/wm/session_state_animator.h" 18 #include "ash/wm/session_state_animator.h"
18 #include "ash/wm/session_state_animator_impl.h" 19 #include "ash/wm/session_state_animator_impl.h"
20 #include "ash/wm/shutdown_client_proxy.h"
19 #include "base/bind.h" 21 #include "base/bind.h"
20 #include "base/bind_helpers.h" 22 #include "base/bind_helpers.h"
21 #include "base/command_line.h" 23 #include "base/command_line.h"
22 #include "base/location.h" 24 #include "base/location.h"
23 #include "base/logging.h" 25 #include "base/logging.h"
24 #include "base/metrics/histogram_macros.h" 26 #include "base/metrics/histogram_macros.h"
25 #include "base/strings/string_util.h" 27 #include "base/strings/string_util.h"
26 #include "base/timer/timer.h" 28 #include "base/timer/timer.h"
27 #include "ui/aura/window_tree_host.h" 29 #include "ui/aura/window_tree_host.h"
28 #include "ui/views/controls/menu/menu_controller.h" 30 #include "ui/views/controls/menu/menu_controller.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 70
69 const int LockStateController::kLockFailTimeoutMs = 8000 * kTimeoutMultiplier; 71 const int LockStateController::kLockFailTimeoutMs = 8000 * kTimeoutMultiplier;
70 const int LockStateController::kLockToShutdownTimeoutMs = 150; 72 const int LockStateController::kLockToShutdownTimeoutMs = 150;
71 const int LockStateController::kShutdownRequestDelayMs = 50; 73 const int LockStateController::kShutdownRequestDelayMs = 50;
72 74
73 LockStateController::TestApi::TestApi(LockStateController* controller) 75 LockStateController::TestApi::TestApi(LockStateController* controller)
74 : controller_(controller) {} 76 : controller_(controller) {}
75 77
76 LockStateController::TestApi::~TestApi() {} 78 LockStateController::TestApi::~TestApi() {}
77 79
78 LockStateController::LockStateController() 80 void LockStateController::TestApi::SetShutdownClient(
81 std::unique_ptr<mojom::ShutdownClient> client) {
82 controller_->shutdown_client_ = std::move(client);
83 }
84
85 LockStateController::LockStateController(service_manager::Connector* connector)
79 : animator_(new SessionStateAnimatorImpl()), 86 : animator_(new SessionStateAnimatorImpl()),
80 login_status_(LoginStatus::NOT_LOGGED_IN), 87 login_status_(LoginStatus::NOT_LOGGED_IN),
81 system_is_locked_(false), 88 system_is_locked_(false),
82 shutting_down_(false), 89 shutting_down_(false),
83 shutdown_after_lock_(false), 90 shutdown_after_lock_(false),
84 animating_lock_(false), 91 animating_lock_(false),
85 can_cancel_lock_animation_(false), 92 can_cancel_lock_animation_(false),
93 shutdown_client_(new ShutdownClientProxy(connector)),
86 weak_ptr_factory_(this) { 94 weak_ptr_factory_(this) {
87 Shell::GetPrimaryRootWindow()->GetHost()->AddObserver(this); 95 Shell::GetPrimaryRootWindow()->GetHost()->AddObserver(this);
88 } 96 }
89 97
90 LockStateController::~LockStateController() { 98 LockStateController::~LockStateController() {
91 Shell::GetPrimaryRootWindow()->GetHost()->RemoveObserver(this); 99 Shell::GetPrimaryRootWindow()->GetHost()->RemoveObserver(this);
92 } 100 }
93 101
94 void LockStateController::SetDelegate(
95 std::unique_ptr<LockStateControllerDelegate> delegate) {
96 delegate_ = std::move(delegate);
97 }
98
99 void LockStateController::StartLockAnimation(bool shutdown_after_lock) { 102 void LockStateController::StartLockAnimation(bool shutdown_after_lock) {
100 if (animating_lock_) 103 if (animating_lock_)
101 return; 104 return;
102 shutdown_after_lock_ = shutdown_after_lock; 105 shutdown_after_lock_ = shutdown_after_lock;
103 can_cancel_lock_animation_ = true; 106 can_cancel_lock_animation_ = true;
104 107
105 StartCancellablePreLockAnimation(); 108 StartCancellablePreLockAnimation();
106 } 109 }
107 110
108 void LockStateController::StartShutdownAnimation() { 111 void LockStateController::StartShutdownAnimation() {
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 #if defined(OS_CHROMEOS) 321 #if defined(OS_CHROMEOS)
319 if (!base::SysInfo::IsRunningOnChromeOS()) { 322 if (!base::SysInfo::IsRunningOnChromeOS()) {
320 ShellDelegate* delegate = WmShell::Get()->delegate(); 323 ShellDelegate* delegate = WmShell::Get()->delegate();
321 if (delegate) { 324 if (delegate) {
322 delegate->Exit(); 325 delegate->Exit();
323 return; 326 return;
324 } 327 }
325 } 328 }
326 #endif 329 #endif
327 WmShell::Get()->RecordUserMetricsAction(UMA_ACCEL_SHUT_DOWN_POWER_BUTTON); 330 WmShell::Get()->RecordUserMetricsAction(UMA_ACCEL_SHUT_DOWN_POWER_BUTTON);
328 delegate_->RequestShutdown(); 331
332 // Connect to the browser to tell it to shutdown the computer. It will either
James Cook 2016/11/02 20:20:03 Thanks for the detailed docs and TODO.
333 // shut down or restart the computer based on the device settings.
334 //
335 // TODO(erg): Once CrosSettings has been moved out of chrome/,
336 // LockStateController should become a preference observer of it, and we
337 // should move the current content_browser implementation here.
338 // crbug.com/628792
339 shutdown_client_->RequestShutdown();
329 } 340 }
330 341
331 void LockStateController::StartCancellableShutdownAnimation() { 342 void LockStateController::StartCancellableShutdownAnimation() {
332 Shell* shell = Shell::GetInstance(); 343 Shell* shell = Shell::GetInstance();
333 // Hide cursor, but let it reappear if the mouse moves. 344 // Hide cursor, but let it reappear if the mouse moves.
334 shell->cursor_manager()->HideCursor(); 345 shell->cursor_manager()->HideCursor();
335 346
336 animator_->StartAnimation( 347 animator_->StartAnimation(
337 SessionStateAnimator::ROOT_CONTAINER, 348 SessionStateAnimator::ROOT_CONTAINER,
338 SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS, 349 SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS,
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 SessionStateAnimator::AnimationSpeed speed, 587 SessionStateAnimator::AnimationSpeed speed,
577 SessionStateAnimator::AnimationSequence* animation_sequence) { 588 SessionStateAnimator::AnimationSequence* animation_sequence) {
578 if (unlocked_properties_.get() && unlocked_properties_->wallpaper_is_hidden) { 589 if (unlocked_properties_.get() && unlocked_properties_->wallpaper_is_hidden) {
579 animation_sequence->StartAnimation(SessionStateAnimator::WALLPAPER, 590 animation_sequence->StartAnimation(SessionStateAnimator::WALLPAPER,
580 SessionStateAnimator::ANIMATION_FADE_OUT, 591 SessionStateAnimator::ANIMATION_FADE_OUT,
581 speed); 592 speed);
582 } 593 }
583 } 594 }
584 595
585 } // namespace ash 596 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698