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

Unified Diff: ash/common/shutdown_controller.cc

Issue 2497123002: chromeos: Move device shutdown handling out of chrome into ash (Closed)
Patch Set: rebase 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/common/shutdown_controller.h ('k') | ash/common/system/chromeos/shutdown_policy_observer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/common/shutdown_controller.cc
diff --git a/ash/common/shutdown_controller.cc b/ash/common/shutdown_controller.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7342eb2cc43810226512d35becb9ed05550ae8f6
--- /dev/null
+++ b/ash/common/shutdown_controller.cc
@@ -0,0 +1,47 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ash/common/shutdown_controller.h"
+
+#include "ash/common/shell_delegate.h"
+#include "ash/common/wm_shell.h"
+
+#if defined(OS_CHROMEOS)
+#include "base/sys_info.h"
+#include "chromeos/dbus/dbus_thread_manager.h"
+#include "chromeos/dbus/power_manager_client.h"
+#endif
+
+namespace ash {
+
+ShutdownController::ShutdownController() {}
+
+ShutdownController::~ShutdownController() {}
+
+void ShutdownController::ShutDownOrReboot() {
+#if defined(OS_CHROMEOS)
+ if (base::SysInfo::IsRunningOnChromeOS()) {
+ // Power manager handles shutdown on Chrome OS hardware.
+ using chromeos::DBusThreadManager;
+ if (reboot_on_shutdown_)
+ DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart();
+ else
+ DBusThreadManager::Get()->GetPowerManagerClient()->RequestShutdown();
+ return;
+ }
+#endif // defined(OS_CHROMEOS)
+
+ // On Windows and on Linux desktop just exit.
+ WmShell::Get()->delegate()->Exit();
+}
+
+void ShutdownController::SetRebootOnShutdown(bool reboot_on_shutdown) {
+ reboot_on_shutdown_ = reboot_on_shutdown;
+}
+
+void ShutdownController::BindRequest(mojom::ShutdownControllerRequest request) {
+ bindings_.AddBinding(this, std::move(request));
+}
+
+} // namespace ash
« no previous file with comments | « ash/common/shutdown_controller.h ('k') | ash/common/system/chromeos/shutdown_policy_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698