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.
5 #include "ash/system/tray/system_tray_notifier.h"
7 #if defined(OS_CHROMEOS)
8 #include "ash/system/chromeos/network/network_state_notifier.h"
13 SystemTrayNotifier::SystemTrayNotifier() {
14 #if defined(OS_CHROMEOS)
15 network_state_notifier_
.reset(new NetworkStateNotifier());
19 SystemTrayNotifier::~SystemTrayNotifier() {
22 void SystemTrayNotifier::AddAccessibilityObserver(
23 AccessibilityObserver
* observer
) {
24 accessibility_observers_
.AddObserver(observer
);
27 void SystemTrayNotifier::RemoveAccessibilityObserver(
28 AccessibilityObserver
* observer
) {
29 accessibility_observers_
.RemoveObserver(observer
);
32 void SystemTrayNotifier::AddAudioObserver(AudioObserver
* observer
) {
33 audio_observers_
.AddObserver(observer
);
36 void SystemTrayNotifier::RemoveAudioObserver(AudioObserver
* observer
) {
37 audio_observers_
.RemoveObserver(observer
);
40 void SystemTrayNotifier::AddBluetoothObserver(BluetoothObserver
* observer
) {
41 bluetooth_observers_
.AddObserver(observer
);
44 void SystemTrayNotifier::RemoveBluetoothObserver(BluetoothObserver
* observer
) {
45 bluetooth_observers_
.RemoveObserver(observer
);
48 void SystemTrayNotifier::AddClockObserver(ClockObserver
* observer
) {
49 clock_observers_
.AddObserver(observer
);
52 void SystemTrayNotifier::RemoveClockObserver(ClockObserver
* observer
) {
53 clock_observers_
.RemoveObserver(observer
);
56 void SystemTrayNotifier::AddIMEObserver(IMEObserver
* observer
) {
57 ime_observers_
.AddObserver(observer
);
60 void SystemTrayNotifier::RemoveIMEObserver(IMEObserver
* observer
) {
61 ime_observers_
.RemoveObserver(observer
);
64 void SystemTrayNotifier::AddLocaleObserver(LocaleObserver
* observer
) {
65 locale_observers_
.AddObserver(observer
);
68 void SystemTrayNotifier::RemoveLocaleObserver(LocaleObserver
* observer
) {
69 locale_observers_
.RemoveObserver(observer
);
72 void SystemTrayNotifier::AddTracingObserver(TracingObserver
* observer
) {
73 tracing_observers_
.AddObserver(observer
);
76 void SystemTrayNotifier::RemoveTracingObserver(TracingObserver
* observer
) {
77 tracing_observers_
.RemoveObserver(observer
);
80 void SystemTrayNotifier::AddUpdateObserver(UpdateObserver
* observer
) {
81 update_observers_
.AddObserver(observer
);
84 void SystemTrayNotifier::RemoveUpdateObserver(UpdateObserver
* observer
) {
85 update_observers_
.RemoveObserver(observer
);
88 void SystemTrayNotifier::AddUserObserver(UserObserver
* observer
) {
89 user_observers_
.AddObserver(observer
);
92 void SystemTrayNotifier::RemoveUserObserver(UserObserver
* observer
) {
93 user_observers_
.RemoveObserver(observer
);
96 #if defined(OS_CHROMEOS)
98 void SystemTrayNotifier::AddLogoutButtonObserver(
99 LogoutButtonObserver
* observer
) {
100 logout_button_observers_
.AddObserver(observer
);
103 void SystemTrayNotifier::RemoveLogoutButtonObserver(
104 LogoutButtonObserver
* observer
) {
105 logout_button_observers_
.RemoveObserver(observer
);
108 void SystemTrayNotifier::AddSessionLengthLimitObserver(
109 SessionLengthLimitObserver
* observer
) {
110 session_length_limit_observers_
.AddObserver(observer
);
113 void SystemTrayNotifier::RemoveSessionLengthLimitObserver(
114 SessionLengthLimitObserver
* observer
) {
115 session_length_limit_observers_
.RemoveObserver(observer
);
118 void SystemTrayNotifier::AddNetworkObserver(NetworkObserver
* observer
) {
119 network_observers_
.AddObserver(observer
);
122 void SystemTrayNotifier::RemoveNetworkObserver(NetworkObserver
* observer
) {
123 network_observers_
.RemoveObserver(observer
);
126 void SystemTrayNotifier::AddNetworkPortalDetectorObserver(
127 NetworkPortalDetectorObserver
* observer
) {
128 network_portal_detector_observers_
.AddObserver(observer
);
131 void SystemTrayNotifier::RemoveNetworkPortalDetectorObserver(
132 NetworkPortalDetectorObserver
* observer
) {
133 network_portal_detector_observers_
.RemoveObserver(observer
);
136 void SystemTrayNotifier::AddEnterpriseDomainObserver(
137 EnterpriseDomainObserver
* observer
) {
138 enterprise_domain_observers_
.AddObserver(observer
);
141 void SystemTrayNotifier::RemoveEnterpriseDomainObserver(
142 EnterpriseDomainObserver
* observer
) {
143 enterprise_domain_observers_
.RemoveObserver(observer
);
146 void SystemTrayNotifier::AddMediaCaptureObserver(
147 MediaCaptureObserver
* observer
) {
148 media_capture_observers_
.AddObserver(observer
);
151 void SystemTrayNotifier::RemoveMediaCaptureObserver(
152 MediaCaptureObserver
* observer
) {
153 media_capture_observers_
.RemoveObserver(observer
);
156 void SystemTrayNotifier::AddScreenCaptureObserver(
157 ScreenCaptureObserver
* observer
) {
158 screen_capture_observers_
.AddObserver(observer
);
161 void SystemTrayNotifier::RemoveScreenCaptureObserver(
162 ScreenCaptureObserver
* observer
) {
163 screen_capture_observers_
.RemoveObserver(observer
);
166 void SystemTrayNotifier::AddScreenShareObserver(
167 ScreenShareObserver
* observer
) {
168 screen_share_observers_
.AddObserver(observer
);
171 void SystemTrayNotifier::RemoveScreenShareObserver(
172 ScreenShareObserver
* observer
) {
173 screen_share_observers_
.RemoveObserver(observer
);
176 void SystemTrayNotifier::AddLastWindowClosedObserver(
177 LastWindowClosedObserver
* observer
) {
178 last_window_closed_observers_
.AddObserver(observer
);
181 void SystemTrayNotifier::RemoveLastWindowClosedObserver(
182 LastWindowClosedObserver
* observer
) {
183 last_window_closed_observers_
.RemoveObserver(observer
);
187 void SystemTrayNotifier::NotifyAccessibilityModeChanged(
188 AccessibilityNotificationVisibility notify
) {
190 AccessibilityObserver
,
191 accessibility_observers_
,
192 OnAccessibilityModeChanged(notify
));
195 void SystemTrayNotifier::NotifyAudioOutputVolumeChanged() {
199 OnOutputVolumeChanged());
202 void SystemTrayNotifier::NotifyAudioOutputMuteChanged() {
206 OnOutputMuteChanged());
209 void SystemTrayNotifier::NotifyAudioNodesChanged() {
213 OnAudioNodesChanged());
216 void SystemTrayNotifier::NotifyAudioActiveOutputNodeChanged() {
220 OnActiveOutputNodeChanged());
223 void SystemTrayNotifier::NotifyAudioActiveInputNodeChanged() {
227 OnActiveInputNodeChanged());
230 void SystemTrayNotifier::NotifyTracingModeChanged(bool value
) {
234 OnTracingModeChanged(value
));
237 void SystemTrayNotifier::NotifyRefreshBluetooth() {
238 FOR_EACH_OBSERVER(BluetoothObserver
,
239 bluetooth_observers_
,
240 OnBluetoothRefresh());
243 void SystemTrayNotifier::NotifyBluetoothDiscoveringChanged() {
244 FOR_EACH_OBSERVER(BluetoothObserver
,
245 bluetooth_observers_
,
246 OnBluetoothDiscoveringChanged());
249 void SystemTrayNotifier::NotifyRefreshClock() {
250 FOR_EACH_OBSERVER(ClockObserver
, clock_observers_
, Refresh());
253 void SystemTrayNotifier::NotifyDateFormatChanged() {
254 FOR_EACH_OBSERVER(ClockObserver
,
256 OnDateFormatChanged());
259 void SystemTrayNotifier::NotifySystemClockTimeUpdated() {
260 FOR_EACH_OBSERVER(ClockObserver
,
262 OnSystemClockTimeUpdated());
265 void SystemTrayNotifier::NotifySystemClockCanSetTimeChanged(bool can_set_time
) {
266 FOR_EACH_OBSERVER(ClockObserver
,
268 OnSystemClockCanSetTimeChanged(can_set_time
));
271 void SystemTrayNotifier::NotifyRefreshIME() {
272 FOR_EACH_OBSERVER(IMEObserver
,
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
) {
285 OnLocaleChanged(delegate
, cur_locale
, from_locale
, to_locale
));
288 void SystemTrayNotifier::NotifyUpdateRecommended(
289 UpdateObserver::UpdateSeverity severity
) {
290 FOR_EACH_OBSERVER(UpdateObserver
,
292 OnUpdateRecommended(severity
));
295 void SystemTrayNotifier::NotifyUserUpdate() {
296 FOR_EACH_OBSERVER(UserObserver
,
301 void SystemTrayNotifier::NotifyUserAddedToSession() {
302 FOR_EACH_OBSERVER(UserObserver
,
304 OnUserAddedToSession());
307 #if defined(OS_CHROMEOS)
309 void SystemTrayNotifier::NotifyShowLoginButtonChanged(bool show_login_button
) {
310 FOR_EACH_OBSERVER(LogoutButtonObserver
,
311 logout_button_observers_
,
312 OnShowLogoutButtonInTrayChanged(show_login_button
));
315 void SystemTrayNotifier::NotifyLogoutDialogDurationChanged(
316 base::TimeDelta duration
) {
317 FOR_EACH_OBSERVER(LogoutButtonObserver
,
318 logout_button_observers_
,
319 OnLogoutDialogDurationChanged(duration
));
322 void SystemTrayNotifier::NotifySessionStartTimeChanged() {
323 FOR_EACH_OBSERVER(SessionLengthLimitObserver
,
324 session_length_limit_observers_
,
325 OnSessionStartTimeChanged());
328 void SystemTrayNotifier::NotifySessionLengthLimitChanged() {
329 FOR_EACH_OBSERVER(SessionLengthLimitObserver
,
330 session_length_limit_observers_
,
331 OnSessionLengthLimitChanged());
334 void SystemTrayNotifier::NotifyRequestToggleWifi() {
335 FOR_EACH_OBSERVER(NetworkObserver
,
337 RequestToggleWifi());
340 void SystemTrayNotifier::NotifyOnCaptivePortalDetected(
341 const std::string
& service_path
) {
342 FOR_EACH_OBSERVER(NetworkPortalDetectorObserver
,
343 network_portal_detector_observers_
,
344 OnCaptivePortalDetected(service_path
));
347 void SystemTrayNotifier::NotifyEnterpriseDomainChanged() {
348 FOR_EACH_OBSERVER(EnterpriseDomainObserver
, enterprise_domain_observers_
,
349 OnEnterpriseDomainChanged());
352 void SystemTrayNotifier::NotifyMediaCaptureChanged() {
354 MediaCaptureObserver
, media_capture_observers_
, OnMediaCaptureChanged());
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
));
364 void SystemTrayNotifier::NotifyScreenCaptureStop() {
365 FOR_EACH_OBSERVER(ScreenCaptureObserver
, screen_capture_observers_
,
366 OnScreenCaptureStop());
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
));
376 void SystemTrayNotifier::NotifyScreenShareStop() {
377 FOR_EACH_OBSERVER(ScreenShareObserver
, screen_share_observers_
,
378 OnScreenShareStop());
381 void SystemTrayNotifier::NotifyLastWindowClosed() {
382 FOR_EACH_OBSERVER(LastWindowClosedObserver
,
383 last_window_closed_observers_
,
384 OnLastWindowClosed());
387 #endif // OS_CHROMEOS