Chromium Code Reviews| Index: ash/wm/lock_state_controller.cc |
| diff --git a/ash/wm/lock_state_controller.cc b/ash/wm/lock_state_controller.cc |
| index b0392dd7249352ed550f48190c0c429625740d9c..f00737c79385e47fbd64a64d8edd484c4fb38536 100644 |
| --- a/ash/wm/lock_state_controller.cc |
| +++ b/ash/wm/lock_state_controller.cc |
| @@ -13,9 +13,11 @@ |
| #include "ash/common/shell_delegate.h" |
| #include "ash/common/wm_shell.h" |
| #include "ash/public/cpp/shell_window_ids.h" |
| +#include "ash/public/interfaces/shutdown.mojom.h" |
| #include "ash/shell.h" |
| #include "ash/wm/session_state_animator.h" |
| #include "ash/wm/session_state_animator_impl.h" |
| +#include "ash/wm/shutdown_client_proxy.h" |
| #include "base/bind.h" |
| #include "base/bind_helpers.h" |
| #include "base/command_line.h" |
| @@ -75,7 +77,12 @@ LockStateController::TestApi::TestApi(LockStateController* controller) |
| LockStateController::TestApi::~TestApi() {} |
| -LockStateController::LockStateController() |
| +void LockStateController::TestApi::SetShutdownClient( |
| + std::unique_ptr<mojom::ShutdownClient> client) { |
| + controller_->shutdown_client_ = std::move(client); |
| +} |
| + |
| +LockStateController::LockStateController(service_manager::Connector* connector) |
| : animator_(new SessionStateAnimatorImpl()), |
| login_status_(LoginStatus::NOT_LOGGED_IN), |
| system_is_locked_(false), |
| @@ -83,6 +90,7 @@ LockStateController::LockStateController() |
| shutdown_after_lock_(false), |
| animating_lock_(false), |
| can_cancel_lock_animation_(false), |
| + shutdown_client_(new ShutdownClientProxy(connector)), |
| weak_ptr_factory_(this) { |
| Shell::GetPrimaryRootWindow()->GetHost()->AddObserver(this); |
| } |
| @@ -91,11 +99,6 @@ LockStateController::~LockStateController() { |
| Shell::GetPrimaryRootWindow()->GetHost()->RemoveObserver(this); |
| } |
| -void LockStateController::SetDelegate( |
| - std::unique_ptr<LockStateControllerDelegate> delegate) { |
| - delegate_ = std::move(delegate); |
| -} |
| - |
| void LockStateController::StartLockAnimation(bool shutdown_after_lock) { |
| if (animating_lock_) |
| return; |
| @@ -325,7 +328,15 @@ void LockStateController::OnRealPowerTimeout() { |
| } |
| #endif |
| WmShell::Get()->RecordUserMetricsAction(UMA_ACCEL_SHUT_DOWN_POWER_BUTTON); |
| - delegate_->RequestShutdown(); |
| + |
| + // 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.
|
| + // shut down or restart the computer based on the device settings. |
| + // |
| + // TODO(erg): Once CrosSettings has been moved out of chrome/, |
| + // LockStateController should become a preference observer of it, and we |
| + // should move the current content_browser implementation here. |
| + // crbug.com/628792 |
| + shutdown_client_->RequestShutdown(); |
| } |
| void LockStateController::StartCancellableShutdownAnimation() { |