OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/chromeos/power/session_state_controller_delegate_chrome
os.h" | 5 #include "chrome/browser/chromeos/power/shutdown_client_impl.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "chrome/browser/chromeos/settings/cros_settings.h" | 8 #include "chrome/browser/chromeos/settings/cros_settings.h" |
9 #include "chromeos/dbus/dbus_thread_manager.h" | 9 #include "chromeos/dbus/dbus_thread_manager.h" |
10 #include "chromeos/dbus/power_manager_client.h" | 10 #include "chromeos/dbus/power_manager_client.h" |
11 #include "chromeos/dbus/session_manager_client.h" | 11 #include "chromeos/dbus/session_manager_client.h" |
12 #include "chromeos/settings/cros_settings_names.h" | 12 #include "chromeos/settings/cros_settings_names.h" |
13 | 13 |
14 namespace chromeos { | 14 namespace chromeos { |
15 | 15 |
16 SessionStateControllerDelegateChromeos::SessionStateControllerDelegateChromeos() | 16 ShutdownClientImpl::ShutdownClientImpl() : weak_factory_(this) {} |
17 : weak_factory_(this) { | |
18 } | |
19 | 17 |
20 SessionStateControllerDelegateChromeos:: | 18 ShutdownClientImpl::~ShutdownClientImpl() {} |
21 ~SessionStateControllerDelegateChromeos() { | |
22 } | |
23 | 19 |
24 void SessionStateControllerDelegateChromeos::RequestShutdown() { | 20 void ShutdownClientImpl::RequestShutdown() { |
25 CrosSettings* cros_settings = CrosSettings::Get(); | 21 CrosSettings* cros_settings = CrosSettings::Get(); |
26 CrosSettingsProvider::TrustedStatus status = | 22 CrosSettingsProvider::TrustedStatus status = |
27 cros_settings->PrepareTrustedValues(base::Bind( | 23 cros_settings->PrepareTrustedValues(base::Bind( |
28 &SessionStateControllerDelegateChromeos::RequestShutdown, | 24 &ShutdownClientImpl::RequestShutdown, weak_factory_.GetWeakPtr())); |
29 weak_factory_.GetWeakPtr())); | |
30 if (status != CrosSettingsProvider::TRUSTED) | 25 if (status != CrosSettingsProvider::TRUSTED) |
31 return; | 26 return; |
32 | 27 |
33 // Get the updated policy. | 28 // Get the updated policy. |
34 bool reboot_on_shutdown = false; | 29 bool reboot_on_shutdown = false; |
35 cros_settings->GetBoolean(kRebootOnShutdown, &reboot_on_shutdown); | 30 cros_settings->GetBoolean(kRebootOnShutdown, &reboot_on_shutdown); |
36 | 31 |
37 if (reboot_on_shutdown) | 32 if (reboot_on_shutdown) |
38 DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart(); | 33 DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart(); |
39 else | 34 else |
40 DBusThreadManager::Get()->GetPowerManagerClient()->RequestShutdown(); | 35 DBusThreadManager::Get()->GetPowerManagerClient()->RequestShutdown(); |
41 } | 36 } |
42 | 37 |
43 } // namespace chromeos | 38 } // namespace chromeos |
OLD | NEW |