| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 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/power/shutdown_client_impl.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 #include "chrome/browser/chromeos/settings/cros_settings.h" | |
| 9 #include "chromeos/dbus/dbus_thread_manager.h" | |
| 10 #include "chromeos/dbus/power_manager_client.h" | |
| 11 #include "chromeos/dbus/session_manager_client.h" | |
| 12 #include "chromeos/settings/cros_settings_names.h" | |
| 13 | |
| 14 namespace chromeos { | |
| 15 | |
| 16 ShutdownClientImpl::ShutdownClientImpl() : weak_factory_(this) {} | |
| 17 | |
| 18 ShutdownClientImpl::~ShutdownClientImpl() {} | |
| 19 | |
| 20 void ShutdownClientImpl::RequestShutdown() { | |
| 21 CrosSettings* cros_settings = CrosSettings::Get(); | |
| 22 CrosSettingsProvider::TrustedStatus status = | |
| 23 cros_settings->PrepareTrustedValues(base::Bind( | |
| 24 &ShutdownClientImpl::RequestShutdown, weak_factory_.GetWeakPtr())); | |
| 25 if (status != CrosSettingsProvider::TRUSTED) | |
| 26 return; | |
| 27 | |
| 28 // Get the updated policy. | |
| 29 bool reboot_on_shutdown = false; | |
| 30 cros_settings->GetBoolean(kRebootOnShutdown, &reboot_on_shutdown); | |
| 31 | |
| 32 if (reboot_on_shutdown) | |
| 33 DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart(); | |
| 34 else | |
| 35 DBusThreadManager::Get()->GetPowerManagerClient()->RequestShutdown(); | |
| 36 } | |
| 37 | |
| 38 } // namespace chromeos | |
| OLD | NEW |