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

Side by Side 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 unified diff | Download patch
OLDNEW
(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 "chrome/browser/chromeos/settings/shutdown_policy_forwarder.h"
6
7 #include "ash/public/interfaces/shutdown.mojom.h"
8 #include "chrome/browser/chromeos/settings/cros_settings.h"
9 #include "chrome/browser/ui/ash/ash_util.h"
10 #include "content/public/common/service_manager_connection.h"
11 #include "services/service_manager/public/cpp/connector.h"
12
13 namespace chromeos {
14
15 ShutdownPolicyForwarder::ShutdownPolicyForwarder()
16 : shutdown_policy_handler_(CrosSettings::Get(), this) {
17 // Request the initial setting.
18 shutdown_policy_handler_.NotifyDelegateWithShutdownPolicy();
19 }
20
21 ShutdownPolicyForwarder::~ShutdownPolicyForwarder() {}
22
23 void ShutdownPolicyForwarder::OnShutdownPolicyChanged(bool reboot_on_shutdown) {
24 service_manager::Connector* connector =
25 content::ServiceManagerConnection::GetForProcess()->GetConnector();
26
27 // Shutdown policy changes rarely so don't bother caching the connection.
28 ash::mojom::ShutdownControllerPtr shutdown_controller;
29
30 // Under mash the ShutdownController interface is in the ash process. In
31 // classic ash the browser provides it to itself.
32 if (chrome::IsRunningInMash()) {
33 connector->ConnectToInterface("service:ash", &shutdown_controller);
34 } else {
35 connector->ConnectToInterface("service:content_browser",
36 &shutdown_controller);
37 }
38
39 // Forward the setting to ash.
40 shutdown_controller->SetRebootOnShutdown(reboot_on_shutdown);
41 }
42
43 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698