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/session_state_controller_delegate_chrome
os.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 SessionStateControllerDelegateChromeos::SessionStateControllerDelegateChromeos() | |
17 : weak_factory_(this) { | |
18 } | |
19 | |
20 SessionStateControllerDelegateChromeos:: | |
21 ~SessionStateControllerDelegateChromeos() { | |
22 } | |
23 | |
24 void SessionStateControllerDelegateChromeos::RequestShutdown() { | |
25 CrosSettings* cros_settings = CrosSettings::Get(); | |
26 CrosSettingsProvider::TrustedStatus status = | |
27 cros_settings->PrepareTrustedValues(base::Bind( | |
28 &SessionStateControllerDelegateChromeos::RequestShutdown, | |
29 weak_factory_.GetWeakPtr())); | |
30 if (status != CrosSettingsProvider::TRUSTED) | |
31 return; | |
32 | |
33 // Get the updated policy. | |
34 bool reboot_on_shutdown = false; | |
35 cros_settings->GetBoolean(kRebootOnShutdown, &reboot_on_shutdown); | |
36 | |
37 if (reboot_on_shutdown) | |
38 DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart(); | |
39 else | |
40 DBusThreadManager::Get()->GetPowerManagerClient()->RequestShutdown(); | |
41 } | |
42 | |
43 } // namespace chromeos | |
OLD | NEW |