| 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 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" | 5 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 #include "chrome/browser/extensions/tab_helper.h" | 46 #include "chrome/browser/extensions/tab_helper.h" |
| 47 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 47 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 48 #include "chrome/browser/profiles/profile.h" | 48 #include "chrome/browser/profiles/profile.h" |
| 49 #include "chrome/browser/profiles/profile_manager.h" | 49 #include "chrome/browser/profiles/profile_manager.h" |
| 50 #include "chrome/common/chrome_paths.h" | 50 #include "chrome/common/chrome_paths.h" |
| 51 #include "chrome/common/extensions/api/accessibility_private.h" | 51 #include "chrome/common/extensions/api/accessibility_private.h" |
| 52 #include "chrome/common/extensions/extension_constants.h" | 52 #include "chrome/common/extensions/extension_constants.h" |
| 53 #include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h" | 53 #include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h" |
| 54 #include "chrome/common/pref_names.h" | 54 #include "chrome/common/pref_names.h" |
| 55 #include "chrome/grit/browser_resources.h" | 55 #include "chrome/grit/browser_resources.h" |
| 56 #include "chromeos/audio/audio_a11y_controller.h" |
| 56 #include "chromeos/audio/chromeos_sounds.h" | 57 #include "chromeos/audio/chromeos_sounds.h" |
| 57 #include "chromeos/login/login_state.h" | 58 #include "chromeos/login/login_state.h" |
| 58 #include "components/prefs/pref_member.h" | 59 #include "components/prefs/pref_member.h" |
| 59 #include "components/prefs/pref_service.h" | 60 #include "components/prefs/pref_service.h" |
| 60 #include "components/user_manager/user_manager.h" | 61 #include "components/user_manager/user_manager.h" |
| 61 #include "content/public/browser/browser_accessibility_state.h" | 62 #include "content/public/browser/browser_accessibility_state.h" |
| 62 #include "content/public/browser/browser_thread.h" | 63 #include "content/public/browser/browser_thread.h" |
| 63 #include "content/public/browser/notification_details.h" | 64 #include "content/public/browser/notification_details.h" |
| 64 #include "content/public/browser/notification_service.h" | 65 #include "content/public/browser/notification_service.h" |
| 65 #include "content/public/browser/notification_source.h" | 66 #include "content/public/browser/notification_source.h" |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 : profile_(NULL), | 394 : profile_(NULL), |
| 394 chrome_vox_loaded_on_lock_screen_(false), | 395 chrome_vox_loaded_on_lock_screen_(false), |
| 395 chrome_vox_loaded_on_user_screen_(false), | 396 chrome_vox_loaded_on_user_screen_(false), |
| 396 large_cursor_pref_handler_(prefs::kAccessibilityLargeCursorEnabled), | 397 large_cursor_pref_handler_(prefs::kAccessibilityLargeCursorEnabled), |
| 397 spoken_feedback_pref_handler_(prefs::kAccessibilitySpokenFeedbackEnabled), | 398 spoken_feedback_pref_handler_(prefs::kAccessibilitySpokenFeedbackEnabled), |
| 398 high_contrast_pref_handler_(prefs::kAccessibilityHighContrastEnabled), | 399 high_contrast_pref_handler_(prefs::kAccessibilityHighContrastEnabled), |
| 399 autoclick_pref_handler_(prefs::kAccessibilityAutoclickEnabled), | 400 autoclick_pref_handler_(prefs::kAccessibilityAutoclickEnabled), |
| 400 autoclick_delay_pref_handler_(prefs::kAccessibilityAutoclickDelayMs), | 401 autoclick_delay_pref_handler_(prefs::kAccessibilityAutoclickDelayMs), |
| 401 virtual_keyboard_pref_handler_( | 402 virtual_keyboard_pref_handler_( |
| 402 prefs::kAccessibilityVirtualKeyboardEnabled), | 403 prefs::kAccessibilityVirtualKeyboardEnabled), |
| 404 mono_audio_pref_handler_( |
| 405 prefs::kAccessibilityMonoAudioEnabled), |
| 403 caret_highlight_pref_handler_(prefs::kAccessibilityCaretHighlightEnabled), | 406 caret_highlight_pref_handler_(prefs::kAccessibilityCaretHighlightEnabled), |
| 404 cursor_highlight_pref_handler_( | 407 cursor_highlight_pref_handler_( |
| 405 prefs::kAccessibilityCursorHighlightEnabled), | 408 prefs::kAccessibilityCursorHighlightEnabled), |
| 406 focus_highlight_pref_handler_(prefs::kAccessibilityFocusHighlightEnabled), | 409 focus_highlight_pref_handler_(prefs::kAccessibilityFocusHighlightEnabled), |
| 407 select_to_speak_pref_handler_(prefs::kAccessibilitySelectToSpeakEnabled), | 410 select_to_speak_pref_handler_(prefs::kAccessibilitySelectToSpeakEnabled), |
| 408 switch_access_pref_handler_(prefs::kAccessibilitySwitchAccessEnabled), | 411 switch_access_pref_handler_(prefs::kAccessibilitySwitchAccessEnabled), |
| 409 large_cursor_enabled_(false), | 412 large_cursor_enabled_(false), |
| 410 sticky_keys_enabled_(false), | 413 sticky_keys_enabled_(false), |
| 411 spoken_feedback_enabled_(false), | 414 spoken_feedback_enabled_(false), |
| 412 high_contrast_enabled_(false), | 415 high_contrast_enabled_(false), |
| 413 autoclick_enabled_(false), | 416 autoclick_enabled_(false), |
| 414 autoclick_delay_ms_(ash::AutoclickController::kDefaultAutoclickDelayMs), | 417 autoclick_delay_ms_(ash::AutoclickController::kDefaultAutoclickDelayMs), |
| 415 virtual_keyboard_enabled_(false), | 418 virtual_keyboard_enabled_(false), |
| 419 mono_audio_enabled_(false), |
| 416 caret_highlight_enabled_(false), | 420 caret_highlight_enabled_(false), |
| 417 cursor_highlight_enabled_(false), | 421 cursor_highlight_enabled_(false), |
| 418 focus_highlight_enabled_(false), | 422 focus_highlight_enabled_(false), |
| 419 select_to_speak_enabled_(false), | 423 select_to_speak_enabled_(false), |
| 420 switch_access_enabled_(false), | 424 switch_access_enabled_(false), |
| 421 spoken_feedback_notification_(ui::A11Y_NOTIFICATION_NONE), | 425 spoken_feedback_notification_(ui::A11Y_NOTIFICATION_NONE), |
| 422 should_speak_chrome_vox_announcements_on_user_screen_(true), | 426 should_speak_chrome_vox_announcements_on_user_screen_(true), |
| 423 system_sounds_enabled_(false), | 427 system_sounds_enabled_(false), |
| 424 braille_display_connected_(false), | 428 braille_display_connected_(false), |
| 425 scoped_braille_observer_(this), | 429 scoped_braille_observer_(this), |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 it != profiles.end(); | 488 it != profiles.end(); |
| 485 ++it) { | 489 ++it) { |
| 486 PrefService* pref_service = (*it)->GetPrefs(); | 490 PrefService* pref_service = (*it)->GetPrefs(); |
| 487 if (pref_service->GetBoolean(prefs::kAccessibilityStickyKeysEnabled) || | 491 if (pref_service->GetBoolean(prefs::kAccessibilityStickyKeysEnabled) || |
| 488 pref_service->GetBoolean(prefs::kAccessibilityLargeCursorEnabled) || | 492 pref_service->GetBoolean(prefs::kAccessibilityLargeCursorEnabled) || |
| 489 pref_service->GetBoolean(prefs::kAccessibilitySpokenFeedbackEnabled) || | 493 pref_service->GetBoolean(prefs::kAccessibilitySpokenFeedbackEnabled) || |
| 490 pref_service->GetBoolean(prefs::kAccessibilityHighContrastEnabled) || | 494 pref_service->GetBoolean(prefs::kAccessibilityHighContrastEnabled) || |
| 491 pref_service->GetBoolean(prefs::kAccessibilityAutoclickEnabled) || | 495 pref_service->GetBoolean(prefs::kAccessibilityAutoclickEnabled) || |
| 492 pref_service->GetBoolean(prefs::kShouldAlwaysShowAccessibilityMenu) || | 496 pref_service->GetBoolean(prefs::kShouldAlwaysShowAccessibilityMenu) || |
| 493 pref_service->GetBoolean(prefs::kAccessibilityScreenMagnifierEnabled) || | 497 pref_service->GetBoolean(prefs::kAccessibilityScreenMagnifierEnabled) || |
| 494 pref_service->GetBoolean(prefs::kAccessibilityVirtualKeyboardEnabled)) | 498 pref_service->GetBoolean(prefs::kAccessibilityVirtualKeyboardEnabled) || |
| 499 pref_service->GetBoolean(prefs::kAccessibilityMonoAudioEnabled)) |
| 495 return true; | 500 return true; |
| 496 } | 501 } |
| 497 return false; | 502 return false; |
| 498 } | 503 } |
| 499 | 504 |
| 500 bool AccessibilityManager::ShouldEnableCursorCompositing() { | 505 bool AccessibilityManager::ShouldEnableCursorCompositing() { |
| 501 if (!profile_) | 506 if (!profile_) |
| 502 return false; | 507 return false; |
| 503 PrefService* pref_service = profile_->GetPrefs(); | 508 PrefService* pref_service = profile_->GetPrefs(); |
| 504 // Enable cursor compositing when one or more of the listed accessibility | 509 // Enable cursor compositing when one or more of the listed accessibility |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 871 else | 876 else |
| 872 ash::Shell::GetInstance()->DeactivateKeyboard(); | 877 ash::Shell::GetInstance()->DeactivateKeyboard(); |
| 873 | 878 |
| 874 AccessibilityStatusEventDetails details( | 879 AccessibilityStatusEventDetails details( |
| 875 ACCESSIBILITY_TOGGLE_VIRTUAL_KEYBOARD, | 880 ACCESSIBILITY_TOGGLE_VIRTUAL_KEYBOARD, |
| 876 enabled, | 881 enabled, |
| 877 ui::A11Y_NOTIFICATION_NONE); | 882 ui::A11Y_NOTIFICATION_NONE); |
| 878 NotifyAccessibilityStatusChanged(details); | 883 NotifyAccessibilityStatusChanged(details); |
| 879 } | 884 } |
| 880 | 885 |
| 886 void AccessibilityManager::EnableMonoAudio(bool enabled) { |
| 887 if (!profile_) |
| 888 return; |
| 889 |
| 890 PrefService* pref_service = profile_->GetPrefs(); |
| 891 pref_service->SetBoolean(prefs::kAccessibilityMonoAudioEnabled, |
| 892 enabled); |
| 893 pref_service->CommitPendingWrite(); |
| 894 } |
| 895 |
| 896 bool AccessibilityManager::IsMonoAudioEnabled() { |
| 897 return mono_audio_enabled_; |
| 898 } |
| 899 |
| 900 void AccessibilityManager::UpdateMonoAudioFromPref() { |
| 901 if (!profile_) |
| 902 return; |
| 903 |
| 904 const bool enabled = profile_->GetPrefs()->GetBoolean( |
| 905 prefs::kAccessibilityMonoAudioEnabled); |
| 906 |
| 907 if (mono_audio_enabled_ == enabled) |
| 908 return; |
| 909 mono_audio_enabled_ = enabled; |
| 910 |
| 911 AccessibilityStatusEventDetails details( |
| 912 ACCESSIBILITY_TOGGLE_MONO_AUDIO, |
| 913 enabled, |
| 914 ui::A11Y_NOTIFICATION_NONE); |
| 915 NotifyAccessibilityStatusChanged(details); |
| 916 |
| 917 ash::Shell::GetInstance()->audio_a11y_controller()->SetOutputMono(enabled); |
| 918 } |
| 919 |
| 881 void AccessibilityManager::SetCaretHighlightEnabled(bool enabled) { | 920 void AccessibilityManager::SetCaretHighlightEnabled(bool enabled) { |
| 882 if (!profile_) | 921 if (!profile_) |
| 883 return; | 922 return; |
| 884 | 923 |
| 885 PrefService* pref_service = profile_->GetPrefs(); | 924 PrefService* pref_service = profile_->GetPrefs(); |
| 886 pref_service->SetBoolean(prefs::kAccessibilityCaretHighlightEnabled, enabled); | 925 pref_service->SetBoolean(prefs::kAccessibilityCaretHighlightEnabled, enabled); |
| 887 pref_service->CommitPendingWrite(); | 926 pref_service->CommitPendingWrite(); |
| 888 } | 927 } |
| 889 | 928 |
| 890 bool AccessibilityManager::IsCaretHighlightEnabled() const { | 929 bool AccessibilityManager::IsCaretHighlightEnabled() const { |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1123 base::Unretained(this))); | 1162 base::Unretained(this))); |
| 1124 pref_change_registrar_->Add( | 1163 pref_change_registrar_->Add( |
| 1125 prefs::kAccessibilityAutoclickDelayMs, | 1164 prefs::kAccessibilityAutoclickDelayMs, |
| 1126 base::Bind(&AccessibilityManager::UpdateAutoclickDelayFromPref, | 1165 base::Bind(&AccessibilityManager::UpdateAutoclickDelayFromPref, |
| 1127 base::Unretained(this))); | 1166 base::Unretained(this))); |
| 1128 pref_change_registrar_->Add( | 1167 pref_change_registrar_->Add( |
| 1129 prefs::kAccessibilityVirtualKeyboardEnabled, | 1168 prefs::kAccessibilityVirtualKeyboardEnabled, |
| 1130 base::Bind(&AccessibilityManager::UpdateVirtualKeyboardFromPref, | 1169 base::Bind(&AccessibilityManager::UpdateVirtualKeyboardFromPref, |
| 1131 base::Unretained(this))); | 1170 base::Unretained(this))); |
| 1132 pref_change_registrar_->Add( | 1171 pref_change_registrar_->Add( |
| 1172 prefs::kAccessibilityMonoAudioEnabled, |
| 1173 base::Bind(&AccessibilityManager::UpdateMonoAudioFromPref, |
| 1174 base::Unretained(this))); |
| 1175 pref_change_registrar_->Add( |
| 1133 prefs::kAccessibilityCaretHighlightEnabled, | 1176 prefs::kAccessibilityCaretHighlightEnabled, |
| 1134 base::Bind(&AccessibilityManager::UpdateCaretHighlightFromPref, | 1177 base::Bind(&AccessibilityManager::UpdateCaretHighlightFromPref, |
| 1135 base::Unretained(this))); | 1178 base::Unretained(this))); |
| 1136 pref_change_registrar_->Add( | 1179 pref_change_registrar_->Add( |
| 1137 prefs::kAccessibilityCursorHighlightEnabled, | 1180 prefs::kAccessibilityCursorHighlightEnabled, |
| 1138 base::Bind(&AccessibilityManager::UpdateCursorHighlightFromPref, | 1181 base::Bind(&AccessibilityManager::UpdateCursorHighlightFromPref, |
| 1139 base::Unretained(this))); | 1182 base::Unretained(this))); |
| 1140 pref_change_registrar_->Add( | 1183 pref_change_registrar_->Add( |
| 1141 prefs::kAccessibilityFocusHighlightEnabled, | 1184 prefs::kAccessibilityFocusHighlightEnabled, |
| 1142 base::Bind(&AccessibilityManager::UpdateFocusHighlightFromPref, | 1185 base::Bind(&AccessibilityManager::UpdateFocusHighlightFromPref, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1162 &AccessibilityManager::UpdateChromeOSAccessibilityHistograms, | 1205 &AccessibilityManager::UpdateChromeOSAccessibilityHistograms, |
| 1163 base::Unretained(this))); | 1206 base::Unretained(this))); |
| 1164 } | 1207 } |
| 1165 | 1208 |
| 1166 large_cursor_pref_handler_.HandleProfileChanged(profile_, profile); | 1209 large_cursor_pref_handler_.HandleProfileChanged(profile_, profile); |
| 1167 spoken_feedback_pref_handler_.HandleProfileChanged(profile_, profile); | 1210 spoken_feedback_pref_handler_.HandleProfileChanged(profile_, profile); |
| 1168 high_contrast_pref_handler_.HandleProfileChanged(profile_, profile); | 1211 high_contrast_pref_handler_.HandleProfileChanged(profile_, profile); |
| 1169 autoclick_pref_handler_.HandleProfileChanged(profile_, profile); | 1212 autoclick_pref_handler_.HandleProfileChanged(profile_, profile); |
| 1170 autoclick_delay_pref_handler_.HandleProfileChanged(profile_, profile); | 1213 autoclick_delay_pref_handler_.HandleProfileChanged(profile_, profile); |
| 1171 virtual_keyboard_pref_handler_.HandleProfileChanged(profile_, profile); | 1214 virtual_keyboard_pref_handler_.HandleProfileChanged(profile_, profile); |
| 1215 mono_audio_pref_handler_.HandleProfileChanged(profile_, profile); |
| 1172 caret_highlight_pref_handler_.HandleProfileChanged(profile_, profile); | 1216 caret_highlight_pref_handler_.HandleProfileChanged(profile_, profile); |
| 1173 cursor_highlight_pref_handler_.HandleProfileChanged(profile_, profile); | 1217 cursor_highlight_pref_handler_.HandleProfileChanged(profile_, profile); |
| 1174 focus_highlight_pref_handler_.HandleProfileChanged(profile_, profile); | 1218 focus_highlight_pref_handler_.HandleProfileChanged(profile_, profile); |
| 1175 select_to_speak_pref_handler_.HandleProfileChanged(profile_, profile); | 1219 select_to_speak_pref_handler_.HandleProfileChanged(profile_, profile); |
| 1176 switch_access_pref_handler_.HandleProfileChanged(profile_, profile); | 1220 switch_access_pref_handler_.HandleProfileChanged(profile_, profile); |
| 1177 | 1221 |
| 1178 bool had_profile = (profile_ != NULL); | 1222 bool had_profile = (profile_ != NULL); |
| 1179 profile_ = profile; | 1223 profile_ = profile; |
| 1180 | 1224 |
| 1181 if (!had_profile && profile) | 1225 if (!had_profile && profile) |
| 1182 CheckBrailleState(); | 1226 CheckBrailleState(); |
| 1183 else | 1227 else |
| 1184 UpdateBrailleImeState(); | 1228 UpdateBrailleImeState(); |
| 1185 UpdateLargeCursorFromPref(); | 1229 UpdateLargeCursorFromPref(); |
| 1186 UpdateStickyKeysFromPref(); | 1230 UpdateStickyKeysFromPref(); |
| 1187 UpdateSpokenFeedbackFromPref(); | 1231 UpdateSpokenFeedbackFromPref(); |
| 1188 UpdateHighContrastFromPref(); | 1232 UpdateHighContrastFromPref(); |
| 1189 UpdateAutoclickFromPref(); | 1233 UpdateAutoclickFromPref(); |
| 1190 UpdateAutoclickDelayFromPref(); | 1234 UpdateAutoclickDelayFromPref(); |
| 1191 UpdateVirtualKeyboardFromPref(); | 1235 UpdateVirtualKeyboardFromPref(); |
| 1236 UpdateMonoAudioFromPref(); |
| 1192 UpdateCaretHighlightFromPref(); | 1237 UpdateCaretHighlightFromPref(); |
| 1193 UpdateCursorHighlightFromPref(); | 1238 UpdateCursorHighlightFromPref(); |
| 1194 UpdateFocusHighlightFromPref(); | 1239 UpdateFocusHighlightFromPref(); |
| 1195 UpdateSelectToSpeakFromPref(); | 1240 UpdateSelectToSpeakFromPref(); |
| 1196 UpdateSwitchAccessFromPref(); | 1241 UpdateSwitchAccessFromPref(); |
| 1197 } | 1242 } |
| 1198 | 1243 |
| 1199 void AccessibilityManager::ActiveUserChanged(const AccountId& account_id) { | 1244 void AccessibilityManager::ActiveUserChanged(const AccountId& account_id) { |
| 1200 SetProfile(ProfileManager::GetActiveUserProfile()); | 1245 SetProfile(ProfileManager::GetActiveUserProfile()); |
| 1201 } | 1246 } |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1441 content::BrowserContext* context) { | 1486 content::BrowserContext* context) { |
| 1442 keyboard_listener_extension_id_ = id; | 1487 keyboard_listener_extension_id_ = id; |
| 1443 | 1488 |
| 1444 extensions::ExtensionRegistry* registry = | 1489 extensions::ExtensionRegistry* registry = |
| 1445 extensions::ExtensionRegistry::Get(context); | 1490 extensions::ExtensionRegistry::Get(context); |
| 1446 if (!extension_registry_observer_.IsObserving(registry) && !id.empty()) | 1491 if (!extension_registry_observer_.IsObserving(registry) && !id.empty()) |
| 1447 extension_registry_observer_.Add(registry); | 1492 extension_registry_observer_.Add(registry); |
| 1448 } | 1493 } |
| 1449 | 1494 |
| 1450 } // namespace chromeos | 1495 } // namespace chromeos |
| OLD | NEW |