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 3 // found in the LICENSE file. 4 5 #include "ash/system/tray/system_tray_notifier.h" 6 7 #if defined(OS_CHROMEOS) 8 #include "ash/system/chromeos/network/network_state_notifier.h" 9 #endif 10 11 namespace ash { 12 13 SystemTrayNotifier::SystemTrayNotifier() { 14 #if defined(OS_CHROMEOS) 15 network_state_notifier_.reset(new NetworkStateNotifier()); 16 #endif 17 } 18 19 SystemTrayNotifier::~SystemTrayNotifier() { 20 } 21 22 void SystemTrayNotifier::AddAccessibilityObserver( 23 AccessibilityObserver* observer) { 24 accessibility_observers_.AddObserver(observer); 25 } 26 27 void SystemTrayNotifier::RemoveAccessibilityObserver( 28 AccessibilityObserver* observer) { 29 accessibility_observers_.RemoveObserver(observer); 30 } 31 32 void SystemTrayNotifier::AddBluetoothObserver(BluetoothObserver* observer) { 33 bluetooth_observers_.AddObserver(observer); 34 } 35 36 void SystemTrayNotifier::RemoveBluetoothObserver(BluetoothObserver* observer) { 37 bluetooth_observers_.RemoveObserver(observer); 38 } 39 40 void SystemTrayNotifier::AddBrightnessObserver(BrightnessObserver* observer) { 41 brightness_observers_.AddObserver(observer); 42 } 43 44 void SystemTrayNotifier::RemoveBrightnessObserver( 45 BrightnessObserver* observer) { 46 brightness_observers_.RemoveObserver(observer); 47 } 48 49 void SystemTrayNotifier::AddCapsLockObserver(CapsLockObserver* observer) { 50 caps_lock_observers_.AddObserver(observer); 51 } 52 53 void SystemTrayNotifier::RemoveCapsLockObserver(CapsLockObserver* observer) { 54 caps_lock_observers_.RemoveObserver(observer); 55 } 56 57 void SystemTrayNotifier::AddClockObserver(ClockObserver* observer) { 58 clock_observers_.AddObserver(observer); 59 } 60 61 void SystemTrayNotifier::RemoveClockObserver(ClockObserver* observer) { 62 clock_observers_.RemoveObserver(observer); 63 } 64 65 void SystemTrayNotifier::AddDriveObserver(DriveObserver* observer) { 66 drive_observers_.AddObserver(observer); 67 } 68 69 void SystemTrayNotifier::RemoveDriveObserver(DriveObserver* observer) { 70 drive_observers_.RemoveObserver(observer); 71 } 72 73 void SystemTrayNotifier::AddIMEObserver(IMEObserver* observer) { 74 ime_observers_.AddObserver(observer); 75 } 76 77 void SystemTrayNotifier::RemoveIMEObserver(IMEObserver* observer) { 78 ime_observers_.RemoveObserver(observer); 79 } 80 81 void SystemTrayNotifier::AddLocaleObserver(LocaleObserver* observer) { 82 locale_observers_.AddObserver(observer); 83 } 84 85 void SystemTrayNotifier::RemoveLocaleObserver(LocaleObserver* observer) { 86 locale_observers_.RemoveObserver(observer); 87 } 88 89 void SystemTrayNotifier::AddLogoutButtonObserver( 90 LogoutButtonObserver* observer) { 91 logout_button_observers_.AddObserver(observer); 92 } 93 94 void SystemTrayNotifier::RemoveLogoutButtonObserver( 95 LogoutButtonObserver* observer) { 96 logout_button_observers_.RemoveObserver(observer); 97 } 98 99 void SystemTrayNotifier::AddSessionLengthLimitObserver( 100 SessionLengthLimitObserver* observer) { 101 session_length_limit_observers_.AddObserver(observer); 102 } 103 104 void SystemTrayNotifier::RemoveSessionLengthLimitObserver( 105 SessionLengthLimitObserver* observer) { 106 session_length_limit_observers_.RemoveObserver(observer); 107 } 108 109 void SystemTrayNotifier::AddTracingObserver(TracingObserver* observer) { 110 tracing_observers_.AddObserver(observer); 111 } 112 113 void SystemTrayNotifier::RemoveTracingObserver(TracingObserver* observer) { 114 tracing_observers_.RemoveObserver(observer); 115 } 116 117 void SystemTrayNotifier::AddUpdateObserver(UpdateObserver* observer) { 118 update_observers_.AddObserver(observer); 119 } 120 121 void SystemTrayNotifier::RemoveUpdateObserver(UpdateObserver* observer) { 122 update_observers_.RemoveObserver(observer); 123 } 124 125 void SystemTrayNotifier::AddUserObserver(UserObserver* observer) { 126 user_observers_.AddObserver(observer); 127 } 128 129 void SystemTrayNotifier::RemoveUserObserver(UserObserver* observer) { 130 user_observers_.RemoveObserver(observer); 131 } 132 133 #if defined(OS_CHROMEOS) 134 135 void SystemTrayNotifier::AddNetworkObserver(NetworkObserver* observer) { 136 network_observers_.AddObserver(observer); 137 } 138 139 void SystemTrayNotifier::RemoveNetworkObserver(NetworkObserver* observer) { 140 network_observers_.RemoveObserver(observer); 141 } 142 143 void SystemTrayNotifier::AddSmsObserver(SmsObserver* observer) { 144 sms_observers_.AddObserver(observer); 145 } 146 147 void SystemTrayNotifier::RemoveSmsObserver(SmsObserver* observer) { 148 sms_observers_.RemoveObserver(observer); 149 } 150 151 void SystemTrayNotifier::AddEnterpriseDomainObserver( 152 EnterpriseDomainObserver* observer) { 153 enterprise_domain_observers_.AddObserver(observer); 154 } 155 156 void SystemTrayNotifier::RemoveEnterpriseDomainObserver( 157 EnterpriseDomainObserver* observer) { 158 enterprise_domain_observers_.RemoveObserver(observer); 159 } 160 161 void SystemTrayNotifier::AddScreenCaptureObserver( 162 ScreenCaptureObserver* observer) { 163 screen_capture_observers_.AddObserver(observer); 164 } 165 166 void SystemTrayNotifier::RemoveScreenCaptureObserver( 167 ScreenCaptureObserver* observer) { 168 screen_capture_observers_.RemoveObserver(observer); 169 } 170 171 void SystemTrayNotifier::AddScreenShareObserver( 172 ScreenShareObserver* observer) { 173 screen_share_observers_.AddObserver(observer); 174 } 175 176 void SystemTrayNotifier::RemoveScreenShareObserver( 177 ScreenShareObserver* observer) { 178 screen_share_observers_.RemoveObserver(observer); 179 } 180 #endif 181 182 void SystemTrayNotifier::NotifyAccessibilityModeChanged( 183 AccessibilityNotificationVisibility notify) { 184 FOR_EACH_OBSERVER( 185 AccessibilityObserver, 186 accessibility_observers_, 187 OnAccessibilityModeChanged(notify)); 188 } 189 190 void SystemTrayNotifier::NotifyTracingModeChanged(bool value) { 191 FOR_EACH_OBSERVER( 192 TracingObserver, 193 tracing_observers_, 194 OnTracingModeChanged(value)); 195 } 196 197 void SystemTrayNotifier::NotifyRefreshBluetooth() { 198 FOR_EACH_OBSERVER(BluetoothObserver, 199 bluetooth_observers_, 200 OnBluetoothRefresh()); 201 } 202 203 void SystemTrayNotifier::NotifyBluetoothDiscoveringChanged() { 204 FOR_EACH_OBSERVER(BluetoothObserver, 205 bluetooth_observers_, 206 OnBluetoothDiscoveringChanged()); 207 } 208 209 void SystemTrayNotifier::NotifyBrightnessChanged(double level, 210 bool user_initiated) { 211 FOR_EACH_OBSERVER( 212 BrightnessObserver, 213 brightness_observers_, 214 OnBrightnessChanged(level, user_initiated)); 215 } 216 217 void SystemTrayNotifier::NotifyCapsLockChanged( 218 bool enabled, 219 bool search_mapped_to_caps_lock) { 220 FOR_EACH_OBSERVER(CapsLockObserver, 221 caps_lock_observers_, 222 OnCapsLockChanged(enabled, search_mapped_to_caps_lock)); 223 } 224 225 void SystemTrayNotifier::NotifyRefreshClock() { 226 FOR_EACH_OBSERVER(ClockObserver, clock_observers_, Refresh()); 227 } 228 229 void SystemTrayNotifier::NotifyDateFormatChanged() { 230 FOR_EACH_OBSERVER(ClockObserver, 231 clock_observers_, 232 OnDateFormatChanged()); 233 } 234 235 void SystemTrayNotifier::NotifySystemClockTimeUpdated() { 236 FOR_EACH_OBSERVER(ClockObserver, 237 clock_observers_, 238 OnSystemClockTimeUpdated()); 239 } 240 241 void SystemTrayNotifier::NotifyDriveJobUpdated( 242 const DriveOperationStatus& status) { 243 FOR_EACH_OBSERVER(DriveObserver, 244 drive_observers_, 245 OnDriveJobUpdated(status)); 246 } 247 248 void SystemTrayNotifier::NotifyRefreshIME(bool show_message) { 249 FOR_EACH_OBSERVER(IMEObserver, 250 ime_observers_, 251 OnIMERefresh(show_message)); 252 } 253 254 void SystemTrayNotifier::NotifyShowLoginButtonChanged(bool show_login_button) { 255 FOR_EACH_OBSERVER(LogoutButtonObserver, 256 logout_button_observers_, 257 OnShowLogoutButtonInTrayChanged(show_login_button)); 258 } 259 260 void SystemTrayNotifier::NotifyLocaleChanged( 261 LocaleObserver::Delegate* delegate, 262 const std::string& cur_locale, 263 const std::string& from_locale, 264 const std::string& to_locale) { 265 FOR_EACH_OBSERVER( 266 LocaleObserver, 267 locale_observers_, 268 OnLocaleChanged(delegate, cur_locale, from_locale, to_locale)); 269 } 270 271 void SystemTrayNotifier::NotifySessionStartTimeChanged() { 272 FOR_EACH_OBSERVER(SessionLengthLimitObserver, 273 session_length_limit_observers_, 274 OnSessionStartTimeChanged()); 275 } 276 277 void SystemTrayNotifier::NotifySessionLengthLimitChanged() { 278 FOR_EACH_OBSERVER(SessionLengthLimitObserver, 279 session_length_limit_observers_, 280 OnSessionLengthLimitChanged()); 281 } 282 283 void SystemTrayNotifier::NotifyUpdateRecommended( 284 UpdateObserver::UpdateSeverity severity) { 285 FOR_EACH_OBSERVER(UpdateObserver, 286 update_observers_, 287 OnUpdateRecommended(severity)); 288 } 289 290 void SystemTrayNotifier::NotifyUserUpdate() { 291 FOR_EACH_OBSERVER(UserObserver, 292 user_observers_, 293 OnUserUpdate()); 294 } 295 296 #if defined(OS_CHROMEOS) 297 298 void SystemTrayNotifier::NotifySetNetworkMessage( 299 NetworkTrayDelegate* delegate, 300 NetworkObserver::MessageType message_type, 301 NetworkObserver::NetworkType network_type, 302 const base::string16& title, 303 const base::string16& message, 304 const std::vector<base::string16>& links) { 305 FOR_EACH_OBSERVER(NetworkObserver, 306 network_observers_, 307 SetNetworkMessage( 308 delegate, 309 message_type, 310 network_type, 311 title, 312 message, 313 links)); 314 } 315 316 void SystemTrayNotifier::NotifyClearNetworkMessage( 317 NetworkObserver::MessageType message_type) { 318 FOR_EACH_OBSERVER(NetworkObserver, 319 network_observers_, 320 ClearNetworkMessage(message_type)); 321 } 322 323 void SystemTrayNotifier::NotifyRequestToggleWifi() { 324 FOR_EACH_OBSERVER(NetworkObserver, 325 network_observers_, 326 RequestToggleWifi()); 327 } 328 329 void SystemTrayNotifier::NotifyAddSmsMessage( 330 const base::DictionaryValue& message) { 331 FOR_EACH_OBSERVER(SmsObserver, sms_observers_, AddMessage(message)); 332 } 333 334 void SystemTrayNotifier::NotifyEnterpriseDomainChanged() { 335 FOR_EACH_OBSERVER(EnterpriseDomainObserver, enterprise_domain_observers_, 336 OnEnterpriseDomainChanged()); 337 } 338 339 void SystemTrayNotifier::NotifyScreenCaptureStart( 340 const base::Closure& stop_callback, 341 const base::string16& sharing_app_name) { 342 FOR_EACH_OBSERVER(ScreenCaptureObserver, screen_capture_observers_, 343 OnScreenCaptureStart(stop_callback, sharing_app_name)); 344 } 345 346 void SystemTrayNotifier::NotifyScreenCaptureStop() { 347 FOR_EACH_OBSERVER(ScreenCaptureObserver, screen_capture_observers_, 348 OnScreenCaptureStop()); 349 } 350 351 void SystemTrayNotifier::NotifyScreenShareStart( 352 const base::Closure& stop_callback, 353 const base::string16& helper_name) { 354 FOR_EACH_OBSERVER(ScreenShareObserver, screen_share_observers_, 355 OnScreenShareStart(stop_callback, helper_name)); 356 } 357 358 void SystemTrayNotifier::NotifyScreenShareStop() { 359 FOR_EACH_OBSERVER(ScreenShareObserver, screen_share_observers_, 360 OnScreenShareStop()); 361 } 362 363 #endif // OS_CHROMEOS 364 365 } // namespace ash 366