| 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 "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 |
| OLD | NEW |