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/session_state_controller_delegate_chrome os.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "chrome/browser/chromeos/settings/cros_settings.h" | |
8 #include "chromeos/dbus/dbus_thread_manager.h" | 9 #include "chromeos/dbus/dbus_thread_manager.h" |
9 #include "chromeos/dbus/power_manager_client.h" | 10 #include "chromeos/dbus/power_manager_client.h" |
10 #include "chromeos/dbus/session_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" | |
11 | 14 |
12 namespace chromeos { | 15 namespace chromeos { |
13 | 16 |
17 SessionStateControllerDelegateChromeos::SessionStateControllerDelegateChromeos() | |
18 : weak_factory_(this) { | |
19 } | |
20 | |
21 SessionStateControllerDelegateChromeos:: | |
22 ~SessionStateControllerDelegateChromeos() { | |
23 } | |
24 | |
14 void SessionStateControllerDelegateChromeos::RequestLockScreen() { | 25 void SessionStateControllerDelegateChromeos::RequestLockScreen() { |
15 // TODO(antrim) : additional logging for crbug/173178 | 26 // TODO(antrim) : additional logging for crbug/173178 |
16 LOG(WARNING) << "Requesting screen lock from SessionStateControllerDelegate"; | 27 LOG(WARNING) << "Requesting screen lock from SessionStateControllerDelegate"; |
17 DBusThreadManager::Get()->GetSessionManagerClient()->RequestLockScreen(); | 28 DBusThreadManager::Get()->GetSessionManagerClient()->RequestLockScreen(); |
18 } | 29 } |
19 | 30 |
20 void SessionStateControllerDelegateChromeos::RequestRestart() { | 31 void SessionStateControllerDelegateChromeos::RequestShutdownOrRestart() { |
21 DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart(); | 32 CrosSettings* cros_settings = CrosSettings::Get(); |
22 } | 33 CrosSettingsProvider::TrustedStatus status = |
34 cros_settings->PrepareTrustedValues(base::Bind( | |
35 &SessionStateControllerDelegateChromeos::RequestShutdownOrRestart, | |
36 weak_factory_.GetWeakPtr())); | |
37 if (status != CrosSettingsProvider::TRUSTED) | |
38 return; | |
23 | 39 |
24 void SessionStateControllerDelegateChromeos::RequestShutdown() { | 40 // Get the updated policy. |
41 bool reboot_on_shutdown = false; | |
42 cros_settings->GetBoolean(kRebootOnShutdown, &reboot_on_shutdown); | |
43 | |
44 if (reboot_on_shutdown) { | |
Daniel Erat
2015/01/07 16:18:40
nit: it's a line shorter to do:
if (reboot_on_s
cschuet (SLOW)
2015/01/13 10:38:28
Done.
| |
45 DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart(); | |
46 return; | |
47 } | |
25 DBusThreadManager::Get()->GetPowerManagerClient()->RequestShutdown(); | 48 DBusThreadManager::Get()->GetPowerManagerClient()->RequestShutdown(); |
26 } | 49 } |
27 | 50 |
28 } // namespace chromeos | 51 } // namespace chromeos |
OLD | NEW |