Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/common/system/tray/system_tray_notifier.h" | 5 #include "ash/common/system/tray/system_tray_notifier.h" |
| 6 | 6 |
| 7 #include "ash/common/system/accessibility_observer.h" | 7 #include "ash/common/system/accessibility_observer.h" |
| 8 #include "ash/common/system/date/clock_observer.h" | |
| 9 #include "ash/common/system/ime/ime_observer.h" | |
| 10 #include "ash/common/system/user/user_observer.h" | |
| 11 | |
| 12 #if defined(OS_CHROMEOS) | |
| 13 #include "ash/common/system/chromeos/bluetooth/bluetooth_observer.h" | 8 #include "ash/common/system/chromeos/bluetooth/bluetooth_observer.h" |
| 14 #include "ash/common/system/chromeos/enterprise/enterprise_domain_observer.h" | 9 #include "ash/common/system/chromeos/enterprise/enterprise_domain_observer.h" |
| 15 #include "ash/common/system/chromeos/network/network_observer.h" | 10 #include "ash/common/system/chromeos/network/network_observer.h" |
| 16 #include "ash/common/system/chromeos/network/network_portal_detector_observer.h" | 11 #include "ash/common/system/chromeos/network/network_portal_detector_observer.h" |
| 17 #include "ash/common/system/chromeos/screen_security/screen_capture_observer.h" | 12 #include "ash/common/system/chromeos/screen_security/screen_capture_observer.h" |
| 18 #include "ash/common/system/chromeos/screen_security/screen_share_observer.h" | 13 #include "ash/common/system/chromeos/screen_security/screen_share_observer.h" |
| 19 #include "ash/common/system/chromeos/session/last_window_closed_observer.h" | 14 #include "ash/common/system/chromeos/session/last_window_closed_observer.h" |
| 20 #include "ash/common/system/chromeos/session/logout_button_observer.h" | 15 #include "ash/common/system/chromeos/session/logout_button_observer.h" |
| 21 #include "ash/common/system/chromeos/session/session_length_limit_observer.h" | 16 #include "ash/common/system/chromeos/session/session_length_limit_observer.h" |
| 22 #include "ash/common/system/chromeos/tray_tracing.h" | 17 #include "ash/common/system/chromeos/tray_tracing.h" |
| 23 #include "ash/common/system/chromeos/virtual_keyboard/virtual_keyboard_observer. h" | 18 #include "ash/common/system/chromeos/virtual_keyboard/virtual_keyboard_observer. h" |
| 24 #endif | 19 #include "ash/common/system/date/clock_observer.h" |
| 20 #include "ash/common/system/ime/ime_observer.h" | |
| 21 #include "ash/common/system/user/user_observer.h" | |
| 25 | 22 |
| 26 namespace ash { | 23 namespace ash { |
| 27 | 24 |
| 28 SystemTrayNotifier::SystemTrayNotifier() {} | 25 SystemTrayNotifier::SystemTrayNotifier() {} |
| 29 | 26 |
| 30 SystemTrayNotifier::~SystemTrayNotifier() {} | 27 SystemTrayNotifier::~SystemTrayNotifier() {} |
| 31 | 28 |
| 32 void SystemTrayNotifier::AddAccessibilityObserver( | 29 void SystemTrayNotifier::AddAccessibilityObserver( |
| 33 AccessibilityObserver* observer) { | 30 AccessibilityObserver* observer) { |
| 34 accessibility_observers_.AddObserver(observer); | 31 accessibility_observers_.AddObserver(observer); |
| 35 } | 32 } |
| 36 | 33 |
| 37 void SystemTrayNotifier::RemoveAccessibilityObserver( | 34 void SystemTrayNotifier::RemoveAccessibilityObserver( |
| 38 AccessibilityObserver* observer) { | 35 AccessibilityObserver* observer) { |
| 39 accessibility_observers_.RemoveObserver(observer); | 36 accessibility_observers_.RemoveObserver(observer); |
| 40 } | 37 } |
| 41 | 38 |
| 42 void SystemTrayNotifier::NotifyAccessibilityModeChanged( | 39 void SystemTrayNotifier::NotifyAccessibilityModeChanged( |
| 43 AccessibilityNotificationVisibility notify) { | 40 AccessibilityNotificationVisibility notify) { |
| 44 for (auto& observer : accessibility_observers_) | 41 for (auto& observer : accessibility_observers_) |
| 45 observer.OnAccessibilityModeChanged(notify); | 42 observer.OnAccessibilityModeChanged(notify); |
| 46 } | 43 } |
| 47 | 44 |
| 45 void SystemTrayNotifier::AddBluetoothObserver(BluetoothObserver* observer) { | |
| 46 bluetooth_observers_.AddObserver(observer); | |
| 47 } | |
| 48 | |
| 49 void SystemTrayNotifier::RemoveBluetoothObserver(BluetoothObserver* observer) { | |
| 50 bluetooth_observers_.RemoveObserver(observer); | |
| 51 } | |
| 52 | |
| 53 void SystemTrayNotifier::NotifyRefreshBluetooth() { | |
| 54 for (auto& observer : bluetooth_observers_) | |
| 55 observer.OnBluetoothRefresh(); | |
| 56 } | |
| 57 | |
| 58 void SystemTrayNotifier::NotifyBluetoothDiscoveringChanged() { | |
| 59 for (auto& observer : bluetooth_observers_) | |
| 60 observer.OnBluetoothDiscoveringChanged(); | |
| 61 } | |
| 62 | |
| 63 void SystemTrayNotifier::AddEnterpriseDomainObserver( | |
|
msw
2016/12/14 22:51:00
nit: this belongs below with the other enterprise
James Cook
2016/12/14 23:46:08
Gack. Thanks for catching this.
| |
| 64 EnterpriseDomainObserver* observer) { | |
| 65 enterprise_domain_observers_.AddObserver(observer); | |
| 66 } | |
| 67 | |
| 48 void SystemTrayNotifier::AddClockObserver(ClockObserver* observer) { | 68 void SystemTrayNotifier::AddClockObserver(ClockObserver* observer) { |
| 49 clock_observers_.AddObserver(observer); | 69 clock_observers_.AddObserver(observer); |
| 50 } | 70 } |
| 51 | 71 |
| 52 void SystemTrayNotifier::RemoveClockObserver(ClockObserver* observer) { | 72 void SystemTrayNotifier::RemoveClockObserver(ClockObserver* observer) { |
| 53 clock_observers_.RemoveObserver(observer); | 73 clock_observers_.RemoveObserver(observer); |
| 54 } | 74 } |
| 55 | 75 |
| 56 void SystemTrayNotifier::NotifyRefreshClock() { | 76 void SystemTrayNotifier::NotifyRefreshClock() { |
| 57 for (auto& observer : clock_observers_) | 77 for (auto& observer : clock_observers_) |
| 58 observer.Refresh(); | 78 observer.Refresh(); |
| 59 } | 79 } |
| 60 | 80 |
| 61 void SystemTrayNotifier::NotifyDateFormatChanged() { | 81 void SystemTrayNotifier::NotifyDateFormatChanged() { |
| 62 for (auto& observer : clock_observers_) | 82 for (auto& observer : clock_observers_) |
| 63 observer.OnDateFormatChanged(); | 83 observer.OnDateFormatChanged(); |
| 64 } | 84 } |
| 65 | 85 |
| 66 void SystemTrayNotifier::NotifySystemClockTimeUpdated() { | 86 void SystemTrayNotifier::NotifySystemClockTimeUpdated() { |
| 67 for (auto& observer : clock_observers_) | 87 for (auto& observer : clock_observers_) |
| 68 observer.OnSystemClockTimeUpdated(); | 88 observer.OnSystemClockTimeUpdated(); |
| 69 } | 89 } |
| 70 | 90 |
| 71 void SystemTrayNotifier::NotifySystemClockCanSetTimeChanged(bool can_set_time) { | 91 void SystemTrayNotifier::NotifySystemClockCanSetTimeChanged(bool can_set_time) { |
| 72 for (auto& observer : clock_observers_) | 92 for (auto& observer : clock_observers_) |
| 73 observer.OnSystemClockCanSetTimeChanged(can_set_time); | 93 observer.OnSystemClockCanSetTimeChanged(can_set_time); |
| 74 } | 94 } |
| 75 | 95 |
| 96 void SystemTrayNotifier::RemoveEnterpriseDomainObserver( | |
| 97 EnterpriseDomainObserver* observer) { | |
| 98 enterprise_domain_observers_.RemoveObserver(observer); | |
| 99 } | |
| 100 | |
| 101 void SystemTrayNotifier::NotifyEnterpriseDomainChanged() { | |
| 102 for (auto& observer : enterprise_domain_observers_) | |
| 103 observer.OnEnterpriseDomainChanged(); | |
| 104 } | |
| 105 | |
| 76 void SystemTrayNotifier::AddIMEObserver(IMEObserver* observer) { | 106 void SystemTrayNotifier::AddIMEObserver(IMEObserver* observer) { |
| 77 ime_observers_.AddObserver(observer); | 107 ime_observers_.AddObserver(observer); |
| 78 } | 108 } |
| 79 | 109 |
| 80 void SystemTrayNotifier::RemoveIMEObserver(IMEObserver* observer) { | 110 void SystemTrayNotifier::RemoveIMEObserver(IMEObserver* observer) { |
| 81 ime_observers_.RemoveObserver(observer); | 111 ime_observers_.RemoveObserver(observer); |
| 82 } | 112 } |
| 83 | 113 |
| 84 void SystemTrayNotifier::NotifyRefreshIME() { | 114 void SystemTrayNotifier::NotifyRefreshIME() { |
| 85 for (auto& observer : ime_observers_) | 115 for (auto& observer : ime_observers_) |
| 86 observer.OnIMERefresh(); | 116 observer.OnIMERefresh(); |
| 87 } | 117 } |
| 88 | 118 |
| 89 void SystemTrayNotifier::NotifyRefreshIMEMenu(bool is_active) { | 119 void SystemTrayNotifier::NotifyRefreshIMEMenu(bool is_active) { |
| 90 for (auto& observer : ime_observers_) | 120 for (auto& observer : ime_observers_) |
| 91 observer.OnIMEMenuActivationChanged(is_active); | 121 observer.OnIMEMenuActivationChanged(is_active); |
| 92 } | 122 } |
| 93 | 123 |
| 94 void SystemTrayNotifier::AddUserObserver(UserObserver* observer) { | |
| 95 user_observers_.AddObserver(observer); | |
| 96 } | |
| 97 | |
| 98 void SystemTrayNotifier::RemoveUserObserver(UserObserver* observer) { | |
| 99 user_observers_.RemoveObserver(observer); | |
| 100 } | |
| 101 | |
| 102 void SystemTrayNotifier::NotifyUserUpdate() { | |
| 103 for (auto& observer : user_observers_) | |
| 104 observer.OnUserUpdate(); | |
| 105 } | |
| 106 | |
| 107 void SystemTrayNotifier::NotifyUserAddedToSession() { | |
| 108 for (auto& observer : user_observers_) | |
| 109 observer.OnUserAddedToSession(); | |
| 110 } | |
| 111 | |
| 112 //////////////////////////////////////////////////////////////////////////////// | |
| 113 | |
| 114 #if defined(OS_CHROMEOS) | |
| 115 | |
| 116 void SystemTrayNotifier::AddBluetoothObserver(BluetoothObserver* observer) { | |
| 117 bluetooth_observers_.AddObserver(observer); | |
| 118 } | |
| 119 | |
| 120 void SystemTrayNotifier::RemoveBluetoothObserver(BluetoothObserver* observer) { | |
| 121 bluetooth_observers_.RemoveObserver(observer); | |
| 122 } | |
| 123 | |
| 124 void SystemTrayNotifier::NotifyRefreshBluetooth() { | |
| 125 for (auto& observer : bluetooth_observers_) | |
| 126 observer.OnBluetoothRefresh(); | |
| 127 } | |
| 128 | |
| 129 void SystemTrayNotifier::NotifyBluetoothDiscoveringChanged() { | |
| 130 for (auto& observer : bluetooth_observers_) | |
| 131 observer.OnBluetoothDiscoveringChanged(); | |
| 132 } | |
| 133 | |
| 134 void SystemTrayNotifier::AddEnterpriseDomainObserver( | |
| 135 EnterpriseDomainObserver* observer) { | |
| 136 enterprise_domain_observers_.AddObserver(observer); | |
| 137 } | |
| 138 | |
| 139 void SystemTrayNotifier::RemoveEnterpriseDomainObserver( | |
| 140 EnterpriseDomainObserver* observer) { | |
| 141 enterprise_domain_observers_.RemoveObserver(observer); | |
| 142 } | |
| 143 | |
| 144 void SystemTrayNotifier::NotifyEnterpriseDomainChanged() { | |
| 145 for (auto& observer : enterprise_domain_observers_) | |
| 146 observer.OnEnterpriseDomainChanged(); | |
| 147 } | |
| 148 | |
| 149 void SystemTrayNotifier::AddLastWindowClosedObserver( | 124 void SystemTrayNotifier::AddLastWindowClosedObserver( |
| 150 LastWindowClosedObserver* observer) { | 125 LastWindowClosedObserver* observer) { |
| 151 last_window_closed_observers_.AddObserver(observer); | 126 last_window_closed_observers_.AddObserver(observer); |
| 152 } | 127 } |
| 153 | 128 |
| 154 void SystemTrayNotifier::RemoveLastWindowClosedObserver( | 129 void SystemTrayNotifier::RemoveLastWindowClosedObserver( |
| 155 LastWindowClosedObserver* observer) { | 130 LastWindowClosedObserver* observer) { |
| 156 last_window_closed_observers_.RemoveObserver(observer); | 131 last_window_closed_observers_.RemoveObserver(observer); |
| 157 } | 132 } |
| 158 | 133 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 280 | 255 |
| 281 void SystemTrayNotifier::RemoveTracingObserver(TracingObserver* observer) { | 256 void SystemTrayNotifier::RemoveTracingObserver(TracingObserver* observer) { |
| 282 tracing_observers_.RemoveObserver(observer); | 257 tracing_observers_.RemoveObserver(observer); |
| 283 } | 258 } |
| 284 | 259 |
| 285 void SystemTrayNotifier::NotifyTracingModeChanged(bool value) { | 260 void SystemTrayNotifier::NotifyTracingModeChanged(bool value) { |
| 286 for (auto& observer : tracing_observers_) | 261 for (auto& observer : tracing_observers_) |
| 287 observer.OnTracingModeChanged(value); | 262 observer.OnTracingModeChanged(value); |
| 288 } | 263 } |
| 289 | 264 |
| 265 void SystemTrayNotifier::AddUserObserver(UserObserver* observer) { | |
| 266 user_observers_.AddObserver(observer); | |
| 267 } | |
| 268 | |
| 269 void SystemTrayNotifier::RemoveUserObserver(UserObserver* observer) { | |
| 270 user_observers_.RemoveObserver(observer); | |
| 271 } | |
| 272 | |
| 273 void SystemTrayNotifier::NotifyUserUpdate() { | |
| 274 for (auto& observer : user_observers_) | |
| 275 observer.OnUserUpdate(); | |
| 276 } | |
| 277 | |
| 278 void SystemTrayNotifier::NotifyUserAddedToSession() { | |
| 279 for (auto& observer : user_observers_) | |
| 280 observer.OnUserAddedToSession(); | |
| 281 } | |
| 282 | |
| 290 void SystemTrayNotifier::AddVirtualKeyboardObserver( | 283 void SystemTrayNotifier::AddVirtualKeyboardObserver( |
| 291 VirtualKeyboardObserver* observer) { | 284 VirtualKeyboardObserver* observer) { |
| 292 virtual_keyboard_observers_.AddObserver(observer); | 285 virtual_keyboard_observers_.AddObserver(observer); |
| 293 } | 286 } |
| 294 | 287 |
| 295 void SystemTrayNotifier::RemoveVirtualKeyboardObserver( | 288 void SystemTrayNotifier::RemoveVirtualKeyboardObserver( |
| 296 VirtualKeyboardObserver* observer) { | 289 VirtualKeyboardObserver* observer) { |
| 297 virtual_keyboard_observers_.RemoveObserver(observer); | 290 virtual_keyboard_observers_.RemoveObserver(observer); |
| 298 } | 291 } |
| 299 | 292 |
| 300 void SystemTrayNotifier::NotifyVirtualKeyboardSuppressionChanged( | 293 void SystemTrayNotifier::NotifyVirtualKeyboardSuppressionChanged( |
| 301 bool suppressed) { | 294 bool suppressed) { |
| 302 for (auto& observer : virtual_keyboard_observers_) | 295 for (auto& observer : virtual_keyboard_observers_) |
| 303 observer.OnKeyboardSuppressionChanged(suppressed); | 296 observer.OnKeyboardSuppressionChanged(suppressed); |
| 304 } | 297 } |
| 305 | 298 |
| 306 #endif // defined(OS_CHROMEOS) | |
| 307 | |
| 308 } // namespace ash | 299 } // namespace ash |
| OLD | NEW |