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

Unified Diff: chrome/browser/chromeos/settings/shutdown_policy_forwarder.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
Index: chrome/browser/chromeos/settings/shutdown_policy_forwarder.cc
diff --git a/chrome/browser/chromeos/settings/shutdown_policy_forwarder.cc b/chrome/browser/chromeos/settings/shutdown_policy_forwarder.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a651156394e0dda9ce91b6ff3092ac86bb1d8ca7
--- /dev/null
+++ b/chrome/browser/chromeos/settings/shutdown_policy_forwarder.cc
@@ -0,0 +1,43 @@
+// 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 "chrome/browser/chromeos/settings/shutdown_policy_forwarder.h"
+
+#include "ash/public/interfaces/shutdown.mojom.h"
+#include "chrome/browser/chromeos/settings/cros_settings.h"
+#include "chrome/browser/ui/ash/ash_util.h"
+#include "content/public/common/service_manager_connection.h"
+#include "services/service_manager/public/cpp/connector.h"
+
+namespace chromeos {
+
+ShutdownPolicyForwarder::ShutdownPolicyForwarder()
+ : shutdown_policy_handler_(CrosSettings::Get(), this) {
+ // Request the initial setting.
+ shutdown_policy_handler_.NotifyDelegateWithShutdownPolicy();
+}
+
+ShutdownPolicyForwarder::~ShutdownPolicyForwarder() {}
+
+void ShutdownPolicyForwarder::OnShutdownPolicyChanged(bool reboot_on_shutdown) {
+ service_manager::Connector* connector =
+ content::ServiceManagerConnection::GetForProcess()->GetConnector();
+
+ // Shutdown policy changes rarely so don't bother caching the connection.
+ ash::mojom::ShutdownControllerPtr shutdown_controller;
+
+ // Under mash the ShutdownController interface is in the ash process. In
+ // classic ash the browser provides it to itself.
+ if (chrome::IsRunningInMash()) {
+ connector->ConnectToInterface("service:ash", &shutdown_controller);
+ } else {
+ connector->ConnectToInterface("service:content_browser",
+ &shutdown_controller);
+ }
+
+ // Forward the setting to ash.
+ shutdown_controller->SetRebootOnShutdown(reboot_on_shutdown);
+}
+
+} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698