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