OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/ui/ash/system_tray_delegate_chromeos.h" | 5 #include "chrome/browser/ui/ash/system_tray_delegate_chromeos.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "ash/ash_switches.h" | 12 #include "ash/ash_switches.h" |
13 #include "ash/desktop_background/desktop_background_controller.h" | 13 #include "ash/desktop_background/desktop_background_controller.h" |
14 #include "ash/metrics/user_metrics_recorder.h" | 14 #include "ash/metrics/user_metrics_recorder.h" |
15 #include "ash/session/session_state_delegate.h" | 15 #include "ash/session/session_state_delegate.h" |
16 #include "ash/session/session_state_observer.h" | 16 #include "ash/session/session_state_observer.h" |
17 #include "ash/shell.h" | 17 #include "ash/shell.h" |
18 #include "ash/shell_delegate.h" | 18 #include "ash/shell_delegate.h" |
19 #include "ash/shell_window_ids.h" | 19 #include "ash/shell_window_ids.h" |
20 #include "ash/system/bluetooth/bluetooth_observer.h" | 20 #include "ash/system/bluetooth/bluetooth_observer.h" |
21 #include "ash/system/chromeos/session/logout_button_observer.h" | 21 #include "ash/system/chromeos/session/logout_button_observer.h" |
22 #include "ash/system/chromeos/shutdown_policy_observer.h" | |
22 #include "ash/system/date/clock_observer.h" | 23 #include "ash/system/date/clock_observer.h" |
23 #include "ash/system/ime/ime_observer.h" | 24 #include "ash/system/ime/ime_observer.h" |
24 #include "ash/system/tray/system_tray.h" | 25 #include "ash/system/tray/system_tray.h" |
25 #include "ash/system/tray/system_tray_delegate.h" | 26 #include "ash/system/tray/system_tray_delegate.h" |
26 #include "ash/system/tray/system_tray_notifier.h" | 27 #include "ash/system/tray/system_tray_notifier.h" |
27 #include "ash/system/tray_accessibility.h" | 28 #include "ash/system/tray_accessibility.h" |
28 #include "ash/system/user/login_status.h" | 29 #include "ash/system/user/login_status.h" |
29 #include "ash/system/user/update_observer.h" | 30 #include "ash/system/user/update_observer.h" |
30 #include "ash/system/user/user_observer.h" | 31 #include "ash/system/user/user_observer.h" |
31 #include "ash/volume_control_delegate.h" | 32 #include "ash/volume_control_delegate.h" |
32 #include "ash/wm/lock_state_controller.h" | 33 #include "ash/wm/lock_state_controller.h" |
34 #include "base/bind.h" | |
33 #include "base/bind_helpers.h" | 35 #include "base/bind_helpers.h" |
34 #include "base/callback.h" | 36 #include "base/callback.h" |
35 #include "base/logging.h" | 37 #include "base/logging.h" |
36 #include "base/memory/weak_ptr.h" | 38 #include "base/memory/weak_ptr.h" |
37 #include "base/prefs/pref_service.h" | 39 #include "base/prefs/pref_service.h" |
38 #include "base/strings/stringprintf.h" | 40 #include "base/strings/stringprintf.h" |
39 #include "base/strings/utf_string_conversions.h" | 41 #include "base/strings/utf_string_conversions.h" |
40 #include "base/sys_info.h" | 42 #include "base/sys_info.h" |
41 #include "base/time/time.h" | 43 #include "base/time/time.h" |
42 #include "chrome/browser/browser_process.h" | 44 #include "chrome/browser/browser_process.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
127 void ExtractIMEInfo(const input_method::InputMethodDescriptor& ime, | 129 void ExtractIMEInfo(const input_method::InputMethodDescriptor& ime, |
128 const input_method::InputMethodUtil& util, | 130 const input_method::InputMethodUtil& util, |
129 ash::IMEInfo* info) { | 131 ash::IMEInfo* info) { |
130 info->id = ime.id(); | 132 info->id = ime.id(); |
131 info->name = util.GetInputMethodLongName(ime); | 133 info->name = util.GetInputMethodLongName(ime); |
132 info->medium_name = util.GetInputMethodMediumName(ime); | 134 info->medium_name = util.GetInputMethodMediumName(ime); |
133 info->short_name = util.GetInputMethodShortName(ime); | 135 info->short_name = util.GetInputMethodShortName(ime); |
134 info->third_party = extension_ime_util::IsExtensionIME(ime.id()); | 136 info->third_party = extension_ime_util::IsExtensionIME(ime.id()); |
135 } | 137 } |
136 | 138 |
139 void TriggerShutdown(bool reboot_on_shutdown) { | |
140 ash::Shell::GetInstance()->lock_state_controller()->RequestShutdown( | |
141 reboot_on_shutdown ? ash::LockStateController::RESTART | |
142 : ash::LockStateController::POWER_OFF); | |
143 } | |
144 | |
137 gfx::NativeWindow GetNativeWindowByStatus(ash::user::LoginStatus login_status, | 145 gfx::NativeWindow GetNativeWindowByStatus(ash::user::LoginStatus login_status, |
138 bool session_started) { | 146 bool session_started) { |
139 bool isUserAddingRunning = ash::Shell::GetInstance() | 147 bool isUserAddingRunning = ash::Shell::GetInstance() |
140 ->session_state_delegate() | 148 ->session_state_delegate() |
141 ->IsInSecondaryLoginScreen(); | 149 ->IsInSecondaryLoginScreen(); |
142 | 150 |
143 int container_id = | 151 int container_id = |
144 (!session_started || login_status == ash::user::LOGGED_IN_NONE || | 152 (!session_started || login_status == ash::user::LOGGED_IN_NONE || |
145 login_status == ash::user::LOGGED_IN_LOCKED || isUserAddingRunning) | 153 login_status == ash::user::LOGGED_IN_LOCKED || isUserAddingRunning) |
146 ? ash::kShellWindowId_LockSystemModalContainer | 154 ? ash::kShellWindowId_LockSystemModalContainer |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
218 chrome::NOTIFICATION_PROFILE_DESTROYED, | 226 chrome::NOTIFICATION_PROFILE_DESTROYED, |
219 content::NotificationService::AllSources()); | 227 content::NotificationService::AllSources()); |
220 | 228 |
221 AccessibilityManager* accessibility_manager = AccessibilityManager::Get(); | 229 AccessibilityManager* accessibility_manager = AccessibilityManager::Get(); |
222 CHECK(accessibility_manager); | 230 CHECK(accessibility_manager); |
223 accessibility_subscription_ = accessibility_manager->RegisterCallback( | 231 accessibility_subscription_ = accessibility_manager->RegisterCallback( |
224 base::Bind(&SystemTrayDelegateChromeOS::OnAccessibilityStatusChanged, | 232 base::Bind(&SystemTrayDelegateChromeOS::OnAccessibilityStatusChanged, |
225 base::Unretained(this))); | 233 base::Unretained(this))); |
226 | 234 |
227 user_manager::UserManager::Get()->AddSessionStateObserver(this); | 235 user_manager::UserManager::Get()->AddSessionStateObserver(this); |
236 shutdown_policy_observer_.reset( | |
237 new ShutdownPolicyObserver(CrosSettings::Get(), this)); | |
228 } | 238 } |
229 | 239 |
230 void SystemTrayDelegateChromeOS::Initialize() { | 240 void SystemTrayDelegateChromeOS::Initialize() { |
231 DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this); | 241 DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this); |
232 | 242 |
233 input_method::InputMethodManager::Get()->AddObserver(this); | 243 input_method::InputMethodManager::Get()->AddObserver(this); |
234 ui::ime::InputMethodMenuManager::GetInstance()->AddObserver(this); | 244 ui::ime::InputMethodMenuManager::GetInstance()->AddObserver(this); |
235 UpdateClockType(); | 245 UpdateClockType(); |
236 | 246 |
237 device::BluetoothAdapterFactory::GetAdapter( | 247 device::BluetoothAdapterFactory::GetAdapter( |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
584 if (show_intro) { | 594 if (show_intro) { |
585 base::Callback<void(bool)> on_accept = | 595 base::Callback<void(bool)> on_accept = |
586 base::Bind(&OnAcceptMultiprofilesIntro); | 596 base::Bind(&OnAcceptMultiprofilesIntro); |
587 ShowMultiprofilesIntroDialog(on_accept); | 597 ShowMultiprofilesIntroDialog(on_accept); |
588 } else { | 598 } else { |
589 UserAddingScreen::Get()->Start(); | 599 UserAddingScreen::Get()->Start(); |
590 } | 600 } |
591 } | 601 } |
592 } | 602 } |
593 | 603 |
604 void SystemTrayDelegateChromeOS::Restart() { | |
605 ash::Shell::GetInstance()->lock_state_controller()->RequestShutdown( | |
606 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.
| |
607 } | |
608 | |
594 void SystemTrayDelegateChromeOS::ShutDown() { | 609 void SystemTrayDelegateChromeOS::ShutDown() { |
595 ash::Shell::GetInstance()->lock_state_controller()->RequestShutdown( | 610 shutdown_policy_observer_->CheckIfRebootOnShutdown( |
596 ash::LockStateController::POWER_OFF); | 611 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.
| |
597 } | 612 } |
598 | 613 |
599 void SystemTrayDelegateChromeOS::SignOut() { | 614 void SystemTrayDelegateChromeOS::SignOut() { |
600 chrome::AttemptUserExit(); | 615 chrome::AttemptUserExit(); |
601 } | 616 } |
602 | 617 |
603 void SystemTrayDelegateChromeOS::RequestLockScreen() { | 618 void SystemTrayDelegateChromeOS::RequestLockScreen() { |
604 // TODO(antrim) : additional logging for crbug/173178 | 619 // TODO(antrim) : additional logging for crbug/173178 |
605 LOG(WARNING) << "Requesting screen lock from AshSystemTrayDelegate"; | 620 LOG(WARNING) << "Requesting screen lock from AshSystemTrayDelegate"; |
606 DBusThreadManager::Get()->GetSessionManagerClient()->RequestLockScreen(); | 621 DBusThreadManager::Get()->GetSessionManagerClient()->RequestLockScreen(); |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
827 void SystemTrayDelegateChromeOS::AddCustodianInfoTrayObserver( | 842 void SystemTrayDelegateChromeOS::AddCustodianInfoTrayObserver( |
828 ash::CustodianInfoTrayObserver* observer) { | 843 ash::CustodianInfoTrayObserver* observer) { |
829 custodian_info_changed_observers_.AddObserver(observer); | 844 custodian_info_changed_observers_.AddObserver(observer); |
830 } | 845 } |
831 | 846 |
832 void SystemTrayDelegateChromeOS::RemoveCustodianInfoTrayObserver( | 847 void SystemTrayDelegateChromeOS::RemoveCustodianInfoTrayObserver( |
833 ash::CustodianInfoTrayObserver* observer) { | 848 ash::CustodianInfoTrayObserver* observer) { |
834 custodian_info_changed_observers_.RemoveObserver(observer); | 849 custodian_info_changed_observers_.RemoveObserver(observer); |
835 } | 850 } |
836 | 851 |
852 void SystemTrayDelegateChromeOS::AddShutdownPolicyObserver( | |
853 ash::ShutdownPolicyObserver* observer) { | |
854 shutdown_policy_observers_.AddObserver(observer); | |
855 } | |
856 | |
857 void SystemTrayDelegateChromeOS::ShouldRebootOnShutdown( | |
858 const ash::RebootOnShutdownCallback& callback) { | |
859 shutdown_policy_observer_->CheckIfRebootOnShutdown(callback); | |
860 } | |
861 | |
862 void SystemTrayDelegateChromeOS::RemoveShutdownPolicyObserver( | |
863 ash::ShutdownPolicyObserver* observer) { | |
864 shutdown_policy_observers_.RemoveObserver(observer); | |
865 } | |
866 | |
837 void SystemTrayDelegateChromeOS::UserAddedToSession( | 867 void SystemTrayDelegateChromeOS::UserAddedToSession( |
838 const user_manager::User* active_user) { | 868 const user_manager::User* active_user) { |
839 } | 869 } |
840 | 870 |
841 void SystemTrayDelegateChromeOS::UserChangedChildStatus( | 871 void SystemTrayDelegateChromeOS::UserChangedChildStatus( |
842 user_manager::User* user) { | 872 user_manager::User* user) { |
843 Profile* user_profile = ProfileHelper::Get()->GetProfileByUser(user); | 873 Profile* user_profile = ProfileHelper::Get()->GetProfileByUser(user); |
844 | 874 |
845 // Returned user_profile might be NULL on restoring Users on browser start. | 875 // Returned user_profile might be NULL on restoring Users on browser start. |
846 // At some point profile is not yet fully initiated. | 876 // At some point profile is not yet fully initiated. |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1290 } | 1320 } |
1291 | 1321 |
1292 void SystemTrayDelegateChromeOS::OnAccessibilityStatusChanged( | 1322 void SystemTrayDelegateChromeOS::OnAccessibilityStatusChanged( |
1293 const AccessibilityStatusEventDetails& details) { | 1323 const AccessibilityStatusEventDetails& details) { |
1294 if (details.notification_type == ACCESSIBILITY_MANAGER_SHUTDOWN) | 1324 if (details.notification_type == ACCESSIBILITY_MANAGER_SHUTDOWN) |
1295 accessibility_subscription_.reset(); | 1325 accessibility_subscription_.reset(); |
1296 else | 1326 else |
1297 OnAccessibilityModeChanged(details.notify); | 1327 OnAccessibilityModeChanged(details.notify); |
1298 } | 1328 } |
1299 | 1329 |
1330 void SystemTrayDelegateChromeOS::OnShutdownPolicyChanged( | |
1331 bool reboot_on_shutdown) { | |
1332 // Notify all observers. | |
1333 FOR_EACH_OBSERVER(ash::ShutdownPolicyObserver, shutdown_policy_observers_, | |
1334 OnShutdownPolicyChanged(reboot_on_shutdown)); | |
1335 } | |
1336 | |
1300 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { | 1337 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { |
1301 return new SystemTrayDelegateChromeOS(); | 1338 return new SystemTrayDelegateChromeOS(); |
1302 } | 1339 } |
1303 | 1340 |
1304 } // namespace chromeos | 1341 } // namespace chromeos |
OLD | NEW |