Chromium Code Reviews| Index: chrome/browser/ui/ash/system_tray_delegate_chromeos.cc |
| diff --git a/chrome/browser/ui/ash/system_tray_delegate_chromeos.cc b/chrome/browser/ui/ash/system_tray_delegate_chromeos.cc |
| index 85c8e85c9310879986d18c25bfbfc1a7ea3bab0f..ecd38165cd2710a216237224d63140d448f731b3 100644 |
| --- a/chrome/browser/ui/ash/system_tray_delegate_chromeos.cc |
| +++ b/chrome/browser/ui/ash/system_tray_delegate_chromeos.cc |
| @@ -19,6 +19,7 @@ |
| #include "ash/shell_window_ids.h" |
| #include "ash/system/bluetooth/bluetooth_observer.h" |
| #include "ash/system/chromeos/session/logout_button_observer.h" |
| +#include "ash/system/chromeos/shutdown_policy_observer.h" |
| #include "ash/system/date/clock_observer.h" |
| #include "ash/system/ime/ime_observer.h" |
| #include "ash/system/tray/system_tray.h" |
| @@ -30,6 +31,7 @@ |
| #include "ash/system/user/user_observer.h" |
| #include "ash/volume_control_delegate.h" |
| #include "ash/wm/lock_state_controller.h" |
| +#include "base/bind.h" |
| #include "base/bind_helpers.h" |
| #include "base/callback.h" |
| #include "base/logging.h" |
| @@ -134,6 +136,12 @@ void ExtractIMEInfo(const input_method::InputMethodDescriptor& ime, |
| info->third_party = extension_ime_util::IsExtensionIME(ime.id()); |
| } |
| +void TriggerShutdown(bool reboot_on_shutdown) { |
| + ash::Shell::GetInstance()->lock_state_controller()->RequestShutdown( |
| + reboot_on_shutdown ? ash::LockStateController::RESTART |
| + : ash::LockStateController::POWER_OFF); |
| +} |
| + |
| gfx::NativeWindow GetNativeWindowByStatus(ash::user::LoginStatus login_status, |
| bool session_started) { |
| bool isUserAddingRunning = ash::Shell::GetInstance() |
| @@ -225,6 +233,8 @@ SystemTrayDelegateChromeOS::SystemTrayDelegateChromeOS() |
| base::Unretained(this))); |
| user_manager::UserManager::Get()->AddSessionStateObserver(this); |
| + shutdown_policy_observer_.reset( |
| + new ShutdownPolicyObserver(CrosSettings::Get(), this)); |
| } |
| void SystemTrayDelegateChromeOS::Initialize() { |
| @@ -591,9 +601,14 @@ void SystemTrayDelegateChromeOS::ShowUserLogin() { |
| } |
| } |
| -void SystemTrayDelegateChromeOS::ShutDown() { |
| +void SystemTrayDelegateChromeOS::Restart() { |
| ash::Shell::GetInstance()->lock_state_controller()->RequestShutdown( |
| - ash::LockStateController::POWER_OFF); |
| + ash::LockStateController::RESTART); |
|
stevenjb
2014/12/17 19:09:02
It seems super silly for the ash system tray deleg
cschuet (SLOW)
2015/01/07 14:37:07
Done.
|
| +} |
| + |
| +void SystemTrayDelegateChromeOS::ShutDown() { |
| + shutdown_policy_observer_->CheckIfRebootOnShutdown( |
| + base::Bind(&TriggerShutdown)); |
|
stevenjb
2014/12/17 19:09:02
This has gotten a bit out of hand:
1. The UI asks
cschuet (SLOW)
2015/01/07 14:37:07
Done.
|
| } |
| void SystemTrayDelegateChromeOS::SignOut() { |
| @@ -834,6 +849,21 @@ void SystemTrayDelegateChromeOS::RemoveCustodianInfoTrayObserver( |
| custodian_info_changed_observers_.RemoveObserver(observer); |
| } |
| +void SystemTrayDelegateChromeOS::AddShutdownPolicyObserver( |
| + ash::ShutdownPolicyObserver* observer) { |
| + shutdown_policy_observers_.AddObserver(observer); |
| +} |
| + |
| +void SystemTrayDelegateChromeOS::ShouldRebootOnShutdown( |
| + const ash::RebootOnShutdownCallback& callback) { |
| + shutdown_policy_observer_->CheckIfRebootOnShutdown(callback); |
| +} |
| + |
| +void SystemTrayDelegateChromeOS::RemoveShutdownPolicyObserver( |
| + ash::ShutdownPolicyObserver* observer) { |
| + shutdown_policy_observers_.RemoveObserver(observer); |
| +} |
| + |
| void SystemTrayDelegateChromeOS::UserAddedToSession( |
| const user_manager::User* active_user) { |
| } |
| @@ -1297,6 +1327,13 @@ void SystemTrayDelegateChromeOS::OnAccessibilityStatusChanged( |
| OnAccessibilityModeChanged(details.notify); |
| } |
| +void SystemTrayDelegateChromeOS::OnShutdownPolicyChanged( |
| + bool reboot_on_shutdown) { |
| + // Notify all observers. |
| + FOR_EACH_OBSERVER(ash::ShutdownPolicyObserver, shutdown_policy_observers_, |
| + OnShutdownPolicyChanged(reboot_on_shutdown)); |
| +} |
| + |
| ash::SystemTrayDelegate* CreateSystemTrayDelegate() { |
| return new SystemTrayDelegateChromeOS(); |
| } |