Separate Simple Backend creation from initialization.
[chromium-blink-merge.git] / ash / system / tray / system_tray_notifier.cc
blob070f8f367fbfa460dcfa6ddb669a8681443ef7d9
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 namespace ash {
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::AddBrightnessObserver(BrightnessObserver* observer) {
42 brightness_observers_.AddObserver(observer);
45 void SystemTrayNotifier::RemoveBrightnessObserver(
46 BrightnessObserver* observer) {
47 brightness_observers_.RemoveObserver(observer);
50 void SystemTrayNotifier::AddCapsLockObserver(CapsLockObserver* observer) {
51 caps_lock_observers_.AddObserver(observer);
54 void SystemTrayNotifier::RemoveCapsLockObserver(CapsLockObserver* observer) {
55 caps_lock_observers_.RemoveObserver(observer);
58 void SystemTrayNotifier::AddClockObserver(ClockObserver* observer) {
59 clock_observers_.AddObserver(observer);
62 void SystemTrayNotifier::RemoveClockObserver(ClockObserver* observer) {
63 clock_observers_.RemoveObserver(observer);
66 void SystemTrayNotifier::AddDriveObserver(DriveObserver* observer) {
67 drive_observers_.AddObserver(observer);
70 void SystemTrayNotifier::RemoveDriveObserver(DriveObserver* observer) {
71 drive_observers_.RemoveObserver(observer);
74 void SystemTrayNotifier::AddIMEObserver(IMEObserver* observer) {
75 ime_observers_.AddObserver(observer);
78 void SystemTrayNotifier::RemoveIMEObserver(IMEObserver* observer) {
79 ime_observers_.RemoveObserver(observer);
82 void SystemTrayNotifier::AddLocaleObserver(LocaleObserver* observer) {
83 locale_observers_.AddObserver(observer);
86 void SystemTrayNotifier::RemoveLocaleObserver(LocaleObserver* observer) {
87 locale_observers_.RemoveObserver(observer);
90 void SystemTrayNotifier::AddLogoutButtonObserver(
91 LogoutButtonObserver* observer) {
92 logout_button_observers_.AddObserver(observer);
95 void SystemTrayNotifier::RemoveLogoutButtonObserver(
96 LogoutButtonObserver* observer) {
97 logout_button_observers_.RemoveObserver(observer);
100 void SystemTrayNotifier::AddPowerStatusObserver(
101 PowerStatusObserver* observer) {
102 power_status_observers_.AddObserver(observer);
105 void SystemTrayNotifier::RemovePowerStatusObserver(
106 PowerStatusObserver* observer) {
107 power_status_observers_.RemoveObserver(observer);
110 void SystemTrayNotifier::AddSessionLengthLimitObserver(
111 SessionLengthLimitObserver* observer) {
112 session_length_limit_observers_.AddObserver(observer);
115 void SystemTrayNotifier::RemoveSessionLengthLimitObserver(
116 SessionLengthLimitObserver* observer) {
117 session_length_limit_observers_.RemoveObserver(observer);
120 void SystemTrayNotifier::AddUpdateObserver(UpdateObserver* observer) {
121 update_observers_.AddObserver(observer);
124 void SystemTrayNotifier::RemoveUpdateObserver(UpdateObserver* observer) {
125 update_observers_.RemoveObserver(observer);
128 void SystemTrayNotifier::AddUserObserver(UserObserver* observer) {
129 user_observers_.AddObserver(observer);
132 void SystemTrayNotifier::RemoveUserObserver(UserObserver* observer) {
133 user_observers_.RemoveObserver(observer);
136 #if defined(OS_CHROMEOS)
137 void SystemTrayNotifier::AddNetworkObserver(NetworkObserver* observer) {
138 network_observers_.AddObserver(observer);
141 void SystemTrayNotifier::RemoveNetworkObserver(NetworkObserver* observer) {
142 network_observers_.RemoveObserver(observer);
145 void SystemTrayNotifier::AddVpnObserver(NetworkObserver* observer) {
146 vpn_observers_.AddObserver(observer);
149 void SystemTrayNotifier::RemoveVpnObserver(NetworkObserver* observer) {
150 vpn_observers_.RemoveObserver(observer);
153 void SystemTrayNotifier::AddSmsObserver(SmsObserver* observer) {
154 sms_observers_.AddObserver(observer);
157 void SystemTrayNotifier::RemoveSmsObserver(SmsObserver* observer) {
158 sms_observers_.RemoveObserver(observer);
161 void SystemTrayNotifier::AddEnterpriseDomainObserver(
162 EnterpriseDomainObserver* observer) {
163 enterprise_domain_observers_.AddObserver(observer);
166 void SystemTrayNotifier::RemoveEnterpriseDomainObserver(
167 EnterpriseDomainObserver* observer) {
168 enterprise_domain_observers_.RemoveObserver(observer);
171 void SystemTrayNotifier::AddScreenCaptureObserver(
172 ScreenCaptureObserver* observer) {
173 screen_capture_observers_.AddObserver(observer);
176 void SystemTrayNotifier::RemoveScreenCaptureObserver(
177 ScreenCaptureObserver* observer) {
178 screen_capture_observers_.RemoveObserver(observer);
181 #endif
183 void SystemTrayNotifier::NotifyAccessibilityModeChanged(
184 AccessibilityNotificationVisibility notify) {
185 FOR_EACH_OBSERVER(
186 AccessibilityObserver,
187 accessibility_observers_,
188 OnAccessibilityModeChanged(notify));
191 void SystemTrayNotifier::NotifyVolumeChanged(float level) {
192 FOR_EACH_OBSERVER(AudioObserver,
193 audio_observers_,
194 OnVolumeChanged(level));
197 void SystemTrayNotifier::NotifyMuteToggled() {
198 FOR_EACH_OBSERVER(AudioObserver,
199 audio_observers_,
200 OnMuteToggled());
203 void SystemTrayNotifier::NotifyRefreshBluetooth() {
204 FOR_EACH_OBSERVER(BluetoothObserver,
205 bluetooth_observers_,
206 OnBluetoothRefresh());
209 void SystemTrayNotifier::NotifyBluetoothDiscoveringChanged() {
210 FOR_EACH_OBSERVER(BluetoothObserver,
211 bluetooth_observers_,
212 OnBluetoothDiscoveringChanged());
215 void SystemTrayNotifier::NotifyBrightnessChanged(double level,
216 bool user_initiated) {
217 FOR_EACH_OBSERVER(
218 BrightnessObserver,
219 brightness_observers_,
220 OnBrightnessChanged(level, user_initiated));
223 void SystemTrayNotifier::NotifyCapsLockChanged(
224 bool enabled,
225 bool search_mapped_to_caps_lock) {
226 FOR_EACH_OBSERVER(CapsLockObserver,
227 caps_lock_observers_,
228 OnCapsLockChanged(enabled, search_mapped_to_caps_lock));
231 void SystemTrayNotifier::NotifyRefreshClock() {
232 FOR_EACH_OBSERVER(ClockObserver, clock_observers_, Refresh());
235 void SystemTrayNotifier::NotifyDateFormatChanged() {
236 FOR_EACH_OBSERVER(ClockObserver,
237 clock_observers_,
238 OnDateFormatChanged());
241 void SystemTrayNotifier::NotifySystemClockTimeUpdated() {
242 FOR_EACH_OBSERVER(ClockObserver,
243 clock_observers_,
244 OnSystemClockTimeUpdated());
247 void SystemTrayNotifier::NotifyRefreshDrive(DriveOperationStatusList& list) {
248 FOR_EACH_OBSERVER(DriveObserver,
249 drive_observers_,
250 OnDriveRefresh(list));
253 void SystemTrayNotifier::NotifyRefreshIME(bool show_message) {
254 FOR_EACH_OBSERVER(IMEObserver,
255 ime_observers_,
256 OnIMERefresh(show_message));
259 void SystemTrayNotifier::NotifyShowLoginButtonChanged(bool show_login_button) {
260 FOR_EACH_OBSERVER(LogoutButtonObserver,
261 logout_button_observers_,
262 OnShowLogoutButtonInTrayChanged(show_login_button));
265 void SystemTrayNotifier::NotifyLocaleChanged(
266 LocaleObserver::Delegate* delegate,
267 const std::string& cur_locale,
268 const std::string& from_locale,
269 const std::string& to_locale) {
270 FOR_EACH_OBSERVER(
271 LocaleObserver,
272 locale_observers_,
273 OnLocaleChanged(delegate, cur_locale, from_locale, to_locale));
276 void SystemTrayNotifier::NotifyPowerStatusChanged(
277 const PowerSupplyStatus& power_status) {
278 FOR_EACH_OBSERVER(PowerStatusObserver,
279 power_status_observers_,
280 OnPowerStatusChanged(power_status));
283 void SystemTrayNotifier::NotifySessionStartTimeChanged() {
284 FOR_EACH_OBSERVER(SessionLengthLimitObserver,
285 session_length_limit_observers_,
286 OnSessionStartTimeChanged());
289 void SystemTrayNotifier::NotifySessionLengthLimitChanged() {
290 FOR_EACH_OBSERVER(SessionLengthLimitObserver,
291 session_length_limit_observers_,
292 OnSessionLengthLimitChanged());
295 void SystemTrayNotifier::NotifyUpdateRecommended(
296 UpdateObserver::UpdateSeverity severity) {
297 FOR_EACH_OBSERVER(UpdateObserver,
298 update_observers_,
299 OnUpdateRecommended(severity));
302 void SystemTrayNotifier::NotifyUserUpdate() {
303 FOR_EACH_OBSERVER(UserObserver,
304 user_observers_,
305 OnUserUpdate());
308 #if defined(OS_CHROMEOS)
310 void SystemTrayNotifier::NotifyRefreshNetwork(const NetworkIconInfo &info) {
311 FOR_EACH_OBSERVER(NetworkObserver,
312 network_observers_,
313 OnNetworkRefresh(info));
316 void SystemTrayNotifier::NotifySetNetworkMessage(
317 NetworkTrayDelegate* delegate,
318 NetworkObserver::MessageType message_type,
319 NetworkObserver::NetworkType network_type,
320 const string16& title,
321 const string16& message,
322 const std::vector<string16>& links) {
323 FOR_EACH_OBSERVER(NetworkObserver,
324 network_observers_,
325 SetNetworkMessage(
326 delegate,
327 message_type,
328 network_type,
329 title,
330 message,
331 links));
334 void SystemTrayNotifier::NotifyClearNetworkMessage(
335 NetworkObserver::MessageType message_type) {
336 FOR_EACH_OBSERVER(NetworkObserver,
337 network_observers_,
338 ClearNetworkMessage(message_type));
341 void SystemTrayNotifier::NotifyVpnRefreshNetwork(const NetworkIconInfo &info) {
342 FOR_EACH_OBSERVER(NetworkObserver,
343 vpn_observers_,
344 OnNetworkRefresh(info));
347 void SystemTrayNotifier::NotifyWillToggleWifi() {
348 FOR_EACH_OBSERVER(NetworkObserver,
349 network_observers_,
350 OnWillToggleWifi());
353 void SystemTrayNotifier::NotifyAddSmsMessage(
354 const base::DictionaryValue& message) {
355 FOR_EACH_OBSERVER(SmsObserver, sms_observers_, AddMessage(message));
358 void SystemTrayNotifier::NotifyEnterpriseDomainChanged() {
359 FOR_EACH_OBSERVER(EnterpriseDomainObserver, enterprise_domain_observers_,
360 OnEnterpriseDomainChanged());
363 void SystemTrayNotifier::NotifyScreenCaptureStart(
364 const base::Closure& stop_callback,
365 const string16& sharing_app_name) {
366 FOR_EACH_OBSERVER(ScreenCaptureObserver, screen_capture_observers_,
367 OnScreenCaptureStart(stop_callback, sharing_app_name));
370 void SystemTrayNotifier::NotifyScreenCaptureStop() {
371 FOR_EACH_OBSERVER(ScreenCaptureObserver, screen_capture_observers_,
372 OnScreenCaptureStop());
375 #endif // OS_CHROMEOS
377 } // namespace ash