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