| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #ifndef CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_ACCESSIBILITY_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_ACCESSIBILITY_MANAGER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_ACCESSIBILITY_MANAGER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_ACCESSIBILITY_MANAGER_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "ash/accessibility_delegate.h" | 10 #include "ash/accessibility_delegate.h" |
| 11 #include "ash/session_state_observer.h" | 11 #include "ash/session_state_observer.h" |
| 12 #include "base/callback_list.h" |
| 12 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 13 #include "base/prefs/pref_change_registrar.h" | 14 #include "base/prefs/pref_change_registrar.h" |
| 14 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 15 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" | 16 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" |
| 16 #include "chrome/browser/extensions/api/braille_display_private/braille_controll
er.h" | 17 #include "chrome/browser/extensions/api/braille_display_private/braille_controll
er.h" |
| 17 #include "content/public/browser/notification_observer.h" | 18 #include "content/public/browser/notification_observer.h" |
| 18 #include "content/public/browser/notification_registrar.h" | 19 #include "content/public/browser/notification_registrar.h" |
| 19 #include "extensions/browser/event_router.h" | 20 #include "extensions/browser/event_router.h" |
| 20 #include "extensions/browser/extension_system.h" | 21 #include "extensions/browser/extension_system.h" |
| 21 | 22 |
| 22 namespace content { | 23 namespace content { |
| 23 class RenderViewHost; | 24 class RenderViewHost; |
| 24 } | 25 } |
| 25 class Profile; | 26 class Profile; |
| 26 | 27 |
| 27 namespace chromeos { | 28 namespace chromeos { |
| 28 | 29 |
| 30 enum AccessibilityNotificationType { |
| 31 ACCESSIBILITY_NOTIFICATION_NONE, |
| 32 ACCESSIBILITY_MANAGER_SHUTDOWN, |
| 33 ACCESSIBILITY_TOGGLE_HIGH_CONTRAST_MODE, |
| 34 ACCESSIBILITY_TOGGLE_LARGE_CURSOR, |
| 35 ACCESSIBILITY_TOGGLE_SCREEN_MAGNIFIER, |
| 36 ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK, |
| 37 ACCESSIBILITY_TOGGLE_VIRTUAL_KEYBOARD |
| 38 }; |
| 39 |
| 29 struct AccessibilityStatusEventDetails { | 40 struct AccessibilityStatusEventDetails { |
| 30 AccessibilityStatusEventDetails( | 41 AccessibilityStatusEventDetails( |
| 42 AccessibilityNotificationType notification_type, |
| 31 bool enabled, | 43 bool enabled, |
| 32 ash::AccessibilityNotificationVisibility notify); | 44 ash::AccessibilityNotificationVisibility notify); |
| 33 | 45 |
| 34 AccessibilityStatusEventDetails( | 46 AccessibilityStatusEventDetails( |
| 47 AccessibilityNotificationType notification_type, |
| 35 bool enabled, | 48 bool enabled, |
| 36 ash::MagnifierType magnifier_type, | 49 ash::MagnifierType magnifier_type, |
| 37 ash::AccessibilityNotificationVisibility notify); | 50 ash::AccessibilityNotificationVisibility notify); |
| 38 | 51 |
| 52 AccessibilityNotificationType notification_type; |
| 39 bool enabled; | 53 bool enabled; |
| 40 ash::MagnifierType magnifier_type; | 54 ash::MagnifierType magnifier_type; |
| 41 ash::AccessibilityNotificationVisibility notify; | 55 ash::AccessibilityNotificationVisibility notify; |
| 42 }; | 56 }; |
| 43 | 57 |
| 58 typedef base::Callback<void(const AccessibilityStatusEventDetails&)> |
| 59 AccessibilityStatusCallback; |
| 60 |
| 61 typedef base::CallbackList<void(const AccessibilityStatusEventDetails&)> |
| 62 AccessibilityStatusCallbackList; |
| 63 |
| 64 typedef AccessibilityStatusCallbackList::Subscription |
| 65 AccessibilityStatusSubscription; |
| 66 |
| 44 // AccessibilityManager changes the statuses of accessibility features | 67 // AccessibilityManager changes the statuses of accessibility features |
| 45 // watching profile notifications and pref-changes. | 68 // watching profile notifications and pref-changes. |
| 46 // TODO(yoshiki): merge MagnificationManager with AccessibilityManager. | 69 // TODO(yoshiki): merge MagnificationManager with AccessibilityManager. |
| 47 class AccessibilityManager : public content::NotificationObserver, | 70 class AccessibilityManager : public content::NotificationObserver, |
| 48 extensions::api::braille_display_private::BrailleObserver, | 71 extensions::api::braille_display_private::BrailleObserver, |
| 49 public ash::SessionStateObserver { | 72 public ash::SessionStateObserver { |
| 50 public: | 73 public: |
| 51 // Creates an instance of AccessibilityManager, this should be called once, | 74 // Creates an instance of AccessibilityManager, this should be called once, |
| 52 // because only one instance should exist at the same time. | 75 // because only one instance should exist at the same time. |
| 53 static void Initialize(); | 76 static void Initialize(); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 | 160 |
| 138 // Enables/disables system sounds. | 161 // Enables/disables system sounds. |
| 139 void EnableSystemSounds(bool system_sounds_enabled); | 162 void EnableSystemSounds(bool system_sounds_enabled); |
| 140 | 163 |
| 141 // Initiates play of shutdown sound and returns it's duration. | 164 // Initiates play of shutdown sound and returns it's duration. |
| 142 base::TimeDelta PlayShutdownSound(); | 165 base::TimeDelta PlayShutdownSound(); |
| 143 | 166 |
| 144 // Injects ChromeVox scripts into given |render_view_host|. | 167 // Injects ChromeVox scripts into given |render_view_host|. |
| 145 void InjectChromeVox(content::RenderViewHost* render_view_host); | 168 void InjectChromeVox(content::RenderViewHost* render_view_host); |
| 146 | 169 |
| 170 // Register a callback to be notified when the status of an accessibility |
| 171 // option changes. |
| 172 scoped_ptr<AccessibilityStatusSubscription> RegisterCallback( |
| 173 const AccessibilityStatusCallback& cb); |
| 174 |
| 175 // Notify registered callbacks of a status change in an accessibility setting. |
| 176 void NotifyAccessibilityStatusChanged( |
| 177 AccessibilityStatusEventDetails& details); |
| 178 |
| 147 protected: | 179 protected: |
| 148 AccessibilityManager(); | 180 AccessibilityManager(); |
| 149 virtual ~AccessibilityManager(); | 181 virtual ~AccessibilityManager(); |
| 150 | 182 |
| 151 private: | 183 private: |
| 152 void LoadChromeVox(); | 184 void LoadChromeVox(); |
| 153 void LoadChromeVoxToUserScreen(); | 185 void LoadChromeVoxToUserScreen(); |
| 154 void LoadChromeVoxToLockScreen(); | 186 void LoadChromeVoxToLockScreen(); |
| 155 void UnloadChromeVox(); | 187 void UnloadChromeVox(); |
| 156 void UnloadChromeVoxFromLockScreen(); | 188 void UnloadChromeVoxFromLockScreen(); |
| 157 void PostLoadChromeVox(Profile* profile); | 189 void PostLoadChromeVox(Profile* profile); |
| 158 void PostUnloadChromeVox(Profile* profile); | 190 void PostUnloadChromeVox(Profile* profile); |
| 159 | 191 |
| 160 void UpdateLargeCursorFromPref(); | 192 void UpdateLargeCursorFromPref(); |
| 161 void UpdateStickyKeysFromPref(); | 193 void UpdateStickyKeysFromPref(); |
| 162 void UpdateSpokenFeedbackFromPref(); | 194 void UpdateSpokenFeedbackFromPref(); |
| 163 void UpdateHighContrastFromPref(); | 195 void UpdateHighContrastFromPref(); |
| 164 void UpdateAutoclickFromPref(); | 196 void UpdateAutoclickFromPref(); |
| 165 void UpdateAutoclickDelayFromPref(); | 197 void UpdateAutoclickDelayFromPref(); |
| 166 void UpdateVirtualKeyboardFromPref(); | 198 void UpdateVirtualKeyboardFromPref(); |
| 167 void LocalePrefChanged(); | 199 void LocalePrefChanged(); |
| 168 | 200 |
| 169 void CheckBrailleState(); | 201 void CheckBrailleState(); |
| 170 void ReceiveBrailleDisplayState( | 202 void ReceiveBrailleDisplayState( |
| 171 scoped_ptr<extensions::api::braille_display_private::DisplayState> state); | 203 scoped_ptr<extensions::api::braille_display_private::DisplayState> state); |
| 172 | 204 |
| 173 | |
| 174 void SetProfile(Profile* profile); | 205 void SetProfile(Profile* profile); |
| 175 | 206 |
| 176 void UpdateChromeOSAccessibilityHistograms(); | 207 void UpdateChromeOSAccessibilityHistograms(); |
| 177 | 208 |
| 178 // content::NotificationObserver implementation: | 209 // content::NotificationObserver implementation: |
| 179 virtual void Observe(int type, | 210 virtual void Observe(int type, |
| 180 const content::NotificationSource& source, | 211 const content::NotificationSource& source, |
| 181 const content::NotificationDetails& details) OVERRIDE; | 212 const content::NotificationDetails& details) OVERRIDE; |
| 182 | 213 |
| 183 // extensions::api::braille_display_private::BrailleObserver implementation. | 214 // extensions::api::braille_display_private::BrailleObserver implementation. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 bool virtual_keyboard_enabled_; | 246 bool virtual_keyboard_enabled_; |
| 216 | 247 |
| 217 ash::AccessibilityNotificationVisibility spoken_feedback_notification_; | 248 ash::AccessibilityNotificationVisibility spoken_feedback_notification_; |
| 218 | 249 |
| 219 base::WeakPtrFactory<AccessibilityManager> weak_ptr_factory_; | 250 base::WeakPtrFactory<AccessibilityManager> weak_ptr_factory_; |
| 220 | 251 |
| 221 bool should_speak_chrome_vox_announcements_on_user_screen_; | 252 bool should_speak_chrome_vox_announcements_on_user_screen_; |
| 222 | 253 |
| 223 bool system_sounds_enabled_; | 254 bool system_sounds_enabled_; |
| 224 | 255 |
| 256 AccessibilityStatusCallbackList callback_list_; |
| 257 |
| 225 DISALLOW_COPY_AND_ASSIGN(AccessibilityManager); | 258 DISALLOW_COPY_AND_ASSIGN(AccessibilityManager); |
| 226 }; | 259 }; |
| 227 | 260 |
| 228 } // namespace chromeos | 261 } // namespace chromeos |
| 229 | 262 |
| 230 #endif // CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_ACCESSIBILITY_MANAGER_H_ | 263 #endif // CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_ACCESSIBILITY_MANAGER_H_ |
| OLD | NEW |