| 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/login/lock/screen_locker.h" | |
| 9 #include "chrome/browser/chromeos/settings/cros_settings.h" | 8 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 10 #include "chromeos/dbus/dbus_thread_manager.h" | 9 #include "chromeos/dbus/dbus_thread_manager.h" |
| 11 #include "chromeos/dbus/power_manager_client.h" | 10 #include "chromeos/dbus/power_manager_client.h" |
| 12 #include "chromeos/dbus/session_manager_client.h" | 11 #include "chromeos/dbus/session_manager_client.h" |
| 13 #include "chromeos/settings/cros_settings_names.h" | 12 #include "chromeos/settings/cros_settings_names.h" |
| 14 #include "chromeos/settings/cros_settings_provider.h" | |
| 15 #include "content/public/browser/web_contents.h" | |
| 16 | 13 |
| 17 namespace chromeos { | 14 namespace chromeos { |
| 18 | 15 |
| 19 SessionStateControllerDelegateChromeos::SessionStateControllerDelegateChromeos() | 16 SessionStateControllerDelegateChromeos::SessionStateControllerDelegateChromeos() |
| 20 : weak_factory_(this) { | 17 : weak_factory_(this) { |
| 21 } | 18 } |
| 22 | 19 |
| 23 SessionStateControllerDelegateChromeos:: | 20 SessionStateControllerDelegateChromeos:: |
| 24 ~SessionStateControllerDelegateChromeos() { | 21 ~SessionStateControllerDelegateChromeos() { |
| 25 } | 22 } |
| 26 | 23 |
| 27 bool SessionStateControllerDelegateChromeos::IsLoading() const { | |
| 28 return ScreenLocker::default_screen_locker() | |
| 29 ->GetAssociatedWebUI() | |
| 30 ->GetWebContents() | |
| 31 ->IsLoading(); | |
| 32 } | |
| 33 | |
| 34 void SessionStateControllerDelegateChromeos::RequestLockScreen() { | 24 void SessionStateControllerDelegateChromeos::RequestLockScreen() { |
| 35 // TODO(antrim) : additional logging for crbug/173178 | 25 // TODO(antrim) : additional logging for crbug/173178 |
| 36 LOG(WARNING) << "Requesting screen lock from SessionStateControllerDelegate"; | 26 LOG(WARNING) << "Requesting screen lock from SessionStateControllerDelegate"; |
| 37 DBusThreadManager::Get()->GetSessionManagerClient()->RequestLockScreen(); | 27 DBusThreadManager::Get()->GetSessionManagerClient()->RequestLockScreen(); |
| 38 } | 28 } |
| 39 | 29 |
| 40 void SessionStateControllerDelegateChromeos::RequestShutdown() { | 30 void SessionStateControllerDelegateChromeos::RequestShutdown() { |
| 41 CrosSettings* cros_settings = CrosSettings::Get(); | 31 CrosSettings* cros_settings = CrosSettings::Get(); |
| 42 CrosSettingsProvider::TrustedStatus status = | 32 CrosSettingsProvider::TrustedStatus status = |
| 43 cros_settings->PrepareTrustedValues(base::Bind( | 33 cros_settings->PrepareTrustedValues(base::Bind( |
| 44 &SessionStateControllerDelegateChromeos::RequestShutdown, | 34 &SessionStateControllerDelegateChromeos::RequestShutdown, |
| 45 weak_factory_.GetWeakPtr())); | 35 weak_factory_.GetWeakPtr())); |
| 46 if (status != CrosSettingsProvider::TRUSTED) | 36 if (status != CrosSettingsProvider::TRUSTED) |
| 47 return; | 37 return; |
| 48 | 38 |
| 49 // Get the updated policy. | 39 // Get the updated policy. |
| 50 bool reboot_on_shutdown = false; | 40 bool reboot_on_shutdown = false; |
| 51 cros_settings->GetBoolean(kRebootOnShutdown, &reboot_on_shutdown); | 41 cros_settings->GetBoolean(kRebootOnShutdown, &reboot_on_shutdown); |
| 52 | 42 |
| 53 if (reboot_on_shutdown) | 43 if (reboot_on_shutdown) |
| 54 DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart(); | 44 DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart(); |
| 55 else | 45 else |
| 56 DBusThreadManager::Get()->GetPowerManagerClient()->RequestShutdown(); | 46 DBusThreadManager::Get()->GetPowerManagerClient()->RequestShutdown(); |
| 57 } | 47 } |
| 58 | 48 |
| 59 } // namespace chromeos | 49 } // namespace chromeos |
| OLD | NEW |