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
AddBluetoothObserver(BluetoothObserver * observer)32 void SystemTrayNotifier::AddBluetoothObserver(BluetoothObserver* observer) {
33 bluetooth_observers_.AddObserver(observer);
34 }
35
RemoveBluetoothObserver(BluetoothObserver * observer)36 void SystemTrayNotifier::RemoveBluetoothObserver(BluetoothObserver* observer) {
37 bluetooth_observers_.RemoveObserver(observer);
38 }
39
AddCapsLockObserver(CapsLockObserver * observer)40 void SystemTrayNotifier::AddCapsLockObserver(CapsLockObserver* observer) {
41 caps_lock_observers_.AddObserver(observer);
42 }
43
RemoveCapsLockObserver(CapsLockObserver * observer)44 void SystemTrayNotifier::RemoveCapsLockObserver(CapsLockObserver* observer) {
45 caps_lock_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
AddLogoutButtonObserver(LogoutButtonObserver * observer)80 void SystemTrayNotifier::AddLogoutButtonObserver(
81 LogoutButtonObserver* observer) {
82 logout_button_observers_.AddObserver(observer);
83 }
84
RemoveLogoutButtonObserver(LogoutButtonObserver * observer)85 void SystemTrayNotifier::RemoveLogoutButtonObserver(
86 LogoutButtonObserver* observer) {
87 logout_button_observers_.RemoveObserver(observer);
88 }
89
AddSessionLengthLimitObserver(SessionLengthLimitObserver * observer)90 void SystemTrayNotifier::AddSessionLengthLimitObserver(
91 SessionLengthLimitObserver* observer) {
92 session_length_limit_observers_.AddObserver(observer);
93 }
94
RemoveSessionLengthLimitObserver(SessionLengthLimitObserver * observer)95 void SystemTrayNotifier::RemoveSessionLengthLimitObserver(
96 SessionLengthLimitObserver* observer) {
97 session_length_limit_observers_.RemoveObserver(observer);
98 }
99
AddTracingObserver(TracingObserver * observer)100 void SystemTrayNotifier::AddTracingObserver(TracingObserver* observer) {
101 tracing_observers_.AddObserver(observer);
102 }
103
RemoveTracingObserver(TracingObserver * observer)104 void SystemTrayNotifier::RemoveTracingObserver(TracingObserver* observer) {
105 tracing_observers_.RemoveObserver(observer);
106 }
107
AddUpdateObserver(UpdateObserver * observer)108 void SystemTrayNotifier::AddUpdateObserver(UpdateObserver* observer) {
109 update_observers_.AddObserver(observer);
110 }
111
RemoveUpdateObserver(UpdateObserver * observer)112 void SystemTrayNotifier::RemoveUpdateObserver(UpdateObserver* observer) {
113 update_observers_.RemoveObserver(observer);
114 }
115
AddUserObserver(UserObserver * observer)116 void SystemTrayNotifier::AddUserObserver(UserObserver* observer) {
117 user_observers_.AddObserver(observer);
118 }
119
RemoveUserObserver(UserObserver * observer)120 void SystemTrayNotifier::RemoveUserObserver(UserObserver* observer) {
121 user_observers_.RemoveObserver(observer);
122 }
123
124 #if defined(OS_CHROMEOS)
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
AddEnterpriseDomainObserver(EnterpriseDomainObserver * observer)134 void SystemTrayNotifier::AddEnterpriseDomainObserver(
135 EnterpriseDomainObserver* observer) {
136 enterprise_domain_observers_.AddObserver(observer);
137 }
138
RemoveEnterpriseDomainObserver(EnterpriseDomainObserver * observer)139 void SystemTrayNotifier::RemoveEnterpriseDomainObserver(
140 EnterpriseDomainObserver* observer) {
141 enterprise_domain_observers_.RemoveObserver(observer);
142 }
143
AddScreenCaptureObserver(ScreenCaptureObserver * observer)144 void SystemTrayNotifier::AddScreenCaptureObserver(
145 ScreenCaptureObserver* observer) {
146 screen_capture_observers_.AddObserver(observer);
147 }
148
RemoveScreenCaptureObserver(ScreenCaptureObserver * observer)149 void SystemTrayNotifier::RemoveScreenCaptureObserver(
150 ScreenCaptureObserver* observer) {
151 screen_capture_observers_.RemoveObserver(observer);
152 }
153
AddScreenShareObserver(ScreenShareObserver * observer)154 void SystemTrayNotifier::AddScreenShareObserver(
155 ScreenShareObserver* observer) {
156 screen_share_observers_.AddObserver(observer);
157 }
158
RemoveScreenShareObserver(ScreenShareObserver * observer)159 void SystemTrayNotifier::RemoveScreenShareObserver(
160 ScreenShareObserver* observer) {
161 screen_share_observers_.RemoveObserver(observer);
162 }
163 #endif
164
NotifyAccessibilityModeChanged(AccessibilityNotificationVisibility notify)165 void SystemTrayNotifier::NotifyAccessibilityModeChanged(
166 AccessibilityNotificationVisibility notify) {
167 FOR_EACH_OBSERVER(
168 AccessibilityObserver,
169 accessibility_observers_,
170 OnAccessibilityModeChanged(notify));
171 }
172
NotifyTracingModeChanged(bool value)173 void SystemTrayNotifier::NotifyTracingModeChanged(bool value) {
174 FOR_EACH_OBSERVER(
175 TracingObserver,
176 tracing_observers_,
177 OnTracingModeChanged(value));
178 }
179
NotifyRefreshBluetooth()180 void SystemTrayNotifier::NotifyRefreshBluetooth() {
181 FOR_EACH_OBSERVER(BluetoothObserver,
182 bluetooth_observers_,
183 OnBluetoothRefresh());
184 }
185
NotifyBluetoothDiscoveringChanged()186 void SystemTrayNotifier::NotifyBluetoothDiscoveringChanged() {
187 FOR_EACH_OBSERVER(BluetoothObserver,
188 bluetooth_observers_,
189 OnBluetoothDiscoveringChanged());
190 }
191
NotifyCapsLockChanged(bool enabled,bool search_mapped_to_caps_lock)192 void SystemTrayNotifier::NotifyCapsLockChanged(
193 bool enabled,
194 bool search_mapped_to_caps_lock) {
195 FOR_EACH_OBSERVER(CapsLockObserver,
196 caps_lock_observers_,
197 OnCapsLockChanged(enabled, search_mapped_to_caps_lock));
198 }
199
NotifyRefreshClock()200 void SystemTrayNotifier::NotifyRefreshClock() {
201 FOR_EACH_OBSERVER(ClockObserver, clock_observers_, Refresh());
202 }
203
NotifyDateFormatChanged()204 void SystemTrayNotifier::NotifyDateFormatChanged() {
205 FOR_EACH_OBSERVER(ClockObserver,
206 clock_observers_,
207 OnDateFormatChanged());
208 }
209
NotifySystemClockTimeUpdated()210 void SystemTrayNotifier::NotifySystemClockTimeUpdated() {
211 FOR_EACH_OBSERVER(ClockObserver,
212 clock_observers_,
213 OnSystemClockTimeUpdated());
214 }
215
NotifyDriveJobUpdated(const DriveOperationStatus & status)216 void SystemTrayNotifier::NotifyDriveJobUpdated(
217 const DriveOperationStatus& status) {
218 FOR_EACH_OBSERVER(DriveObserver,
219 drive_observers_,
220 OnDriveJobUpdated(status));
221 }
222
NotifyRefreshIME(bool show_message)223 void SystemTrayNotifier::NotifyRefreshIME(bool show_message) {
224 FOR_EACH_OBSERVER(IMEObserver,
225 ime_observers_,
226 OnIMERefresh(show_message));
227 }
228
NotifyShowLoginButtonChanged(bool show_login_button)229 void SystemTrayNotifier::NotifyShowLoginButtonChanged(bool show_login_button) {
230 FOR_EACH_OBSERVER(LogoutButtonObserver,
231 logout_button_observers_,
232 OnShowLogoutButtonInTrayChanged(show_login_button));
233 }
234
NotifyLocaleChanged(LocaleObserver::Delegate * delegate,const std::string & cur_locale,const std::string & from_locale,const std::string & to_locale)235 void SystemTrayNotifier::NotifyLocaleChanged(
236 LocaleObserver::Delegate* delegate,
237 const std::string& cur_locale,
238 const std::string& from_locale,
239 const std::string& to_locale) {
240 FOR_EACH_OBSERVER(
241 LocaleObserver,
242 locale_observers_,
243 OnLocaleChanged(delegate, cur_locale, from_locale, to_locale));
244 }
245
NotifySessionStartTimeChanged()246 void SystemTrayNotifier::NotifySessionStartTimeChanged() {
247 FOR_EACH_OBSERVER(SessionLengthLimitObserver,
248 session_length_limit_observers_,
249 OnSessionStartTimeChanged());
250 }
251
NotifySessionLengthLimitChanged()252 void SystemTrayNotifier::NotifySessionLengthLimitChanged() {
253 FOR_EACH_OBSERVER(SessionLengthLimitObserver,
254 session_length_limit_observers_,
255 OnSessionLengthLimitChanged());
256 }
257
NotifyUpdateRecommended(UpdateObserver::UpdateSeverity severity)258 void SystemTrayNotifier::NotifyUpdateRecommended(
259 UpdateObserver::UpdateSeverity severity) {
260 FOR_EACH_OBSERVER(UpdateObserver,
261 update_observers_,
262 OnUpdateRecommended(severity));
263 }
264
NotifyUserUpdate()265 void SystemTrayNotifier::NotifyUserUpdate() {
266 FOR_EACH_OBSERVER(UserObserver,
267 user_observers_,
268 OnUserUpdate());
269 }
270
NotifyUserAddedToSession()271 void SystemTrayNotifier::NotifyUserAddedToSession() {
272 FOR_EACH_OBSERVER(UserObserver,
273 user_observers_,
274 OnUserAddedToSession());
275 }
276
277 #if defined(OS_CHROMEOS)
278
NotifyRequestToggleWifi()279 void SystemTrayNotifier::NotifyRequestToggleWifi() {
280 FOR_EACH_OBSERVER(NetworkObserver,
281 network_observers_,
282 RequestToggleWifi());
283 }
284
NotifyEnterpriseDomainChanged()285 void SystemTrayNotifier::NotifyEnterpriseDomainChanged() {
286 FOR_EACH_OBSERVER(EnterpriseDomainObserver, enterprise_domain_observers_,
287 OnEnterpriseDomainChanged());
288 }
289
NotifyScreenCaptureStart(const base::Closure & stop_callback,const base::string16 & sharing_app_name)290 void SystemTrayNotifier::NotifyScreenCaptureStart(
291 const base::Closure& stop_callback,
292 const base::string16& sharing_app_name) {
293 FOR_EACH_OBSERVER(ScreenCaptureObserver, screen_capture_observers_,
294 OnScreenCaptureStart(stop_callback, sharing_app_name));
295 }
296
NotifyScreenCaptureStop()297 void SystemTrayNotifier::NotifyScreenCaptureStop() {
298 FOR_EACH_OBSERVER(ScreenCaptureObserver, screen_capture_observers_,
299 OnScreenCaptureStop());
300 }
301
NotifyScreenShareStart(const base::Closure & stop_callback,const base::string16 & helper_name)302 void SystemTrayNotifier::NotifyScreenShareStart(
303 const base::Closure& stop_callback,
304 const base::string16& helper_name) {
305 FOR_EACH_OBSERVER(ScreenShareObserver, screen_share_observers_,
306 OnScreenShareStart(stop_callback, helper_name));
307 }
308
NotifyScreenShareStop()309 void SystemTrayNotifier::NotifyScreenShareStop() {
310 FOR_EACH_OBSERVER(ScreenShareObserver, screen_share_observers_,
311 OnScreenShareStop());
312 }
313
314 #endif // OS_CHROMEOS
315
316 } // namespace ash
317