| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <set> | 10 #include <set> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <utility> | 12 #include <utility> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "ash/common/ash_switches.h" | 15 #include "ash/common/ash_switches.h" |
| 16 #include "ash/common/login_status.h" | 16 #include "ash/common/login_status.h" |
| 17 #include "ash/common/session/session_state_delegate.h" | 17 #include "ash/common/session/session_state_delegate.h" |
| 18 #include "ash/common/session/session_state_observer.h" | 18 #include "ash/common/session/session_state_observer.h" |
| 19 #include "ash/common/shell_window_ids.h" | 19 #include "ash/common/shell_window_ids.h" |
| 20 #include "ash/common/system/chromeos/bluetooth/bluetooth_observer.h" |
| 20 #include "ash/common/system/chromeos/power/power_status.h" | 21 #include "ash/common/system/chromeos/power/power_status.h" |
| 22 #include "ash/common/system/chromeos/session/logout_button_observer.h" |
| 21 #include "ash/common/system/chromeos/shutdown_policy_observer.h" | 23 #include "ash/common/system/chromeos/shutdown_policy_observer.h" |
| 22 #include "ash/common/system/date/clock_observer.h" | 24 #include "ash/common/system/date/clock_observer.h" |
| 23 #include "ash/common/system/ime/ime_observer.h" | 25 #include "ash/common/system/ime/ime_observer.h" |
| 24 #include "ash/common/system/tray/system_tray_delegate.h" | 26 #include "ash/common/system/tray/system_tray_delegate.h" |
| 25 #include "ash/common/system/tray/wm_system_tray_notifier.h" | 27 #include "ash/common/system/tray/system_tray_notifier.h" |
| 26 #include "ash/common/system/tray_accessibility.h" | 28 #include "ash/common/system/tray_accessibility.h" |
| 27 #include "ash/common/system/update/update_observer.h" | 29 #include "ash/common/system/update/update_observer.h" |
| 28 #include "ash/common/system/user/user_observer.h" | 30 #include "ash/common/system/user/user_observer.h" |
| 29 #include "ash/common/system/volume_control_delegate.h" | 31 #include "ash/common/system/volume_control_delegate.h" |
| 30 #include "ash/common/wm_shell.h" | 32 #include "ash/common/wm_shell.h" |
| 31 #include "ash/desktop_background/desktop_background_controller.h" | 33 #include "ash/desktop_background/desktop_background_controller.h" |
| 32 #include "ash/shell.h" | 34 #include "ash/shell.h" |
| 33 #include "ash/shell_delegate.h" | 35 #include "ash/shell_delegate.h" |
| 34 #include "ash/system/chromeos/bluetooth/bluetooth_observer.h" | |
| 35 #include "ash/system/chromeos/session/logout_button_observer.h" | |
| 36 #include "ash/system/tray/system_tray.h" | 36 #include "ash/system/tray/system_tray.h" |
| 37 #include "ash/system/tray/system_tray_notifier.h" | |
| 38 #include "ash/wm/lock_state_controller.h" | 37 #include "ash/wm/lock_state_controller.h" |
| 39 #include "base/bind_helpers.h" | 38 #include "base/bind_helpers.h" |
| 40 #include "base/callback.h" | 39 #include "base/callback.h" |
| 41 #include "base/logging.h" | 40 #include "base/logging.h" |
| 42 #include "base/memory/ptr_util.h" | 41 #include "base/memory/ptr_util.h" |
| 43 #include "base/memory/weak_ptr.h" | 42 #include "base/memory/weak_ptr.h" |
| 44 #include "base/strings/stringprintf.h" | 43 #include "base/strings/stringprintf.h" |
| 45 #include "base/strings/utf_string_conversions.h" | 44 #include "base/strings/utf_string_conversions.h" |
| 46 #include "base/sys_info.h" | 45 #include "base/sys_info.h" |
| 47 #include "base/time/time.h" | 46 #include "base/time/time.h" |
| (...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 875 ash::Shell::GetInstance()->UpdateAfterLoginStatusChange( | 874 ash::Shell::GetInstance()->UpdateAfterLoginStatusChange( |
| 876 GetUserLoginStatus()); | 875 GetUserLoginStatus()); |
| 877 } | 876 } |
| 878 } | 877 } |
| 879 | 878 |
| 880 ash::SystemTray* SystemTrayDelegateChromeOS::GetPrimarySystemTray() { | 879 ash::SystemTray* SystemTrayDelegateChromeOS::GetPrimarySystemTray() { |
| 881 return ash::Shell::GetInstance()->GetPrimarySystemTray(); | 880 return ash::Shell::GetInstance()->GetPrimarySystemTray(); |
| 882 } | 881 } |
| 883 | 882 |
| 884 ash::SystemTrayNotifier* SystemTrayDelegateChromeOS::GetSystemTrayNotifier() { | 883 ash::SystemTrayNotifier* SystemTrayDelegateChromeOS::GetSystemTrayNotifier() { |
| 885 return ash::Shell::GetInstance()->system_tray_notifier(); | |
| 886 } | |
| 887 | |
| 888 ash::WmSystemTrayNotifier* | |
| 889 SystemTrayDelegateChromeOS::GetWmSystemTrayNotifier() { | |
| 890 return ash::WmShell::Get()->system_tray_notifier(); | 884 return ash::WmShell::Get()->system_tray_notifier(); |
| 891 } | 885 } |
| 892 | 886 |
| 893 void SystemTrayDelegateChromeOS::SetProfile(Profile* profile) { | 887 void SystemTrayDelegateChromeOS::SetProfile(Profile* profile) { |
| 894 // Stop observing the AppWindowRegistry of the current |user_profile_|. | 888 // Stop observing the AppWindowRegistry of the current |user_profile_|. |
| 895 StopObservingAppWindowRegistry(); | 889 StopObservingAppWindowRegistry(); |
| 896 | 890 |
| 897 // Stop observing custodian info changes of the current |user_profile_|. | 891 // Stop observing custodian info changes of the current |user_profile_|. |
| 898 StopObservingCustodianInfoChanges(); | 892 StopObservingCustodianInfoChanges(); |
| 899 | 893 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 956 bool SystemTrayDelegateChromeOS::GetShouldUse24HourClockForTesting() const { | 950 bool SystemTrayDelegateChromeOS::GetShouldUse24HourClockForTesting() const { |
| 957 return g_browser_process->platform_part() | 951 return g_browser_process->platform_part() |
| 958 ->GetSystemClock() | 952 ->GetSystemClock() |
| 959 ->ShouldUse24HourClock(); | 953 ->ShouldUse24HourClock(); |
| 960 } | 954 } |
| 961 | 955 |
| 962 void SystemTrayDelegateChromeOS::OnSystemClockChanged( | 956 void SystemTrayDelegateChromeOS::OnSystemClockChanged( |
| 963 system::SystemClock* system_clock) { | 957 system::SystemClock* system_clock) { |
| 964 const bool use_24_hour_clock = system_clock->ShouldUse24HourClock(); | 958 const bool use_24_hour_clock = system_clock->ShouldUse24HourClock(); |
| 965 clock_type_ = use_24_hour_clock ? base::k24HourClock : base::k12HourClock; | 959 clock_type_ = use_24_hour_clock ? base::k24HourClock : base::k12HourClock; |
| 966 GetWmSystemTrayNotifier()->NotifyDateFormatChanged(); | 960 GetSystemTrayNotifier()->NotifyDateFormatChanged(); |
| 967 } | 961 } |
| 968 | 962 |
| 969 void SystemTrayDelegateChromeOS::UpdateShowLogoutButtonInTray() { | 963 void SystemTrayDelegateChromeOS::UpdateShowLogoutButtonInTray() { |
| 970 GetSystemTrayNotifier()->NotifyShowLoginButtonChanged( | 964 GetSystemTrayNotifier()->NotifyShowLoginButtonChanged( |
| 971 user_pref_registrar_->prefs()->GetBoolean( | 965 user_pref_registrar_->prefs()->GetBoolean( |
| 972 prefs::kShowLogoutButtonInTray)); | 966 prefs::kShowLogoutButtonInTray)); |
| 973 } | 967 } |
| 974 | 968 |
| 975 void SystemTrayDelegateChromeOS::UpdateLogoutDialogDuration() { | 969 void SystemTrayDelegateChromeOS::UpdateLogoutDialogDuration() { |
| 976 const int duration_ms = | 970 const int duration_ms = |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1071 | 1065 |
| 1072 // content::NotificationObserver implementation. | 1066 // content::NotificationObserver implementation. |
| 1073 void SystemTrayDelegateChromeOS::Observe( | 1067 void SystemTrayDelegateChromeOS::Observe( |
| 1074 int type, | 1068 int type, |
| 1075 const content::NotificationSource& source, | 1069 const content::NotificationSource& source, |
| 1076 const content::NotificationDetails& details) { | 1070 const content::NotificationDetails& details) { |
| 1077 switch (type) { | 1071 switch (type) { |
| 1078 case chrome::NOTIFICATION_UPGRADE_RECOMMENDED: { | 1072 case chrome::NOTIFICATION_UPGRADE_RECOMMENDED: { |
| 1079 ash::UpdateInfo info; | 1073 ash::UpdateInfo info; |
| 1080 GetUpdateInfo(content::Source<UpgradeDetector>(source).ptr(), &info); | 1074 GetUpdateInfo(content::Source<UpgradeDetector>(source).ptr(), &info); |
| 1081 GetWmSystemTrayNotifier()->NotifyUpdateRecommended(info); | 1075 GetSystemTrayNotifier()->NotifyUpdateRecommended(info); |
| 1082 break; | 1076 break; |
| 1083 } | 1077 } |
| 1084 case chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED: { | 1078 case chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED: { |
| 1085 // This notification is also sent on login screen when user avatar | 1079 // This notification is also sent on login screen when user avatar |
| 1086 // is loaded from file. | 1080 // is loaded from file. |
| 1087 if (GetUserLoginStatus() != ash::LoginStatus::NOT_LOGGED_IN) { | 1081 if (GetUserLoginStatus() != ash::LoginStatus::NOT_LOGGED_IN) { |
| 1088 GetSystemTrayNotifier()->NotifyUserUpdate(); | 1082 GetSystemTrayNotifier()->NotifyUserUpdate(); |
| 1089 } | 1083 } |
| 1090 break; | 1084 break; |
| 1091 } | 1085 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1116 } | 1110 } |
| 1117 } | 1111 } |
| 1118 | 1112 |
| 1119 void SystemTrayDelegateChromeOS::OnLanguageRemapSearchKeyToChanged() { | 1113 void SystemTrayDelegateChromeOS::OnLanguageRemapSearchKeyToChanged() { |
| 1120 search_key_mapped_to_ = user_pref_registrar_->prefs()->GetInteger( | 1114 search_key_mapped_to_ = user_pref_registrar_->prefs()->GetInteger( |
| 1121 prefs::kLanguageRemapSearchKeyTo); | 1115 prefs::kLanguageRemapSearchKeyTo); |
| 1122 } | 1116 } |
| 1123 | 1117 |
| 1124 void SystemTrayDelegateChromeOS::OnAccessibilityModeChanged( | 1118 void SystemTrayDelegateChromeOS::OnAccessibilityModeChanged( |
| 1125 ash::AccessibilityNotificationVisibility notify) { | 1119 ash::AccessibilityNotificationVisibility notify) { |
| 1126 GetWmSystemTrayNotifier()->NotifyAccessibilityModeChanged(notify); | 1120 GetSystemTrayNotifier()->NotifyAccessibilityModeChanged(notify); |
| 1127 } | 1121 } |
| 1128 | 1122 |
| 1129 void SystemTrayDelegateChromeOS::UpdatePerformanceTracing() { | 1123 void SystemTrayDelegateChromeOS::UpdatePerformanceTracing() { |
| 1130 if (!user_pref_registrar_) | 1124 if (!user_pref_registrar_) |
| 1131 return; | 1125 return; |
| 1132 bool value = user_pref_registrar_->prefs()->GetBoolean( | 1126 bool value = user_pref_registrar_->prefs()->GetBoolean( |
| 1133 prefs::kPerformanceTracingEnabled); | 1127 prefs::kPerformanceTracingEnabled); |
| 1134 GetWmSystemTrayNotifier()->NotifyTracingModeChanged(value); | 1128 GetSystemTrayNotifier()->NotifyTracingModeChanged(value); |
| 1135 } | 1129 } |
| 1136 | 1130 |
| 1137 // Overridden from InputMethodManager::Observer. | 1131 // Overridden from InputMethodManager::Observer. |
| 1138 void SystemTrayDelegateChromeOS::InputMethodChanged( | 1132 void SystemTrayDelegateChromeOS::InputMethodChanged( |
| 1139 input_method::InputMethodManager* manager, | 1133 input_method::InputMethodManager* manager, |
| 1140 Profile* /* profile */, | 1134 Profile* /* profile */, |
| 1141 bool show_message) { | 1135 bool show_message) { |
| 1142 GetWmSystemTrayNotifier()->NotifyRefreshIME(); | 1136 GetSystemTrayNotifier()->NotifyRefreshIME(); |
| 1143 } | 1137 } |
| 1144 | 1138 |
| 1145 // Overridden from InputMethodMenuManager::Observer. | 1139 // Overridden from InputMethodMenuManager::Observer. |
| 1146 void SystemTrayDelegateChromeOS::InputMethodMenuItemChanged( | 1140 void SystemTrayDelegateChromeOS::InputMethodMenuItemChanged( |
| 1147 ui::ime::InputMethodMenuManager* manager) { | 1141 ui::ime::InputMethodMenuManager* manager) { |
| 1148 GetWmSystemTrayNotifier()->NotifyRefreshIME(); | 1142 GetSystemTrayNotifier()->NotifyRefreshIME(); |
| 1149 } | 1143 } |
| 1150 | 1144 |
| 1151 // Overridden from CrasAudioHandler::AudioObserver. | 1145 // Overridden from CrasAudioHandler::AudioObserver. |
| 1152 void SystemTrayDelegateChromeOS::OnOutputNodeVolumeChanged(uint64_t node_id, | 1146 void SystemTrayDelegateChromeOS::OnOutputNodeVolumeChanged(uint64_t node_id, |
| 1153 int volume) { | 1147 int volume) { |
| 1154 GetWmSystemTrayNotifier()->NotifyAudioOutputVolumeChanged(node_id, volume); | 1148 GetSystemTrayNotifier()->NotifyAudioOutputVolumeChanged(node_id, volume); |
| 1155 } | 1149 } |
| 1156 | 1150 |
| 1157 void SystemTrayDelegateChromeOS::OnOutputMuteChanged(bool mute_on, | 1151 void SystemTrayDelegateChromeOS::OnOutputMuteChanged(bool mute_on, |
| 1158 bool system_adjust) { | 1152 bool system_adjust) { |
| 1159 GetWmSystemTrayNotifier()->NotifyAudioOutputMuteChanged(mute_on, | 1153 GetSystemTrayNotifier()->NotifyAudioOutputMuteChanged(mute_on, system_adjust); |
| 1160 system_adjust); | |
| 1161 } | 1154 } |
| 1162 | 1155 |
| 1163 void SystemTrayDelegateChromeOS::OnInputNodeGainChanged(uint64_t /* node_id */, | 1156 void SystemTrayDelegateChromeOS::OnInputNodeGainChanged(uint64_t /* node_id */, |
| 1164 int /* gain */) { | 1157 int /* gain */) { |
| 1165 } | 1158 } |
| 1166 | 1159 |
| 1167 void SystemTrayDelegateChromeOS::OnInputMuteChanged(bool /* mute_on */) { | 1160 void SystemTrayDelegateChromeOS::OnInputMuteChanged(bool /* mute_on */) { |
| 1168 } | 1161 } |
| 1169 | 1162 |
| 1170 void SystemTrayDelegateChromeOS::OnAudioNodesChanged() { | 1163 void SystemTrayDelegateChromeOS::OnAudioNodesChanged() { |
| 1171 GetWmSystemTrayNotifier()->NotifyAudioNodesChanged(); | 1164 GetSystemTrayNotifier()->NotifyAudioNodesChanged(); |
| 1172 } | 1165 } |
| 1173 | 1166 |
| 1174 void SystemTrayDelegateChromeOS::OnActiveOutputNodeChanged() { | 1167 void SystemTrayDelegateChromeOS::OnActiveOutputNodeChanged() { |
| 1175 GetWmSystemTrayNotifier()->NotifyAudioActiveOutputNodeChanged(); | 1168 GetSystemTrayNotifier()->NotifyAudioActiveOutputNodeChanged(); |
| 1176 } | 1169 } |
| 1177 | 1170 |
| 1178 void SystemTrayDelegateChromeOS::OnActiveInputNodeChanged() { | 1171 void SystemTrayDelegateChromeOS::OnActiveInputNodeChanged() { |
| 1179 GetWmSystemTrayNotifier()->NotifyAudioActiveInputNodeChanged(); | 1172 GetSystemTrayNotifier()->NotifyAudioActiveInputNodeChanged(); |
| 1180 } | 1173 } |
| 1181 | 1174 |
| 1182 // Overridden from BluetoothAdapter::Observer. | 1175 // Overridden from BluetoothAdapter::Observer. |
| 1183 void SystemTrayDelegateChromeOS::AdapterPresentChanged( | 1176 void SystemTrayDelegateChromeOS::AdapterPresentChanged( |
| 1184 device::BluetoothAdapter* adapter, | 1177 device::BluetoothAdapter* adapter, |
| 1185 bool present) { | 1178 bool present) { |
| 1186 GetSystemTrayNotifier()->NotifyRefreshBluetooth(); | 1179 GetSystemTrayNotifier()->NotifyRefreshBluetooth(); |
| 1187 } | 1180 } |
| 1188 | 1181 |
| 1189 void SystemTrayDelegateChromeOS::AdapterPoweredChanged( | 1182 void SystemTrayDelegateChromeOS::AdapterPoweredChanged( |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1283 } | 1276 } |
| 1284 | 1277 |
| 1285 void SystemTrayDelegateChromeOS::OnShutdownPolicyChanged( | 1278 void SystemTrayDelegateChromeOS::OnShutdownPolicyChanged( |
| 1286 bool reboot_on_shutdown) { | 1279 bool reboot_on_shutdown) { |
| 1287 // Notify all observers. | 1280 // Notify all observers. |
| 1288 FOR_EACH_OBSERVER(ash::ShutdownPolicyObserver, shutdown_policy_observers_, | 1281 FOR_EACH_OBSERVER(ash::ShutdownPolicyObserver, shutdown_policy_observers_, |
| 1289 OnShutdownPolicyChanged(reboot_on_shutdown)); | 1282 OnShutdownPolicyChanged(reboot_on_shutdown)); |
| 1290 } | 1283 } |
| 1291 | 1284 |
| 1292 void SystemTrayDelegateChromeOS::ImeMenuActivationChanged(bool is_active) { | 1285 void SystemTrayDelegateChromeOS::ImeMenuActivationChanged(bool is_active) { |
| 1293 GetWmSystemTrayNotifier()->NotifyRefreshIMEMenu(is_active); | 1286 GetSystemTrayNotifier()->NotifyRefreshIMEMenu(is_active); |
| 1294 } | 1287 } |
| 1295 | 1288 |
| 1296 void SystemTrayDelegateChromeOS::ImeMenuListChanged() {} | 1289 void SystemTrayDelegateChromeOS::ImeMenuListChanged() {} |
| 1297 | 1290 |
| 1298 void SystemTrayDelegateChromeOS::ImeMenuItemsChanged( | 1291 void SystemTrayDelegateChromeOS::ImeMenuItemsChanged( |
| 1299 const std::string& engine_id, | 1292 const std::string& engine_id, |
| 1300 const std::vector<input_method::InputMethodManager::MenuItem>& items) {} | 1293 const std::vector<input_method::InputMethodManager::MenuItem>& items) {} |
| 1301 | 1294 |
| 1302 const base::string16 | 1295 const base::string16 |
| 1303 SystemTrayDelegateChromeOS::GetLegacySupervisedUserMessage() const { | 1296 SystemTrayDelegateChromeOS::GetLegacySupervisedUserMessage() const { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1332 LOG(WARNING) << "SystemTrayDelegateChromeOS::GetChildUserMessage call while " | 1325 LOG(WARNING) << "SystemTrayDelegateChromeOS::GetChildUserMessage call while " |
| 1333 << "ENABLE_SUPERVISED_USERS undefined."; | 1326 << "ENABLE_SUPERVISED_USERS undefined."; |
| 1334 return base::string16(); | 1327 return base::string16(); |
| 1335 } | 1328 } |
| 1336 | 1329 |
| 1337 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { | 1330 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { |
| 1338 return new SystemTrayDelegateChromeOS(); | 1331 return new SystemTrayDelegateChromeOS(); |
| 1339 } | 1332 } |
| 1340 | 1333 |
| 1341 } // namespace chromeos | 1334 } // namespace chromeos |
| OLD | NEW |