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

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

Issue 2471643002: mash: remove the LockStateControllerDelegate. (Closed)
Patch Set: sky comments 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/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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 defined(SYZYASAN) 65 defined(SYZYASAN)
64 static const int kTimeoutMultiplier = 2; 66 static const int kTimeoutMultiplier = 2;
65 #else 67 #else
66 static const int kTimeoutMultiplier = 1; 68 static const int kTimeoutMultiplier = 1;
67 #endif 69 #endif
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::LockStateController(service_manager::Connector* connector)
74 : controller_(controller) {}
75
76 LockStateController::TestApi::~TestApi() {}
77
78 LockStateController::LockStateController()
79 : animator_(new SessionStateAnimatorImpl()), 76 : animator_(new SessionStateAnimatorImpl()),
80 login_status_(LoginStatus::NOT_LOGGED_IN), 77 login_status_(LoginStatus::NOT_LOGGED_IN),
81 system_is_locked_(false), 78 system_is_locked_(false),
82 shutting_down_(false), 79 shutting_down_(false),
83 shutdown_after_lock_(false), 80 shutdown_after_lock_(false),
84 animating_lock_(false), 81 animating_lock_(false),
85 can_cancel_lock_animation_(false), 82 can_cancel_lock_animation_(false),
83 shutdown_client_(base::MakeUnique<ShutdownClientProxy>(connector)),
86 weak_ptr_factory_(this) { 84 weak_ptr_factory_(this) {
87 Shell::GetPrimaryRootWindow()->GetHost()->AddObserver(this); 85 Shell::GetPrimaryRootWindow()->GetHost()->AddObserver(this);
88 } 86 }
89 87
90 LockStateController::~LockStateController() { 88 LockStateController::~LockStateController() {
91 Shell::GetPrimaryRootWindow()->GetHost()->RemoveObserver(this); 89 Shell::GetPrimaryRootWindow()->GetHost()->RemoveObserver(this);
92 } 90 }
93 91
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) { 92 void LockStateController::StartLockAnimation(bool shutdown_after_lock) {
100 if (animating_lock_) 93 if (animating_lock_)
101 return; 94 return;
102 shutdown_after_lock_ = shutdown_after_lock; 95 shutdown_after_lock_ = shutdown_after_lock;
103 can_cancel_lock_animation_ = true; 96 can_cancel_lock_animation_ = true;
104 97
105 StartCancellablePreLockAnimation(); 98 StartCancellablePreLockAnimation();
106 } 99 }
107 100
108 void LockStateController::StartShutdownAnimation() { 101 void LockStateController::StartShutdownAnimation() {
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 #if defined(OS_CHROMEOS) 311 #if defined(OS_CHROMEOS)
319 if (!base::SysInfo::IsRunningOnChromeOS()) { 312 if (!base::SysInfo::IsRunningOnChromeOS()) {
320 ShellDelegate* delegate = WmShell::Get()->delegate(); 313 ShellDelegate* delegate = WmShell::Get()->delegate();
321 if (delegate) { 314 if (delegate) {
322 delegate->Exit(); 315 delegate->Exit();
323 return; 316 return;
324 } 317 }
325 } 318 }
326 #endif 319 #endif
327 WmShell::Get()->RecordUserMetricsAction(UMA_ACCEL_SHUT_DOWN_POWER_BUTTON); 320 WmShell::Get()->RecordUserMetricsAction(UMA_ACCEL_SHUT_DOWN_POWER_BUTTON);
328 delegate_->RequestShutdown(); 321
322 // Connect to the browser to tell it to shutdown the computer. It will either
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();
329 } 330 }
330 331
331 void LockStateController::StartCancellableShutdownAnimation() { 332 void LockStateController::StartCancellableShutdownAnimation() {
332 Shell* shell = Shell::GetInstance(); 333 Shell* shell = Shell::GetInstance();
333 // Hide cursor, but let it reappear if the mouse moves. 334 // Hide cursor, but let it reappear if the mouse moves.
334 shell->cursor_manager()->HideCursor(); 335 shell->cursor_manager()->HideCursor();
335 336
336 animator_->StartAnimation( 337 animator_->StartAnimation(
337 SessionStateAnimator::ROOT_CONTAINER, 338 SessionStateAnimator::ROOT_CONTAINER,
338 SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS, 339 SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS,
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 SessionStateAnimator::AnimationSpeed speed, 577 SessionStateAnimator::AnimationSpeed speed,
577 SessionStateAnimator::AnimationSequence* animation_sequence) { 578 SessionStateAnimator::AnimationSequence* animation_sequence) {
578 if (unlocked_properties_.get() && unlocked_properties_->wallpaper_is_hidden) { 579 if (unlocked_properties_.get() && unlocked_properties_->wallpaper_is_hidden) {
579 animation_sequence->StartAnimation(SessionStateAnimator::WALLPAPER, 580 animation_sequence->StartAnimation(SessionStateAnimator::WALLPAPER,
580 SessionStateAnimator::ANIMATION_FADE_OUT, 581 SessionStateAnimator::ANIMATION_FADE_OUT,
581 speed); 582 speed);
582 } 583 }
583 } 584 }
584 585
585 } // namespace ash 586 } // 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