Home | History | Annotate | Download | only in tray
      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::AddAudioObserver(AudioObserver* observer) {
     33   audio_observers_.AddObserver(observer);
     34 }
     35 
     36 void SystemTrayNotifier::RemoveAudioObserver(AudioObserver* observer) {
     37   audio_observers_.RemoveObserver(observer);
     38 }
     39 
     40 void SystemTrayNotifier::AddBluetoothObserver(BluetoothObserver* observer) {
     41   bluetooth_observers_.AddObserver(observer);
     42 }
     43 
     44 void SystemTrayNotifier::RemoveBluetoothObserver(BluetoothObserver* observer) {
     45   bluetooth_observers_.RemoveObserver(observer);
     46 }
     47 
     48 void SystemTrayNotifier::AddClockObserver(ClockObserver* observer) {
     49   clock_observers_.AddObserver(observer);
     50 }
     51 
     52 void SystemTrayNotifier::RemoveClockObserver(ClockObserver* observer) {
     53   clock_observers_.RemoveObserver(observer);
     54 }
     55 
     56 void SystemTrayNotifier::AddDriveObserver(DriveObserver* observer) {
     57   drive_observers_.AddObserver(observer);
     58 }
     59 
     60 void SystemTrayNotifier::RemoveDriveObserver(DriveObserver* observer) {
     61   drive_observers_.RemoveObserver(observer);
     62 }
     63 
     64 void SystemTrayNotifier::AddIMEObserver(IMEObserver* observer) {
     65   ime_observers_.AddObserver(observer);
     66 }
     67 
     68 void SystemTrayNotifier::RemoveIMEObserver(IMEObserver* observer) {
     69   ime_observers_.RemoveObserver(observer);
     70 }
     71 
     72 void SystemTrayNotifier::AddLocaleObserver(LocaleObserver* observer) {
     73   locale_observers_.AddObserver(observer);
     74 }
     75 
     76 void SystemTrayNotifier::RemoveLocaleObserver(LocaleObserver* observer) {
     77   locale_observers_.RemoveObserver(observer);
     78 }
     79 
     80 void SystemTrayNotifier::AddTracingObserver(TracingObserver* observer) {
     81   tracing_observers_.AddObserver(observer);
     82 }
     83 
     84 void SystemTrayNotifier::RemoveTracingObserver(TracingObserver* observer) {
     85   tracing_observers_.RemoveObserver(observer);
     86 }
     87 
     88 void SystemTrayNotifier::AddUpdateObserver(UpdateObserver* observer) {
     89   update_observers_.AddObserver(observer);
     90 }
     91 
     92 void SystemTrayNotifier::RemoveUpdateObserver(UpdateObserver* observer) {
     93   update_observers_.RemoveObserver(observer);
     94 }
     95 
     96 void SystemTrayNotifier::AddUserObserver(UserObserver* observer) {
     97   user_observers_.AddObserver(observer);
     98 }
     99 
    100 void SystemTrayNotifier::RemoveUserObserver(UserObserver* observer) {
    101   user_observers_.RemoveObserver(observer);
    102 }
    103 
    104 #if defined(OS_CHROMEOS)
    105 
    106 void SystemTrayNotifier::AddLogoutButtonObserver(
    107     LogoutButtonObserver* observer) {
    108   logout_button_observers_.AddObserver(observer);
    109 }
    110 
    111 void SystemTrayNotifier::RemoveLogoutButtonObserver(
    112     LogoutButtonObserver* observer) {
    113   logout_button_observers_.RemoveObserver(observer);
    114 }
    115 
    116 void SystemTrayNotifier::AddSessionLengthLimitObserver(
    117     SessionLengthLimitObserver* observer) {
    118   session_length_limit_observers_.AddObserver(observer);
    119 }
    120 
    121 void SystemTrayNotifier::RemoveSessionLengthLimitObserver(
    122     SessionLengthLimitObserver* observer) {
    123   session_length_limit_observers_.RemoveObserver(observer);
    124 }
    125 
    126 void SystemTrayNotifier::AddNetworkObserver(NetworkObserver* observer) {
    127   network_observers_.AddObserver(observer);
    128 }
    129 
    130 void SystemTrayNotifier::RemoveNetworkObserver(NetworkObserver* observer) {
    131   network_observers_.RemoveObserver(observer);
    132 }
    133 
    134 void SystemTrayNotifier::AddNetworkPortalDetectorObserver(
    135     NetworkPortalDetectorObserver* observer) {
    136   network_portal_detector_observers_.AddObserver(observer);
    137 }
    138 
    139 void SystemTrayNotifier::RemoveNetworkPortalDetectorObserver(
    140     NetworkPortalDetectorObserver* observer) {
    141   network_portal_detector_observers_.RemoveObserver(observer);
    142 }
    143 
    144 void SystemTrayNotifier::AddEnterpriseDomainObserver(
    145     EnterpriseDomainObserver* observer) {
    146   enterprise_domain_observers_.AddObserver(observer);
    147 }
    148 
    149 void SystemTrayNotifier::RemoveEnterpriseDomainObserver(
    150     EnterpriseDomainObserver* observer) {
    151   enterprise_domain_observers_.RemoveObserver(observer);
    152 }
    153 
    154 void SystemTrayNotifier::AddMediaCaptureObserver(
    155     MediaCaptureObserver* observer) {
    156   media_capture_observers_.AddObserver(observer);
    157 }
    158 
    159 void SystemTrayNotifier::RemoveMediaCaptureObserver(
    160     MediaCaptureObserver* observer) {
    161   media_capture_observers_.RemoveObserver(observer);
    162 }
    163 
    164 void SystemTrayNotifier::AddScreenCaptureObserver(
    165     ScreenCaptureObserver* observer) {
    166   screen_capture_observers_.AddObserver(observer);
    167 }
    168 
    169 void SystemTrayNotifier::RemoveScreenCaptureObserver(
    170     ScreenCaptureObserver* observer) {
    171   screen_capture_observers_.RemoveObserver(observer);
    172 }
    173 
    174 void SystemTrayNotifier::AddScreenShareObserver(
    175     ScreenShareObserver* observer) {
    176   screen_share_observers_.AddObserver(observer);
    177 }
    178 
    179 void SystemTrayNotifier::RemoveScreenShareObserver(
    180     ScreenShareObserver* observer) {
    181   screen_share_observers_.RemoveObserver(observer);
    182 }
    183 
    184 void SystemTrayNotifier::AddLastWindowClosedObserver(
    185     LastWindowClosedObserver* observer) {
    186   last_window_closed_observers_.AddObserver(observer);
    187 }
    188 
    189 void SystemTrayNotifier::RemoveLastWindowClosedObserver(
    190     LastWindowClosedObserver* observer) {
    191   last_window_closed_observers_.RemoveObserver(observer);
    192 }
    193 #endif
    194 
    195 void SystemTrayNotifier::NotifyAccessibilityModeChanged(
    196     AccessibilityNotificationVisibility notify) {
    197   FOR_EACH_OBSERVER(
    198       AccessibilityObserver,
    199       accessibility_observers_,
    200       OnAccessibilityModeChanged(notify));
    201 }
    202 
    203 void SystemTrayNotifier::NotifyAudioOutputVolumeChanged() {
    204   FOR_EACH_OBSERVER(
    205       AudioObserver,
    206       audio_observers_,
    207       OnOutputVolumeChanged());
    208 }
    209 
    210 void SystemTrayNotifier::NotifyAudioOutputMuteChanged() {
    211   FOR_EACH_OBSERVER(
    212       AudioObserver,
    213       audio_observers_,
    214       OnOutputMuteChanged());
    215 }
    216 
    217 void SystemTrayNotifier::NotifyAudioNodesChanged() {
    218   FOR_EACH_OBSERVER(
    219       AudioObserver,
    220       audio_observers_,
    221       OnAudioNodesChanged());
    222 }
    223 
    224 void SystemTrayNotifier::NotifyAudioActiveOutputNodeChanged() {
    225   FOR_EACH_OBSERVER(
    226       AudioObserver,
    227       audio_observers_,
    228       OnActiveOutputNodeChanged());
    229 }
    230 
    231 void SystemTrayNotifier::NotifyAudioActiveInputNodeChanged() {
    232   FOR_EACH_OBSERVER(
    233       AudioObserver,
    234       audio_observers_,
    235       OnActiveInputNodeChanged());
    236 }
    237 
    238 void SystemTrayNotifier::NotifyTracingModeChanged(bool value) {
    239   FOR_EACH_OBSERVER(
    240       TracingObserver,
    241       tracing_observers_,
    242       OnTracingModeChanged(value));
    243 }
    244 
    245 void SystemTrayNotifier::NotifyRefreshBluetooth() {
    246   FOR_EACH_OBSERVER(BluetoothObserver,
    247                     bluetooth_observers_,
    248                     OnBluetoothRefresh());
    249 }
    250 
    251 void SystemTrayNotifier::NotifyBluetoothDiscoveringChanged() {
    252   FOR_EACH_OBSERVER(BluetoothObserver,
    253                     bluetooth_observers_,
    254                     OnBluetoothDiscoveringChanged());
    255 }
    256 
    257 void SystemTrayNotifier::NotifyRefreshClock() {
    258   FOR_EACH_OBSERVER(ClockObserver, clock_observers_, Refresh());
    259 }
    260 
    261 void SystemTrayNotifier::NotifyDateFormatChanged() {
    262   FOR_EACH_OBSERVER(ClockObserver,
    263                     clock_observers_,
    264                     OnDateFormatChanged());
    265 }
    266 
    267 void SystemTrayNotifier::NotifySystemClockTimeUpdated() {
    268   FOR_EACH_OBSERVER(ClockObserver,
    269                     clock_observers_,
    270                     OnSystemClockTimeUpdated());
    271 }
    272 
    273 void SystemTrayNotifier::NotifySystemClockCanSetTimeChanged(bool can_set_time) {
    274   FOR_EACH_OBSERVER(ClockObserver,
    275                     clock_observers_,
    276                     OnSystemClockCanSetTimeChanged(can_set_time));
    277 }
    278 
    279 void SystemTrayNotifier::NotifyDriveJobUpdated(
    280     const DriveOperationStatus& status) {
    281   FOR_EACH_OBSERVER(DriveObserver,
    282                     drive_observers_,
    283                     OnDriveJobUpdated(status));
    284 }
    285 
    286 void SystemTrayNotifier::NotifyRefreshIME() {
    287   FOR_EACH_OBSERVER(IMEObserver,
    288                     ime_observers_,
    289                     OnIMERefresh());
    290 }
    291 
    292 void SystemTrayNotifier::NotifyLocaleChanged(
    293     LocaleObserver::Delegate* delegate,
    294     const std::string& cur_locale,
    295     const std::string& from_locale,
    296     const std::string& to_locale) {
    297   FOR_EACH_OBSERVER(
    298       LocaleObserver,
    299       locale_observers_,
    300       OnLocaleChanged(delegate, cur_locale, from_locale, to_locale));
    301 }
    302 
    303 void SystemTrayNotifier::NotifyUpdateRecommended(
    304     UpdateObserver::UpdateSeverity severity) {
    305   FOR_EACH_OBSERVER(UpdateObserver,
    306                     update_observers_,
    307                     OnUpdateRecommended(severity));
    308 }
    309 
    310 void SystemTrayNotifier::NotifyUserUpdate() {
    311   FOR_EACH_OBSERVER(UserObserver,
    312                     user_observers_,
    313                     OnUserUpdate());
    314 }
    315 
    316 void SystemTrayNotifier::NotifyUserAddedToSession() {
    317   FOR_EACH_OBSERVER(UserObserver,
    318                     user_observers_,
    319                     OnUserAddedToSession());
    320 }
    321 
    322 #if defined(OS_CHROMEOS)
    323 
    324 void SystemTrayNotifier::NotifyShowLoginButtonChanged(bool show_login_button) {
    325   FOR_EACH_OBSERVER(LogoutButtonObserver,
    326                     logout_button_observers_,
    327                     OnShowLogoutButtonInTrayChanged(show_login_button));
    328 }
    329 
    330 void SystemTrayNotifier::NotifyLogoutDialogDurationChanged(
    331     base::TimeDelta duration) {
    332   FOR_EACH_OBSERVER(LogoutButtonObserver,
    333                     logout_button_observers_,
    334                     OnLogoutDialogDurationChanged(duration));
    335 }
    336 
    337 void SystemTrayNotifier::NotifySessionStartTimeChanged() {
    338   FOR_EACH_OBSERVER(SessionLengthLimitObserver,
    339                     session_length_limit_observers_,
    340                     OnSessionStartTimeChanged());
    341 }
    342 
    343 void SystemTrayNotifier::NotifySessionLengthLimitChanged() {
    344   FOR_EACH_OBSERVER(SessionLengthLimitObserver,
    345                     session_length_limit_observers_,
    346                     OnSessionLengthLimitChanged());
    347 }
    348 
    349 void SystemTrayNotifier::NotifyRequestToggleWifi() {
    350   FOR_EACH_OBSERVER(NetworkObserver,
    351                     network_observers_,
    352                     RequestToggleWifi());
    353 }
    354 
    355 void SystemTrayNotifier::NotifyOnCaptivePortalDetected(
    356     const std::string& service_path) {
    357   FOR_EACH_OBSERVER(NetworkPortalDetectorObserver,
    358                     network_portal_detector_observers_,
    359                     OnCaptivePortalDetected(service_path));
    360 }
    361 
    362 void SystemTrayNotifier::NotifyEnterpriseDomainChanged() {
    363   FOR_EACH_OBSERVER(EnterpriseDomainObserver, enterprise_domain_observers_,
    364       OnEnterpriseDomainChanged());
    365 }
    366 
    367 void SystemTrayNotifier::NotifyMediaCaptureChanged() {
    368   FOR_EACH_OBSERVER(
    369       MediaCaptureObserver, media_capture_observers_, OnMediaCaptureChanged());
    370 }
    371 
    372 void SystemTrayNotifier::NotifyScreenCaptureStart(
    373     const base::Closure& stop_callback,
    374     const base::string16& sharing_app_name) {
    375   FOR_EACH_OBSERVER(ScreenCaptureObserver, screen_capture_observers_,
    376                     OnScreenCaptureStart(stop_callback, sharing_app_name));
    377 }
    378 
    379 void SystemTrayNotifier::NotifyScreenCaptureStop() {
    380   FOR_EACH_OBSERVER(ScreenCaptureObserver, screen_capture_observers_,
    381                     OnScreenCaptureStop());
    382 }
    383 
    384 void SystemTrayNotifier::NotifyScreenShareStart(
    385     const base::Closure& stop_callback,
    386     const base::string16& helper_name) {
    387   FOR_EACH_OBSERVER(ScreenShareObserver, screen_share_observers_,
    388                     OnScreenShareStart(stop_callback, helper_name));
    389 }
    390 
    391 void SystemTrayNotifier::NotifyScreenShareStop() {
    392   FOR_EACH_OBSERVER(ScreenShareObserver, screen_share_observers_,
    393                     OnScreenShareStop());
    394 }
    395 
    396 void SystemTrayNotifier::NotifyLastWindowClosed() {
    397   FOR_EACH_OBSERVER(LastWindowClosedObserver,
    398                     last_window_closed_observers_,
    399                     OnLastWindowClosed());
    400 }
    401 
    402 #endif  // OS_CHROMEOS
    403 
    404 }  // namespace ash
    405