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::AddDriveObserver(DriveObserver* observer) {
57 drive_observers_.AddObserver(observer);
60 void SystemTrayNotifier::RemoveDriveObserver(DriveObserver* observer) {
61 drive_observers_.RemoveObserver(observer);
64 void SystemTrayNotifier::AddIMEObserver(IMEObserver* observer) {
65 ime_observers_.AddObserver(observer);
68 void SystemTrayNotifier::RemoveIMEObserver(IMEObserver* observer) {
69 ime_observers_.RemoveObserver(observer);
72 void SystemTrayNotifier::AddLocaleObserver(LocaleObserver* observer) {
73 locale_observers_.AddObserver(observer);
76 void SystemTrayNotifier::RemoveLocaleObserver(LocaleObserver* observer) {
77 locale_observers_.RemoveObserver(observer);
80 void SystemTrayNotifier::AddTracingObserver(TracingObserver* observer) {
81 tracing_observers_.AddObserver(observer);
84 void SystemTrayNotifier::RemoveTracingObserver(TracingObserver* observer) {
85 tracing_observers_.RemoveObserver(observer);
88 void SystemTrayNotifier::AddUpdateObserver(UpdateObserver* observer) {
89 update_observers_.AddObserver(observer);
92 void SystemTrayNotifier::RemoveUpdateObserver(UpdateObserver* observer) {
93 update_observers_.RemoveObserver(observer);
96 void SystemTrayNotifier::AddUserObserver(UserObserver* observer) {
97 user_observers_.AddObserver(observer);
100 void SystemTrayNotifier::RemoveUserObserver(UserObserver* observer) {
101 user_observers_.RemoveObserver(observer);
104 #if defined(OS_CHROMEOS)
106 void SystemTrayNotifier::AddLogoutButtonObserver(
107 LogoutButtonObserver* observer) {
108 logout_button_observers_.AddObserver(observer);
111 void SystemTrayNotifier::RemoveLogoutButtonObserver(
112 LogoutButtonObserver* observer) {
113 logout_button_observers_.RemoveObserver(observer);
116 void SystemTrayNotifier::AddSessionLengthLimitObserver(
117 SessionLengthLimitObserver* observer) {
118 session_length_limit_observers_.AddObserver(observer);
121 void SystemTrayNotifier::RemoveSessionLengthLimitObserver(
122 SessionLengthLimitObserver* observer) {
123 session_length_limit_observers_.RemoveObserver(observer);
126 void SystemTrayNotifier::AddNetworkObserver(NetworkObserver* observer) {
127 network_observers_.AddObserver(observer);
130 void SystemTrayNotifier::RemoveNetworkObserver(NetworkObserver* observer) {
131 network_observers_.RemoveObserver(observer);
134 void SystemTrayNotifier::AddNetworkPortalDetectorObserver(
135 NetworkPortalDetectorObserver* observer) {
136 network_portal_detector_observers_.AddObserver(observer);
139 void SystemTrayNotifier::RemoveNetworkPortalDetectorObserver(
140 NetworkPortalDetectorObserver* observer) {
141 network_portal_detector_observers_.RemoveObserver(observer);
144 void SystemTrayNotifier::AddEnterpriseDomainObserver(
145 EnterpriseDomainObserver* observer) {
146 enterprise_domain_observers_.AddObserver(observer);
149 void SystemTrayNotifier::RemoveEnterpriseDomainObserver(
150 EnterpriseDomainObserver* observer) {
151 enterprise_domain_observers_.RemoveObserver(observer);
154 void SystemTrayNotifier::AddScreenCaptureObserver(
155 ScreenCaptureObserver* observer) {
156 screen_capture_observers_.AddObserver(observer);
159 void SystemTrayNotifier::RemoveScreenCaptureObserver(
160 ScreenCaptureObserver* observer) {
161 screen_capture_observers_.RemoveObserver(observer);
164 void SystemTrayNotifier::AddScreenShareObserver(
165 ScreenShareObserver* observer) {
166 screen_share_observers_.AddObserver(observer);
169 void SystemTrayNotifier::RemoveScreenShareObserver(
170 ScreenShareObserver* observer) {
171 screen_share_observers_.RemoveObserver(observer);
174 void SystemTrayNotifier::AddLastWindowClosedObserver(
175 LastWindowClosedObserver* observer) {
176 last_window_closed_observers_.AddObserver(observer);
179 void SystemTrayNotifier::RemoveLastWindowClosedObserver(
180 LastWindowClosedObserver* observer) {
181 last_window_closed_observers_.RemoveObserver(observer);
185 void SystemTrayNotifier::NotifyAccessibilityModeChanged(
186 AccessibilityNotificationVisibility notify) {
188 AccessibilityObserver,
189 accessibility_observers_,
190 OnAccessibilityModeChanged(notify));
193 void SystemTrayNotifier::NotifyAudioOutputVolumeChanged() {
197 OnOutputVolumeChanged());
200 void SystemTrayNotifier::NotifyAudioOutputMuteChanged() {
204 OnOutputMuteChanged());
207 void SystemTrayNotifier::NotifyAudioNodesChanged() {
211 OnAudioNodesChanged());
214 void SystemTrayNotifier::NotifyAudioActiveOutputNodeChanged() {
218 OnActiveOutputNodeChanged());
221 void SystemTrayNotifier::NotifyAudioActiveInputNodeChanged() {
225 OnActiveInputNodeChanged());
228 void SystemTrayNotifier::NotifyTracingModeChanged(bool value) {
232 OnTracingModeChanged(value));
235 void SystemTrayNotifier::NotifyRefreshBluetooth() {
236 FOR_EACH_OBSERVER(BluetoothObserver,
237 bluetooth_observers_,
238 OnBluetoothRefresh());
241 void SystemTrayNotifier::NotifyBluetoothDiscoveringChanged() {
242 FOR_EACH_OBSERVER(BluetoothObserver,
243 bluetooth_observers_,
244 OnBluetoothDiscoveringChanged());
247 void SystemTrayNotifier::NotifyRefreshClock() {
248 FOR_EACH_OBSERVER(ClockObserver, clock_observers_, Refresh());
251 void SystemTrayNotifier::NotifyDateFormatChanged() {
252 FOR_EACH_OBSERVER(ClockObserver,
254 OnDateFormatChanged());
257 void SystemTrayNotifier::NotifySystemClockTimeUpdated() {
258 FOR_EACH_OBSERVER(ClockObserver,
260 OnSystemClockTimeUpdated());
263 void SystemTrayNotifier::NotifyDriveJobUpdated(
264 const DriveOperationStatus& status) {
265 FOR_EACH_OBSERVER(DriveObserver,
267 OnDriveJobUpdated(status));
270 void SystemTrayNotifier::NotifyRefreshIME() {
271 FOR_EACH_OBSERVER(IMEObserver,
276 void SystemTrayNotifier::NotifyLocaleChanged(
277 LocaleObserver::Delegate* delegate,
278 const std::string& cur_locale,
279 const std::string& from_locale,
280 const std::string& to_locale) {
284 OnLocaleChanged(delegate, cur_locale, from_locale, to_locale));
287 void SystemTrayNotifier::NotifyUpdateRecommended(
288 UpdateObserver::UpdateSeverity severity) {
289 FOR_EACH_OBSERVER(UpdateObserver,
291 OnUpdateRecommended(severity));
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::NotifyScreenCaptureStart(
352 const base::Closure& stop_callback,
353 const base::string16& sharing_app_name) {
354 FOR_EACH_OBSERVER(ScreenCaptureObserver, screen_capture_observers_,
355 OnScreenCaptureStart(stop_callback, sharing_app_name));
358 void SystemTrayNotifier::NotifyScreenCaptureStop() {
359 FOR_EACH_OBSERVER(ScreenCaptureObserver, screen_capture_observers_,
360 OnScreenCaptureStop());
363 void SystemTrayNotifier::NotifyScreenShareStart(
364 const base::Closure& stop_callback,
365 const base::string16& helper_name) {
366 FOR_EACH_OBSERVER(ScreenShareObserver, screen_share_observers_,
367 OnScreenShareStart(stop_callback, helper_name));
370 void SystemTrayNotifier::NotifyScreenShareStop() {
371 FOR_EACH_OBSERVER(ScreenShareObserver, screen_share_observers_,
372 OnScreenShareStop());
375 void SystemTrayNotifier::NotifyLastWindowClosed() {
376 FOR_EACH_OBSERVER(LastWindowClosedObserver,
377 last_window_closed_observers_,
378 OnLastWindowClosed());
381 #endif // OS_CHROMEOS