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"
9 SystemTrayNotifier::SystemTrayNotifier() {
12 SystemTrayNotifier::~SystemTrayNotifier() {
15 void SystemTrayNotifier::AddAccessibilityObserver(
16 AccessibilityObserver
* observer
) {
17 accessibility_observers_
.AddObserver(observer
);
20 void SystemTrayNotifier::RemoveAccessibilityObserver(
21 AccessibilityObserver
* observer
) {
22 accessibility_observers_
.RemoveObserver(observer
);
25 void SystemTrayNotifier::AddAudioObserver(AudioObserver
* observer
) {
26 audio_observers_
.AddObserver(observer
);
29 void SystemTrayNotifier::RemoveAudioObserver(AudioObserver
* observer
) {
30 audio_observers_
.RemoveObserver(observer
);
33 void SystemTrayNotifier::AddBluetoothObserver(BluetoothObserver
* observer
) {
34 bluetooth_observers_
.AddObserver(observer
);
37 void SystemTrayNotifier::RemoveBluetoothObserver(BluetoothObserver
* observer
) {
38 bluetooth_observers_
.RemoveObserver(observer
);
41 void SystemTrayNotifier::AddClockObserver(ClockObserver
* observer
) {
42 clock_observers_
.AddObserver(observer
);
45 void SystemTrayNotifier::RemoveClockObserver(ClockObserver
* observer
) {
46 clock_observers_
.RemoveObserver(observer
);
49 void SystemTrayNotifier::AddIMEObserver(IMEObserver
* observer
) {
50 ime_observers_
.AddObserver(observer
);
53 void SystemTrayNotifier::RemoveIMEObserver(IMEObserver
* observer
) {
54 ime_observers_
.RemoveObserver(observer
);
57 void SystemTrayNotifier::AddLocaleObserver(LocaleObserver
* observer
) {
58 locale_observers_
.AddObserver(observer
);
61 void SystemTrayNotifier::RemoveLocaleObserver(LocaleObserver
* observer
) {
62 locale_observers_
.RemoveObserver(observer
);
65 void SystemTrayNotifier::AddTracingObserver(TracingObserver
* observer
) {
66 tracing_observers_
.AddObserver(observer
);
69 void SystemTrayNotifier::RemoveTracingObserver(TracingObserver
* observer
) {
70 tracing_observers_
.RemoveObserver(observer
);
73 void SystemTrayNotifier::AddUpdateObserver(UpdateObserver
* observer
) {
74 update_observers_
.AddObserver(observer
);
77 void SystemTrayNotifier::RemoveUpdateObserver(UpdateObserver
* observer
) {
78 update_observers_
.RemoveObserver(observer
);
81 void SystemTrayNotifier::AddUserObserver(UserObserver
* observer
) {
82 user_observers_
.AddObserver(observer
);
85 void SystemTrayNotifier::RemoveUserObserver(UserObserver
* observer
) {
86 user_observers_
.RemoveObserver(observer
);
89 #if defined(OS_CHROMEOS)
91 void SystemTrayNotifier::AddLogoutButtonObserver(
92 LogoutButtonObserver
* observer
) {
93 logout_button_observers_
.AddObserver(observer
);
96 void SystemTrayNotifier::RemoveLogoutButtonObserver(
97 LogoutButtonObserver
* observer
) {
98 logout_button_observers_
.RemoveObserver(observer
);
101 void SystemTrayNotifier::AddSessionLengthLimitObserver(
102 SessionLengthLimitObserver
* observer
) {
103 session_length_limit_observers_
.AddObserver(observer
);
106 void SystemTrayNotifier::RemoveSessionLengthLimitObserver(
107 SessionLengthLimitObserver
* observer
) {
108 session_length_limit_observers_
.RemoveObserver(observer
);
111 void SystemTrayNotifier::AddNetworkObserver(NetworkObserver
* observer
) {
112 network_observers_
.AddObserver(observer
);
115 void SystemTrayNotifier::RemoveNetworkObserver(NetworkObserver
* observer
) {
116 network_observers_
.RemoveObserver(observer
);
119 void SystemTrayNotifier::AddNetworkPortalDetectorObserver(
120 NetworkPortalDetectorObserver
* observer
) {
121 network_portal_detector_observers_
.AddObserver(observer
);
124 void SystemTrayNotifier::RemoveNetworkPortalDetectorObserver(
125 NetworkPortalDetectorObserver
* observer
) {
126 network_portal_detector_observers_
.RemoveObserver(observer
);
129 void SystemTrayNotifier::AddEnterpriseDomainObserver(
130 EnterpriseDomainObserver
* observer
) {
131 enterprise_domain_observers_
.AddObserver(observer
);
134 void SystemTrayNotifier::RemoveEnterpriseDomainObserver(
135 EnterpriseDomainObserver
* observer
) {
136 enterprise_domain_observers_
.RemoveObserver(observer
);
139 void SystemTrayNotifier::AddMediaCaptureObserver(
140 MediaCaptureObserver
* observer
) {
141 media_capture_observers_
.AddObserver(observer
);
144 void SystemTrayNotifier::RemoveMediaCaptureObserver(
145 MediaCaptureObserver
* observer
) {
146 media_capture_observers_
.RemoveObserver(observer
);
149 void SystemTrayNotifier::AddScreenCaptureObserver(
150 ScreenCaptureObserver
* observer
) {
151 screen_capture_observers_
.AddObserver(observer
);
154 void SystemTrayNotifier::RemoveScreenCaptureObserver(
155 ScreenCaptureObserver
* observer
) {
156 screen_capture_observers_
.RemoveObserver(observer
);
159 void SystemTrayNotifier::AddScreenShareObserver(
160 ScreenShareObserver
* observer
) {
161 screen_share_observers_
.AddObserver(observer
);
164 void SystemTrayNotifier::RemoveScreenShareObserver(
165 ScreenShareObserver
* observer
) {
166 screen_share_observers_
.RemoveObserver(observer
);
169 void SystemTrayNotifier::AddLastWindowClosedObserver(
170 LastWindowClosedObserver
* observer
) {
171 last_window_closed_observers_
.AddObserver(observer
);
174 void SystemTrayNotifier::RemoveLastWindowClosedObserver(
175 LastWindowClosedObserver
* observer
) {
176 last_window_closed_observers_
.RemoveObserver(observer
);
179 void SystemTrayNotifier::AddVirtualKeyboardObserver(
180 VirtualKeyboardObserver
* observer
) {
181 virtual_keyboard_observers_
.AddObserver(observer
);
184 void SystemTrayNotifier::RemoveVirtualKeyboardObserver(
185 VirtualKeyboardObserver
* observer
) {
186 virtual_keyboard_observers_
.RemoveObserver(observer
);
190 void SystemTrayNotifier::NotifyAccessibilityModeChanged(
191 ui::AccessibilityNotificationVisibility notify
) {
193 AccessibilityObserver
,
194 accessibility_observers_
,
195 OnAccessibilityModeChanged(notify
));
198 void SystemTrayNotifier::NotifyAudioOutputVolumeChanged(uint64_t node_id
,
200 FOR_EACH_OBSERVER(AudioObserver
, audio_observers_
,
201 OnOutputNodeVolumeChanged(node_id
, volume
));
204 void SystemTrayNotifier::NotifyAudioOutputMuteChanged(bool mute_on
,
205 bool system_adjust
) {
206 FOR_EACH_OBSERVER(AudioObserver
, audio_observers_
,
207 OnOutputMuteChanged(mute_on
, system_adjust
));
210 void SystemTrayNotifier::NotifyAudioNodesChanged() {
214 OnAudioNodesChanged());
217 void SystemTrayNotifier::NotifyAudioActiveOutputNodeChanged() {
221 OnActiveOutputNodeChanged());
224 void SystemTrayNotifier::NotifyAudioActiveInputNodeChanged() {
228 OnActiveInputNodeChanged());
231 void SystemTrayNotifier::NotifyTracingModeChanged(bool value
) {
235 OnTracingModeChanged(value
));
238 void SystemTrayNotifier::NotifyRefreshBluetooth() {
239 FOR_EACH_OBSERVER(BluetoothObserver
,
240 bluetooth_observers_
,
241 OnBluetoothRefresh());
244 void SystemTrayNotifier::NotifyBluetoothDiscoveringChanged() {
245 FOR_EACH_OBSERVER(BluetoothObserver
,
246 bluetooth_observers_
,
247 OnBluetoothDiscoveringChanged());
250 void SystemTrayNotifier::NotifyRefreshClock() {
251 FOR_EACH_OBSERVER(ClockObserver
, clock_observers_
, Refresh());
254 void SystemTrayNotifier::NotifyDateFormatChanged() {
255 FOR_EACH_OBSERVER(ClockObserver
,
257 OnDateFormatChanged());
260 void SystemTrayNotifier::NotifySystemClockTimeUpdated() {
261 FOR_EACH_OBSERVER(ClockObserver
,
263 OnSystemClockTimeUpdated());
266 void SystemTrayNotifier::NotifySystemClockCanSetTimeChanged(bool can_set_time
) {
267 FOR_EACH_OBSERVER(ClockObserver
,
269 OnSystemClockCanSetTimeChanged(can_set_time
));
272 void SystemTrayNotifier::NotifyRefreshIME() {
273 FOR_EACH_OBSERVER(IMEObserver
,
278 void SystemTrayNotifier::NotifyLocaleChanged(
279 LocaleObserver::Delegate
* delegate
,
280 const std::string
& cur_locale
,
281 const std::string
& from_locale
,
282 const std::string
& to_locale
) {
286 OnLocaleChanged(delegate
, cur_locale
, from_locale
, to_locale
));
289 void SystemTrayNotifier::NotifyUpdateRecommended(const UpdateInfo
& info
) {
291 UpdateObserver
, update_observers_
, OnUpdateRecommended(info
));
294 void SystemTrayNotifier::NotifyUserUpdate() {
295 FOR_EACH_OBSERVER(UserObserver
,
300 void SystemTrayNotifier::NotifyUserAddedToSession() {
301 FOR_EACH_OBSERVER(UserObserver
,
303 OnUserAddedToSession());
306 #if defined(OS_CHROMEOS)
308 void SystemTrayNotifier::NotifyShowLoginButtonChanged(bool show_login_button
) {
309 FOR_EACH_OBSERVER(LogoutButtonObserver
,
310 logout_button_observers_
,
311 OnShowLogoutButtonInTrayChanged(show_login_button
));
314 void SystemTrayNotifier::NotifyLogoutDialogDurationChanged(
315 base::TimeDelta duration
) {
316 FOR_EACH_OBSERVER(LogoutButtonObserver
,
317 logout_button_observers_
,
318 OnLogoutDialogDurationChanged(duration
));
321 void SystemTrayNotifier::NotifySessionStartTimeChanged() {
322 FOR_EACH_OBSERVER(SessionLengthLimitObserver
,
323 session_length_limit_observers_
,
324 OnSessionStartTimeChanged());
327 void SystemTrayNotifier::NotifySessionLengthLimitChanged() {
328 FOR_EACH_OBSERVER(SessionLengthLimitObserver
,
329 session_length_limit_observers_
,
330 OnSessionLengthLimitChanged());
333 void SystemTrayNotifier::NotifyRequestToggleWifi() {
334 FOR_EACH_OBSERVER(NetworkObserver
,
336 RequestToggleWifi());
339 void SystemTrayNotifier::NotifyOnCaptivePortalDetected(
340 const std::string
& service_path
) {
341 FOR_EACH_OBSERVER(NetworkPortalDetectorObserver
,
342 network_portal_detector_observers_
,
343 OnCaptivePortalDetected(service_path
));
346 void SystemTrayNotifier::NotifyEnterpriseDomainChanged() {
347 FOR_EACH_OBSERVER(EnterpriseDomainObserver
, enterprise_domain_observers_
,
348 OnEnterpriseDomainChanged());
351 void SystemTrayNotifier::NotifyMediaCaptureChanged() {
353 MediaCaptureObserver
, media_capture_observers_
, OnMediaCaptureChanged());
356 void SystemTrayNotifier::NotifyScreenCaptureStart(
357 const base::Closure
& stop_callback
,
358 const base::string16
& sharing_app_name
) {
359 FOR_EACH_OBSERVER(ScreenCaptureObserver
, screen_capture_observers_
,
360 OnScreenCaptureStart(stop_callback
, sharing_app_name
));
363 void SystemTrayNotifier::NotifyScreenCaptureStop() {
364 FOR_EACH_OBSERVER(ScreenCaptureObserver
, screen_capture_observers_
,
365 OnScreenCaptureStop());
368 void SystemTrayNotifier::NotifyScreenShareStart(
369 const base::Closure
& stop_callback
,
370 const base::string16
& helper_name
) {
371 FOR_EACH_OBSERVER(ScreenShareObserver
, screen_share_observers_
,
372 OnScreenShareStart(stop_callback
, helper_name
));
375 void SystemTrayNotifier::NotifyScreenShareStop() {
376 FOR_EACH_OBSERVER(ScreenShareObserver
, screen_share_observers_
,
377 OnScreenShareStop());
380 void SystemTrayNotifier::NotifyLastWindowClosed() {
381 FOR_EACH_OBSERVER(LastWindowClosedObserver
,
382 last_window_closed_observers_
,
383 OnLastWindowClosed());
386 void SystemTrayNotifier::NotifyVirtualKeyboardSuppressionChanged(
388 FOR_EACH_OBSERVER(VirtualKeyboardObserver
,
389 virtual_keyboard_observers_
,
390 OnKeyboardSuppressionChanged(suppressed
));
393 #endif // OS_CHROMEOS