Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / chromeos / power / session_state_controller_delegate_chromeos.cc
blob299db3fb7643217031da5d75258cf6f373b3b580
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.
5 #include "chrome/browser/chromeos/power/session_state_controller_delegate_chromeos.h"
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 #include "chromeos/settings/cros_settings_provider.h"
15 namespace chromeos {
17 SessionStateControllerDelegateChromeos::SessionStateControllerDelegateChromeos()
18 : weak_factory_(this) {
21 SessionStateControllerDelegateChromeos::
22 ~SessionStateControllerDelegateChromeos() {
25 void SessionStateControllerDelegateChromeos::RequestLockScreen() {
26 // TODO(antrim) : additional logging for crbug/173178
27 LOG(WARNING) << "Requesting screen lock from SessionStateControllerDelegate";
28 DBusThreadManager::Get()->GetSessionManagerClient()->RequestLockScreen();
31 void SessionStateControllerDelegateChromeos::RequestShutdown() {
32 CrosSettings* cros_settings = CrosSettings::Get();
33 CrosSettingsProvider::TrustedStatus status =
34 cros_settings->PrepareTrustedValues(base::Bind(
35 &SessionStateControllerDelegateChromeos::RequestShutdown,
36 weak_factory_.GetWeakPtr()));
37 if (status != CrosSettingsProvider::TRUSTED)
38 return;
40 // Get the updated policy.
41 bool reboot_on_shutdown = false;
42 cros_settings->GetBoolean(kRebootOnShutdown, &reboot_on_shutdown);
44 if (reboot_on_shutdown)
45 DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart();
46 else
47 DBusThreadManager::Get()->GetPowerManagerClient()->RequestShutdown();
50 } // namespace chromeos