| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ash/common/shutdown_controller.h" |
| 6 |
| 7 #include "ash/common/shell_delegate.h" |
| 8 #include "ash/common/wm_shell.h" |
| 9 |
| 10 #if defined(OS_CHROMEOS) |
| 11 #include "base/sys_info.h" |
| 12 #include "chromeos/dbus/dbus_thread_manager.h" |
| 13 #include "chromeos/dbus/power_manager_client.h" |
| 14 #endif |
| 15 |
| 16 using chromeos::DBusThreadManager; |
| 17 |
| 18 namespace ash { |
| 19 |
| 20 ShutdownController::ShutdownController() {} |
| 21 |
| 22 ShutdownController::~ShutdownController() {} |
| 23 |
| 24 void ShutdownController::ShutdownOrReboot() { |
| 25 #if defined(OS_CHROMEOS) |
| 26 if (base::SysInfo::IsRunningOnChromeOS()) { |
| 27 // Power manager handles shutdown on Chrome OS hardware. |
| 28 if (reboot_on_shutdown_) |
| 29 DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart(); |
| 30 else |
| 31 DBusThreadManager::Get()->GetPowerManagerClient()->RequestShutdown(); |
| 32 return; |
| 33 } |
| 34 #endif // defined(OS_CHROMEOS) |
| 35 |
| 36 // On Windows and on Linux desktop just exit. |
| 37 WmShell::Get()->delegate()->Exit(); |
| 38 } |
| 39 |
| 40 void ShutdownController::SetRebootOnShutdown(bool reboot_on_shutdown) { |
| 41 reboot_on_shutdown_ = reboot_on_shutdown; |
| 42 } |
| 43 |
| 44 void ShutdownController::BindRequest(mojom::ShutdownControllerRequest request) { |
| 45 bindings_.AddBinding(this, std::move(request)); |
| 46 } |
| 47 |
| 48 } // namespace ash |
| OLD | NEW |