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" | |
11 #include "ash/session/session_state_observer.h" | |
12 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
13 #include "base/callback_list.h" | 11 #include "base/callback_list.h" |
14 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
15 #include "base/prefs/pref_change_registrar.h" | 13 #include "base/prefs/pref_change_registrar.h" |
16 #include "base/scoped_observer.h" | 14 #include "base/scoped_observer.h" |
17 #include "base/time/time.h" | 15 #include "base/time/time.h" |
18 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" | 16 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" |
19 #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" |
20 #include "chromeos/ime/input_method_manager.h" | 18 #include "chromeos/ime/input_method_manager.h" |
21 #include "content/public/browser/notification_observer.h" | 19 #include "content/public/browser/notification_observer.h" |
22 #include "content/public/browser/notification_registrar.h" | 20 #include "content/public/browser/notification_registrar.h" |
23 #include "extensions/browser/event_router.h" | 21 #include "extensions/browser/event_router.h" |
24 #include "extensions/browser/extension_system.h" | 22 #include "extensions/browser/extension_system.h" |
| 23 #include "ui/chromeos/accessibility_types.h" |
| 24 |
| 25 #if !defined(USE_ATHENA) |
| 26 #include "ash/session/session_state_observer.h" |
| 27 #endif |
25 | 28 |
26 namespace content { | 29 namespace content { |
27 class RenderViewHost; | 30 class RenderViewHost; |
28 } | 31 } |
29 class Profile; | 32 class Profile; |
30 | 33 |
31 namespace chromeos { | 34 namespace chromeos { |
32 | 35 |
33 enum AccessibilityNotificationType { | 36 enum AccessibilityNotificationType { |
34 ACCESSIBILITY_MANAGER_SHUTDOWN, | 37 ACCESSIBILITY_MANAGER_SHUTDOWN, |
35 ACCESSIBILITY_TOGGLE_HIGH_CONTRAST_MODE, | 38 ACCESSIBILITY_TOGGLE_HIGH_CONTRAST_MODE, |
36 ACCESSIBILITY_TOGGLE_LARGE_CURSOR, | 39 ACCESSIBILITY_TOGGLE_LARGE_CURSOR, |
37 ACCESSIBILITY_TOGGLE_SCREEN_MAGNIFIER, | 40 ACCESSIBILITY_TOGGLE_SCREEN_MAGNIFIER, |
38 ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK, | 41 ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK, |
39 ACCESSIBILITY_TOGGLE_VIRTUAL_KEYBOARD, | 42 ACCESSIBILITY_TOGGLE_VIRTUAL_KEYBOARD, |
40 ACCESSIBILITY_BRAILLE_DISPLAY_CONNECTION_STATE_CHANGED | 43 ACCESSIBILITY_BRAILLE_DISPLAY_CONNECTION_STATE_CHANGED |
41 }; | 44 }; |
42 | 45 |
43 struct AccessibilityStatusEventDetails { | 46 struct AccessibilityStatusEventDetails { |
44 AccessibilityStatusEventDetails( | 47 AccessibilityStatusEventDetails( |
45 AccessibilityNotificationType notification_type, | 48 AccessibilityNotificationType notification_type, |
46 bool enabled, | 49 bool enabled, |
47 ash::AccessibilityNotificationVisibility notify); | 50 ui::AccessibilityNotificationVisibility notify); |
48 | 51 |
49 AccessibilityStatusEventDetails( | 52 AccessibilityStatusEventDetails( |
50 AccessibilityNotificationType notification_type, | 53 AccessibilityNotificationType notification_type, |
51 bool enabled, | 54 bool enabled, |
52 ash::MagnifierType magnifier_type, | 55 ui::MagnifierType magnifier_type, |
53 ash::AccessibilityNotificationVisibility notify); | 56 ui::AccessibilityNotificationVisibility notify); |
54 | 57 |
55 AccessibilityNotificationType notification_type; | 58 AccessibilityNotificationType notification_type; |
56 bool enabled; | 59 bool enabled; |
57 ash::MagnifierType magnifier_type; | 60 ui::MagnifierType magnifier_type; |
58 ash::AccessibilityNotificationVisibility notify; | 61 ui::AccessibilityNotificationVisibility notify; |
59 }; | 62 }; |
60 | 63 |
61 typedef base::Callback<void(const AccessibilityStatusEventDetails&)> | 64 typedef base::Callback<void(const AccessibilityStatusEventDetails&)> |
62 AccessibilityStatusCallback; | 65 AccessibilityStatusCallback; |
63 | 66 |
64 typedef base::CallbackList<void(const AccessibilityStatusEventDetails&)> | 67 typedef base::CallbackList<void(const AccessibilityStatusEventDetails&)> |
65 AccessibilityStatusCallbackList; | 68 AccessibilityStatusCallbackList; |
66 | 69 |
67 typedef AccessibilityStatusCallbackList::Subscription | 70 typedef AccessibilityStatusCallbackList::Subscription |
68 AccessibilityStatusSubscription; | 71 AccessibilityStatusSubscription; |
69 | 72 |
70 // AccessibilityManager changes the statuses of accessibility features | 73 // AccessibilityManager changes the statuses of accessibility features |
71 // watching profile notifications and pref-changes. | 74 // watching profile notifications and pref-changes. |
72 // TODO(yoshiki): merge MagnificationManager with AccessibilityManager. | 75 // TODO(yoshiki): merge MagnificationManager with AccessibilityManager. |
73 class AccessibilityManager | 76 class AccessibilityManager |
74 : public content::NotificationObserver, | 77 : public content::NotificationObserver, |
75 public extensions::api::braille_display_private::BrailleObserver, | 78 public extensions::api::braille_display_private::BrailleObserver, |
76 public input_method::InputMethodManager::Observer, | 79 #if !defined(USE_ATHENA) |
77 public ash::SessionStateObserver { | 80 public ash::SessionStateObserver, |
| 81 #endif |
| 82 public input_method::InputMethodManager::Observer { |
78 public: | 83 public: |
79 // Creates an instance of AccessibilityManager, this should be called once, | 84 // Creates an instance of AccessibilityManager, this should be called once, |
80 // because only one instance should exist at the same time. | 85 // because only one instance should exist at the same time. |
81 static void Initialize(); | 86 static void Initialize(); |
82 // Deletes the existing instance of AccessibilityManager. | 87 // Deletes the existing instance of AccessibilityManager. |
83 static void Shutdown(); | 88 static void Shutdown(); |
84 // Returns the existing instance. If there is no instance, returns NULL. | 89 // Returns the existing instance. If there is no instance, returns NULL. |
85 static AccessibilityManager* Get(); | 90 static AccessibilityManager* Get(); |
86 | 91 |
87 // On a user's first login into a device, any a11y features enabled/disabled | 92 // On a user's first login into a device, any a11y features enabled/disabled |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 | 124 |
120 // Returns true if Incognito mode is allowed, or false if not. | 125 // Returns true if Incognito mode is allowed, or false if not. |
121 bool IsIncognitoAllowed(); | 126 bool IsIncognitoAllowed(); |
122 | 127 |
123 // Returns true if the Sticky Keys is enabled, or false if not. | 128 // Returns true if the Sticky Keys is enabled, or false if not. |
124 bool IsStickyKeysEnabled(); | 129 bool IsStickyKeysEnabled(); |
125 | 130 |
126 // Enables or disables spoken feedback. Enabling spoken feedback installs the | 131 // Enables or disables spoken feedback. Enabling spoken feedback installs the |
127 // ChromeVox component extension. | 132 // ChromeVox component extension. |
128 void EnableSpokenFeedback(bool enabled, | 133 void EnableSpokenFeedback(bool enabled, |
129 ash::AccessibilityNotificationVisibility notify); | 134 ui::AccessibilityNotificationVisibility notify); |
130 | 135 |
131 // Returns true if spoken feedback is enabled, or false if not. | 136 // Returns true if spoken feedback is enabled, or false if not. |
132 bool IsSpokenFeedbackEnabled(); | 137 bool IsSpokenFeedbackEnabled(); |
133 | 138 |
134 // Toggles whether Chrome OS spoken feedback is on or off. | 139 // Toggles whether Chrome OS spoken feedback is on or off. |
135 void ToggleSpokenFeedback(ash::AccessibilityNotificationVisibility notify); | 140 void ToggleSpokenFeedback(ui::AccessibilityNotificationVisibility notify); |
136 | 141 |
137 // Enables or disables the high contrast mode for Chrome. | 142 // Enables or disables the high contrast mode for Chrome. |
138 void EnableHighContrast(bool enabled); | 143 void EnableHighContrast(bool enabled); |
139 | 144 |
140 // Returns true if High Contrast is enabled, or false if not. | 145 // Returns true if High Contrast is enabled, or false if not. |
141 bool IsHighContrastEnabled(); | 146 bool IsHighContrastEnabled(); |
142 | 147 |
143 // Enables or disables autoclick. | 148 // Enables or disables autoclick. |
144 void EnableAutoclick(bool enabled); | 149 void EnableAutoclick(bool enabled); |
145 | 150 |
146 // Returns true if autoclick is enabled. | 151 // Returns true if autoclick is enabled. |
147 bool IsAutoclickEnabled(); | 152 bool IsAutoclickEnabled(); |
148 | 153 |
149 // Set the delay for autoclicking after stopping the cursor in milliseconds. | 154 // Set the delay for autoclicking after stopping the cursor in milliseconds. |
150 void SetAutoclickDelay(int delay_ms); | 155 void SetAutoclickDelay(int delay_ms); |
151 | 156 |
152 // Returns the autoclick delay in milliseconds. | 157 // Returns the autoclick delay in milliseconds. |
153 int GetAutoclickDelay() const; | 158 int GetAutoclickDelay() const; |
154 | 159 |
155 // Enables or disables the virtual keyboard. | 160 // Enables or disables the virtual keyboard. |
156 void EnableVirtualKeyboard(bool enabled); | 161 void EnableVirtualKeyboard(bool enabled); |
157 // Returns true if the virtual keyboard is enabled, otherwise false. | 162 // Returns true if the virtual keyboard is enabled, otherwise false. |
158 bool IsVirtualKeyboardEnabled(); | 163 bool IsVirtualKeyboardEnabled(); |
159 | 164 |
160 // Returns true if a braille display is connected to the system, otherwise | 165 // Returns true if a braille display is connected to the system, otherwise |
161 // false. | 166 // false. |
162 bool IsBrailleDisplayConnected() const; | 167 bool IsBrailleDisplayConnected() const; |
163 | 168 |
| 169 #if !defined(USE_ATHENA) |
164 // SessionStateObserver overrides: | 170 // SessionStateObserver overrides: |
165 virtual void ActiveUserChanged(const std::string& user_id) override; | 171 virtual void ActiveUserChanged(const std::string& user_id) override; |
| 172 #endif |
166 | 173 |
167 void SetProfileForTest(Profile* profile); | 174 void SetProfileForTest(Profile* profile); |
168 | 175 |
169 static void SetBrailleControllerForTest( | 176 static void SetBrailleControllerForTest( |
170 extensions::api::braille_display_private::BrailleController* controller); | 177 extensions::api::braille_display_private::BrailleController* controller); |
171 | 178 |
172 // Enables/disables system sounds. | 179 // Enables/disables system sounds. |
173 void EnableSystemSounds(bool system_sounds_enabled); | 180 void EnableSystemSounds(bool system_sounds_enabled); |
174 | 181 |
175 // Initiates play of shutdown sound and returns it's duration. | 182 // Initiates play of shutdown sound and returns it's duration. |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 Profile* profile_; | 254 Profile* profile_; |
248 | 255 |
249 // Profile which ChromeVox is currently loaded to. If NULL, ChromeVox is not | 256 // Profile which ChromeVox is currently loaded to. If NULL, ChromeVox is not |
250 // loaded to any profile. | 257 // loaded to any profile. |
251 bool chrome_vox_loaded_on_lock_screen_; | 258 bool chrome_vox_loaded_on_lock_screen_; |
252 bool chrome_vox_loaded_on_user_screen_; | 259 bool chrome_vox_loaded_on_user_screen_; |
253 | 260 |
254 content::NotificationRegistrar notification_registrar_; | 261 content::NotificationRegistrar notification_registrar_; |
255 scoped_ptr<PrefChangeRegistrar> pref_change_registrar_; | 262 scoped_ptr<PrefChangeRegistrar> pref_change_registrar_; |
256 scoped_ptr<PrefChangeRegistrar> local_state_pref_change_registrar_; | 263 scoped_ptr<PrefChangeRegistrar> local_state_pref_change_registrar_; |
| 264 #if !defined(USE_ATHENA) |
257 scoped_ptr<ash::ScopedSessionStateObserver> session_state_observer_; | 265 scoped_ptr<ash::ScopedSessionStateObserver> session_state_observer_; |
| 266 #endif |
258 | 267 |
259 PrefHandler large_cursor_pref_handler_; | 268 PrefHandler large_cursor_pref_handler_; |
260 PrefHandler spoken_feedback_pref_handler_; | 269 PrefHandler spoken_feedback_pref_handler_; |
261 PrefHandler high_contrast_pref_handler_; | 270 PrefHandler high_contrast_pref_handler_; |
262 PrefHandler autoclick_pref_handler_; | 271 PrefHandler autoclick_pref_handler_; |
263 PrefHandler autoclick_delay_pref_handler_; | 272 PrefHandler autoclick_delay_pref_handler_; |
264 PrefHandler virtual_keyboard_pref_handler_; | 273 PrefHandler virtual_keyboard_pref_handler_; |
265 | 274 |
266 bool large_cursor_enabled_; | 275 bool large_cursor_enabled_; |
267 bool sticky_keys_enabled_; | 276 bool sticky_keys_enabled_; |
268 bool spoken_feedback_enabled_; | 277 bool spoken_feedback_enabled_; |
269 bool high_contrast_enabled_; | 278 bool high_contrast_enabled_; |
270 bool autoclick_enabled_; | 279 bool autoclick_enabled_; |
271 int autoclick_delay_ms_; | 280 int autoclick_delay_ms_; |
272 bool virtual_keyboard_enabled_; | 281 bool virtual_keyboard_enabled_; |
273 | 282 |
274 ash::AccessibilityNotificationVisibility spoken_feedback_notification_; | 283 ui::AccessibilityNotificationVisibility spoken_feedback_notification_; |
275 | 284 |
276 bool should_speak_chrome_vox_announcements_on_user_screen_; | 285 bool should_speak_chrome_vox_announcements_on_user_screen_; |
277 | 286 |
278 bool system_sounds_enabled_; | 287 bool system_sounds_enabled_; |
279 | 288 |
280 AccessibilityStatusCallbackList callback_list_; | 289 AccessibilityStatusCallbackList callback_list_; |
281 | 290 |
282 bool braille_display_connected_; | 291 bool braille_display_connected_; |
283 ScopedObserver<extensions::api::braille_display_private::BrailleController, | 292 ScopedObserver<extensions::api::braille_display_private::BrailleController, |
284 AccessibilityManager> scoped_braille_observer_; | 293 AccessibilityManager> scoped_braille_observer_; |
285 | 294 |
286 bool braille_ime_current_; | 295 bool braille_ime_current_; |
287 | 296 |
288 base::WeakPtrFactory<AccessibilityManager> weak_ptr_factory_; | 297 base::WeakPtrFactory<AccessibilityManager> weak_ptr_factory_; |
289 | 298 |
290 DISALLOW_COPY_AND_ASSIGN(AccessibilityManager); | 299 DISALLOW_COPY_AND_ASSIGN(AccessibilityManager); |
291 }; | 300 }; |
292 | 301 |
293 } // namespace chromeos | 302 } // namespace chromeos |
294 | 303 |
295 #endif // CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_ACCESSIBILITY_MANAGER_H_ | 304 #endif // CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_ACCESSIBILITY_MANAGER_H_ |
OLD | NEW |