Chromium Code Reviews| 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 "ash/accessibility_delegate.h" | 8 #include "ash/accessibility_delegate.h" |
| 9 #include "ash/session_state_observer.h" | |
| 9 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 10 #include "base/prefs/pref_change_registrar.h" | 11 #include "base/prefs/pref_change_registrar.h" |
| 11 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 12 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" | 13 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" |
| 13 #include "chrome/browser/extensions/api/braille_display_private/braille_controll er.h" | 14 #include "chrome/browser/extensions/api/braille_display_private/braille_controll er.h" |
| 14 #include "chrome/browser/extensions/extension_system.h" | 15 #include "chrome/browser/extensions/extension_system.h" |
| 15 #include "content/public/browser/notification_observer.h" | 16 #include "content/public/browser/notification_observer.h" |
| 16 #include "content/public/browser/notification_registrar.h" | 17 #include "content/public/browser/notification_registrar.h" |
| 17 #include "extensions/browser/event_router.h" | 18 #include "extensions/browser/event_router.h" |
| 18 | 19 |
| 19 class Profile; | 20 class Profile; |
| 20 | 21 |
| 21 namespace chromeos { | 22 namespace chromeos { |
| 22 | 23 |
| 23 struct AccessibilityStatusEventDetails { | 24 struct AccessibilityStatusEventDetails { |
| 24 AccessibilityStatusEventDetails( | 25 AccessibilityStatusEventDetails( |
| 25 bool enabled, | 26 bool enabled, |
| 26 ash::AccessibilityNotificationVisibility notify); | 27 ash::AccessibilityNotificationVisibility notify); |
| 27 | 28 |
| 28 AccessibilityStatusEventDetails( | 29 AccessibilityStatusEventDetails( |
| 29 bool enabled, | 30 bool enabled, |
| 30 ash::MagnifierType magnifier_type, | 31 ash::MagnifierType magnifier_type, |
| 31 ash::AccessibilityNotificationVisibility notify); | 32 ash::AccessibilityNotificationVisibility notify); |
| 32 | 33 |
| 33 bool enabled; | 34 bool enabled; |
| 34 ash::MagnifierType magnifier_type; | 35 ash::MagnifierType magnifier_type; |
| 35 ash::AccessibilityNotificationVisibility notify; | 36 ash::AccessibilityNotificationVisibility notify; |
| 36 }; | 37 }; |
| 37 | 38 |
| 39 // A class to attach / detach an object as a session state observer with a | |
| 40 // scoped pointer. | |
| 41 class ScopedSessionStateObserver { | |
|
dmazzoni
2013/12/13 17:30:07
Could you move this to session_state_observer.h?
Mr4D (OOO till 08-26)
2013/12/13 17:58:33
Done.
| |
| 42 public: | |
| 43 explicit ScopedSessionStateObserver(ash::SessionStateObserver* observer); | |
| 44 virtual ~ScopedSessionStateObserver(); | |
| 45 | |
| 46 private: | |
| 47 ash::SessionStateObserver* observer_; | |
| 48 | |
| 49 DISALLOW_COPY_AND_ASSIGN(ScopedSessionStateObserver); | |
| 50 }; | |
| 51 | |
| 38 // AccessibilityManager changes the statuses of accessibility features | 52 // AccessibilityManager changes the statuses of accessibility features |
| 39 // watching profile notifications and pref-changes. | 53 // watching profile notifications and pref-changes. |
| 40 // TODO(yoshiki): merge MagnificationManager with AccessibilityManager. | 54 // TODO(yoshiki): merge MagnificationManager with AccessibilityManager. |
| 41 class AccessibilityManager : public content::NotificationObserver, | 55 class AccessibilityManager : public content::NotificationObserver, |
| 42 public extensions::EventRouter::Observer, | 56 public extensions::EventRouter::Observer, |
| 43 extensions::api::braille_display_private::BrailleObserver { | 57 extensions::api::braille_display_private::BrailleObserver, |
| 58 public ash::SessionStateObserver { | |
| 44 public: | 59 public: |
| 45 // Creates an instance of AccessibilityManager, this should be called once, | 60 // Creates an instance of AccessibilityManager, this should be called once, |
| 46 // because only one instance should exist at the same time. | 61 // because only one instance should exist at the same time. |
| 47 static void Initialize(); | 62 static void Initialize(); |
| 48 // Deletes the existing instance of AccessibilityManager. | 63 // Deletes the existing instance of AccessibilityManager. |
| 49 static void Shutdown(); | 64 static void Shutdown(); |
| 50 // Returns the existing instance. If there is no instance, returns NULL. | 65 // Returns the existing instance. If there is no instance, returns NULL. |
| 51 static AccessibilityManager* Get(); | 66 static AccessibilityManager* Get(); |
| 52 | 67 |
| 53 // On a user's first login into a device, any a11y features enabled/disabled | 68 // On a user's first login into a device, any a11y features enabled/disabled |
| 54 // by the user on the login screen are enabled/disabled in the user's profile. | 69 // by the user on the login screen are enabled/disabled in the user's profile. |
| 55 // This class watches for profile changes and copies settings into the user's | 70 // This class watches for profile changes and copies settings into the user's |
| 56 // profile when it detects a login with a newly created profile. | 71 // profile when it detects a login with a newly created profile. |
| 57 class PrefHandler { | 72 class PrefHandler { |
| 58 public: | 73 public: |
| 59 explicit PrefHandler(const char* pref_path); | 74 explicit PrefHandler(const char* pref_path); |
| 60 virtual ~PrefHandler(); | 75 virtual ~PrefHandler(); |
| 61 | 76 |
| 62 // Should be called from AccessibilityManager::SetProfile(). | 77 // Should be called from AccessibilityManager::SetProfile(). |
| 63 void HandleProfileChanged(Profile* previous_profile, | 78 void HandleProfileChanged(Profile* previous_profile, |
| 64 Profile* current_profile); | 79 Profile* current_profile); |
| 65 | 80 |
| 66 private: | 81 private: |
| 67 const char* pref_path_; | 82 const char* pref_path_; |
| 68 }; | 83 }; |
| 69 | 84 |
| 85 // Returns true when the accessibility menu should be shown. | |
| 86 bool ShouldShowAccessibilityMenu(); | |
| 87 | |
| 70 // Enables or disables the large cursor. | 88 // Enables or disables the large cursor. |
| 71 void EnableLargeCursor(bool enabled); | 89 void EnableLargeCursor(bool enabled); |
| 72 // Returns true if the large cursor is enabled, or false if not. | 90 // Returns true if the large cursor is enabled, or false if not. |
| 73 bool IsLargeCursorEnabled(); | 91 bool IsLargeCursorEnabled(); |
| 74 | 92 |
| 75 // Enables or disable Sticky Keys. | 93 // Enables or disable Sticky Keys. |
| 76 void EnableStickyKeys(bool enabled); | 94 void EnableStickyKeys(bool enabled); |
| 77 | 95 |
| 78 // Returns true if Incognito mode is allowed, or false if not. | 96 // Returns true if Incognito mode is allowed, or false if not. |
| 79 bool IsIncognitoAllowed(); | 97 bool IsIncognitoAllowed(); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 103 | 121 |
| 104 // Returns true if autoclick is enabled. | 122 // Returns true if autoclick is enabled. |
| 105 bool IsAutoclickEnabled(); | 123 bool IsAutoclickEnabled(); |
| 106 | 124 |
| 107 // Set the delay for autoclicking after stopping the cursor in milliseconds. | 125 // Set the delay for autoclicking after stopping the cursor in milliseconds. |
| 108 void SetAutoclickDelay(int delay_ms); | 126 void SetAutoclickDelay(int delay_ms); |
| 109 | 127 |
| 110 // Returns the autoclick delay in milliseconds. | 128 // Returns the autoclick delay in milliseconds. |
| 111 int GetAutoclickDelay() const; | 129 int GetAutoclickDelay() const; |
| 112 | 130 |
| 131 // SessionStateObserver overrides: | |
| 132 virtual void ActiveUserChanged(const std::string& user_id) OVERRIDE; | |
| 133 | |
| 113 void SetProfileForTest(Profile* profile); | 134 void SetProfileForTest(Profile* profile); |
| 114 | 135 |
| 115 static void SetBrailleControllerForTest( | 136 static void SetBrailleControllerForTest( |
| 116 extensions::api::braille_display_private::BrailleController* controller); | 137 extensions::api::braille_display_private::BrailleController* controller); |
| 117 | 138 |
| 118 // Enables/disables system sounds. | 139 // Enables/disables system sounds. |
| 119 void EnableSystemSounds(bool system_sounds_enabled); | 140 void EnableSystemSounds(bool system_sounds_enabled); |
| 120 | 141 |
| 121 // Initiates play of shutdown sound and returns it's duration. | 142 // Initiates play of shutdown sound and returns it's duration. |
| 122 base::TimeDelta PlayShutdownSound(); | 143 base::TimeDelta PlayShutdownSound(); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 178 Profile* profile_; | 199 Profile* profile_; |
| 179 | 200 |
| 180 // Profile which ChromeVox is currently loaded to. If NULL, ChromeVox is not | 201 // Profile which ChromeVox is currently loaded to. If NULL, ChromeVox is not |
| 181 // loaded to any profile. | 202 // loaded to any profile. |
| 182 bool chrome_vox_loaded_on_lock_screen_; | 203 bool chrome_vox_loaded_on_lock_screen_; |
| 183 bool chrome_vox_loaded_on_user_screen_; | 204 bool chrome_vox_loaded_on_user_screen_; |
| 184 | 205 |
| 185 content::NotificationRegistrar notification_registrar_; | 206 content::NotificationRegistrar notification_registrar_; |
| 186 scoped_ptr<PrefChangeRegistrar> pref_change_registrar_; | 207 scoped_ptr<PrefChangeRegistrar> pref_change_registrar_; |
| 187 scoped_ptr<PrefChangeRegistrar> local_state_pref_change_registrar_; | 208 scoped_ptr<PrefChangeRegistrar> local_state_pref_change_registrar_; |
| 209 scoped_ptr<ScopedSessionStateObserver> session_state_observer_; | |
| 188 | 210 |
| 189 PrefHandler large_cursor_pref_handler_; | 211 PrefHandler large_cursor_pref_handler_; |
| 190 PrefHandler spoken_feedback_pref_handler_; | 212 PrefHandler spoken_feedback_pref_handler_; |
| 191 PrefHandler high_contrast_pref_handler_; | 213 PrefHandler high_contrast_pref_handler_; |
| 192 PrefHandler autoclick_pref_handler_; | 214 PrefHandler autoclick_pref_handler_; |
| 193 PrefHandler autoclick_delay_pref_handler_; | 215 PrefHandler autoclick_delay_pref_handler_; |
| 194 | 216 |
| 195 bool large_cursor_enabled_; | 217 bool large_cursor_enabled_; |
| 196 bool sticky_keys_enabled_; | 218 bool sticky_keys_enabled_; |
| 197 bool spoken_feedback_enabled_; | 219 bool spoken_feedback_enabled_; |
| 198 bool high_contrast_enabled_; | 220 bool high_contrast_enabled_; |
| 199 bool autoclick_enabled_; | 221 bool autoclick_enabled_; |
| 200 int autoclick_delay_ms_; | 222 int autoclick_delay_ms_; |
| 201 | 223 |
| 202 ash::AccessibilityNotificationVisibility spoken_feedback_notification_; | 224 ash::AccessibilityNotificationVisibility spoken_feedback_notification_; |
| 203 | 225 |
| 204 base::WeakPtrFactory<AccessibilityManager> weak_ptr_factory_; | 226 base::WeakPtrFactory<AccessibilityManager> weak_ptr_factory_; |
| 205 | 227 |
| 206 bool should_speak_chrome_vox_announcements_on_user_screen_; | 228 bool should_speak_chrome_vox_announcements_on_user_screen_; |
| 207 | 229 |
| 208 bool system_sounds_enabled_; | 230 bool system_sounds_enabled_; |
| 209 | 231 |
| 210 DISALLOW_COPY_AND_ASSIGN(AccessibilityManager); | 232 DISALLOW_COPY_AND_ASSIGN(AccessibilityManager); |
| 211 }; | 233 }; |
| 212 | 234 |
| 213 } // namespace chromeos | 235 } // namespace chromeos |
| 214 | 236 |
| 215 #endif // CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_ACCESSIBILITY_MANAGER_H_ | 237 #endif // CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_ACCESSIBILITY_MANAGER_H_ |
| OLD | NEW |