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