| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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/common/shutdown_controller.h" | 5 #include "ash/common/shutdown_controller.h" |
| 6 | 6 |
| 7 #include "ash/common/shell_delegate.h" | 7 #include "ash/common/shell_delegate.h" |
| 8 #include "ash/common/wm_shell.h" | 8 #include "ash/common/wm_shell.h" |
| 9 | |
| 10 #if defined(OS_CHROMEOS) | |
| 11 #include "base/sys_info.h" | 9 #include "base/sys_info.h" |
| 12 #include "chromeos/dbus/dbus_thread_manager.h" | 10 #include "chromeos/dbus/dbus_thread_manager.h" |
| 13 #include "chromeos/dbus/power_manager_client.h" | 11 #include "chromeos/dbus/power_manager_client.h" |
| 14 #endif | |
| 15 | 12 |
| 16 namespace ash { | 13 namespace ash { |
| 17 | 14 |
| 18 ShutdownController::ShutdownController() {} | 15 ShutdownController::ShutdownController() {} |
| 19 | 16 |
| 20 ShutdownController::~ShutdownController() {} | 17 ShutdownController::~ShutdownController() {} |
| 21 | 18 |
| 22 void ShutdownController::ShutDownOrReboot() { | 19 void ShutdownController::ShutDownOrReboot() { |
| 23 #if defined(OS_CHROMEOS) | 20 // For developers on Linux desktop just exit the app. |
| 24 if (base::SysInfo::IsRunningOnChromeOS()) { | 21 if (!base::SysInfo::IsRunningOnChromeOS()) { |
| 25 // Power manager handles shutdown on Chrome OS hardware. | 22 WmShell::Get()->delegate()->Exit(); |
| 26 using chromeos::DBusThreadManager; | |
| 27 if (reboot_on_shutdown_) | |
| 28 DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart(); | |
| 29 else | |
| 30 DBusThreadManager::Get()->GetPowerManagerClient()->RequestShutdown(); | |
| 31 return; | 23 return; |
| 32 } | 24 } |
| 33 #endif // defined(OS_CHROMEOS) | |
| 34 | 25 |
| 35 // On Windows and on Linux desktop just exit. | 26 // On real Chrome OS hardware the power manager handles shutdown. |
| 36 WmShell::Get()->delegate()->Exit(); | 27 using chromeos::DBusThreadManager; |
| 28 if (reboot_on_shutdown_) |
| 29 DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart(); |
| 30 else |
| 31 DBusThreadManager::Get()->GetPowerManagerClient()->RequestShutdown(); |
| 37 } | 32 } |
| 38 | 33 |
| 39 void ShutdownController::SetRebootOnShutdown(bool reboot_on_shutdown) { | 34 void ShutdownController::SetRebootOnShutdown(bool reboot_on_shutdown) { |
| 40 reboot_on_shutdown_ = reboot_on_shutdown; | 35 reboot_on_shutdown_ = reboot_on_shutdown; |
| 41 } | 36 } |
| 42 | 37 |
| 43 void ShutdownController::BindRequest(mojom::ShutdownControllerRequest request) { | 38 void ShutdownController::BindRequest(mojom::ShutdownControllerRequest request) { |
| 44 bindings_.AddBinding(this, std::move(request)); | 39 bindings_.AddBinding(this, std::move(request)); |
| 45 } | 40 } |
| 46 | 41 |
| 47 } // namespace ash | 42 } // namespace ash |
| OLD | NEW |