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 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 : profile_(NULL), | 392 : profile_(NULL), |
393 chrome_vox_loaded_on_lock_screen_(false), | 393 chrome_vox_loaded_on_lock_screen_(false), |
394 chrome_vox_loaded_on_user_screen_(false), | 394 chrome_vox_loaded_on_user_screen_(false), |
395 large_cursor_pref_handler_(prefs::kAccessibilityLargeCursorEnabled), | 395 large_cursor_pref_handler_(prefs::kAccessibilityLargeCursorEnabled), |
396 spoken_feedback_pref_handler_(prefs::kAccessibilitySpokenFeedbackEnabled), | 396 spoken_feedback_pref_handler_(prefs::kAccessibilitySpokenFeedbackEnabled), |
397 high_contrast_pref_handler_(prefs::kAccessibilityHighContrastEnabled), | 397 high_contrast_pref_handler_(prefs::kAccessibilityHighContrastEnabled), |
398 autoclick_pref_handler_(prefs::kAccessibilityAutoclickEnabled), | 398 autoclick_pref_handler_(prefs::kAccessibilityAutoclickEnabled), |
399 autoclick_delay_pref_handler_(prefs::kAccessibilityAutoclickDelayMs), | 399 autoclick_delay_pref_handler_(prefs::kAccessibilityAutoclickDelayMs), |
400 virtual_keyboard_pref_handler_( | 400 virtual_keyboard_pref_handler_( |
401 prefs::kAccessibilityVirtualKeyboardEnabled), | 401 prefs::kAccessibilityVirtualKeyboardEnabled), |
| 402 caret_highlight_pref_handler_(prefs::kAccessibilityCaretHighlightEnabled), |
| 403 cursor_highlight_pref_handler_( |
| 404 prefs::kAccessibilityCursorHighlightEnabled), |
| 405 focus_highlight_pref_handler_(prefs::kAccessibilityFocusHighlightEnabled), |
| 406 select_to_speak_pref_handler_(prefs::kAccessibilitySelectToSpeakEnabled), |
| 407 switch_access_pref_handler_(prefs::kAccessibilitySwitchAccessEnabled), |
402 large_cursor_enabled_(false), | 408 large_cursor_enabled_(false), |
403 sticky_keys_enabled_(false), | 409 sticky_keys_enabled_(false), |
404 spoken_feedback_enabled_(false), | 410 spoken_feedback_enabled_(false), |
405 high_contrast_enabled_(false), | 411 high_contrast_enabled_(false), |
406 autoclick_enabled_(false), | 412 autoclick_enabled_(false), |
407 autoclick_delay_ms_(ash::AutoclickController::kDefaultAutoclickDelayMs), | 413 autoclick_delay_ms_(ash::AutoclickController::kDefaultAutoclickDelayMs), |
408 virtual_keyboard_enabled_(false), | 414 virtual_keyboard_enabled_(false), |
| 415 caret_highlight_enabled_(false), |
| 416 cursor_highlight_enabled_(false), |
| 417 focus_highlight_enabled_(false), |
| 418 select_to_speak_enabled_(false), |
| 419 switch_access_enabled_(false), |
409 spoken_feedback_notification_(ui::A11Y_NOTIFICATION_NONE), | 420 spoken_feedback_notification_(ui::A11Y_NOTIFICATION_NONE), |
410 should_speak_chrome_vox_announcements_on_user_screen_(true), | 421 should_speak_chrome_vox_announcements_on_user_screen_(true), |
411 system_sounds_enabled_(false), | 422 system_sounds_enabled_(false), |
412 braille_display_connected_(false), | 423 braille_display_connected_(false), |
413 scoped_braille_observer_(this), | 424 scoped_braille_observer_(this), |
414 braille_ime_current_(false), | 425 braille_ime_current_(false), |
415 chromevox_panel_(nullptr), | 426 chromevox_panel_(nullptr), |
416 extension_registry_observer_(this), | 427 extension_registry_observer_(this), |
417 weak_ptr_factory_(this) { | 428 weak_ptr_factory_(this) { |
418 notification_registrar_.Add(this, | 429 notification_registrar_.Add(this, |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
859 else | 870 else |
860 ash::Shell::GetInstance()->DeactivateKeyboard(); | 871 ash::Shell::GetInstance()->DeactivateKeyboard(); |
861 | 872 |
862 AccessibilityStatusEventDetails details( | 873 AccessibilityStatusEventDetails details( |
863 ACCESSIBILITY_TOGGLE_VIRTUAL_KEYBOARD, | 874 ACCESSIBILITY_TOGGLE_VIRTUAL_KEYBOARD, |
864 enabled, | 875 enabled, |
865 ui::A11Y_NOTIFICATION_NONE); | 876 ui::A11Y_NOTIFICATION_NONE); |
866 NotifyAccessibilityStatusChanged(details); | 877 NotifyAccessibilityStatusChanged(details); |
867 } | 878 } |
868 | 879 |
| 880 void AccessibilityManager::SetCaretHighlightEnabled(bool enabled) { |
| 881 if (!profile_) |
| 882 return; |
| 883 |
| 884 PrefService* pref_service = profile_->GetPrefs(); |
| 885 pref_service->SetBoolean(prefs::kAccessibilityCaretHighlightEnabled, enabled); |
| 886 pref_service->CommitPendingWrite(); |
| 887 } |
| 888 |
| 889 bool AccessibilityManager::IsCaretHighlightEnabled() const { |
| 890 return caret_highlight_enabled_; |
| 891 } |
| 892 |
| 893 void AccessibilityManager::UpdateCaretHighlightFromPref() { |
| 894 if (!profile_) |
| 895 return; |
| 896 |
| 897 const bool enabled = profile_->GetPrefs()->GetBoolean( |
| 898 prefs::kAccessibilityCaretHighlightEnabled); |
| 899 |
| 900 if (caret_highlight_enabled_ == enabled) |
| 901 return; |
| 902 caret_highlight_enabled_ = enabled; |
| 903 |
| 904 // TODO(dmazzoni): implement feature here. |
| 905 } |
| 906 |
| 907 void AccessibilityManager::SetCursorHighlightEnabled(bool enabled) { |
| 908 if (!profile_) |
| 909 return; |
| 910 |
| 911 PrefService* pref_service = profile_->GetPrefs(); |
| 912 pref_service->SetBoolean(prefs::kAccessibilityCursorHighlightEnabled, |
| 913 enabled); |
| 914 pref_service->CommitPendingWrite(); |
| 915 } |
| 916 |
| 917 bool AccessibilityManager::IsCursorHighlightEnabled() const { |
| 918 return cursor_highlight_enabled_; |
| 919 } |
| 920 |
| 921 void AccessibilityManager::UpdateCursorHighlightFromPref() { |
| 922 if (!profile_) |
| 923 return; |
| 924 |
| 925 const bool enabled = profile_->GetPrefs()->GetBoolean( |
| 926 prefs::kAccessibilityCursorHighlightEnabled); |
| 927 |
| 928 if (cursor_highlight_enabled_ == enabled) |
| 929 return; |
| 930 cursor_highlight_enabled_ = enabled; |
| 931 |
| 932 // TODO(dmazzoni): implement feature here. |
| 933 } |
| 934 |
| 935 void AccessibilityManager::SetFocusHighlightEnabled(bool enabled) { |
| 936 if (!profile_) |
| 937 return; |
| 938 |
| 939 PrefService* pref_service = profile_->GetPrefs(); |
| 940 pref_service->SetBoolean(prefs::kAccessibilityFocusHighlightEnabled, enabled); |
| 941 pref_service->CommitPendingWrite(); |
| 942 } |
| 943 |
| 944 bool AccessibilityManager::IsFocusHighlightEnabled() const { |
| 945 return focus_highlight_enabled_; |
| 946 } |
| 947 |
| 948 void AccessibilityManager::UpdateFocusHighlightFromPref() { |
| 949 if (!profile_) |
| 950 return; |
| 951 |
| 952 const bool enabled = profile_->GetPrefs()->GetBoolean( |
| 953 prefs::kAccessibilityFocusHighlightEnabled); |
| 954 |
| 955 if (focus_highlight_enabled_ == enabled) |
| 956 return; |
| 957 focus_highlight_enabled_ = enabled; |
| 958 |
| 959 // TODO(dmazzoni): implement feature here. |
| 960 } |
| 961 |
| 962 void AccessibilityManager::SetSelectToSpeakEnabled(bool enabled) { |
| 963 if (!profile_) |
| 964 return; |
| 965 |
| 966 PrefService* pref_service = profile_->GetPrefs(); |
| 967 pref_service->SetBoolean(prefs::kAccessibilitySelectToSpeakEnabled, enabled); |
| 968 pref_service->CommitPendingWrite(); |
| 969 } |
| 970 |
| 971 bool AccessibilityManager::IsSelectToSpeakEnabled() const { |
| 972 return select_to_speak_enabled_; |
| 973 } |
| 974 |
| 975 void AccessibilityManager::UpdateSelectToSpeakFromPref() { |
| 976 if (!profile_) |
| 977 return; |
| 978 |
| 979 const bool enabled = profile_->GetPrefs()->GetBoolean( |
| 980 prefs::kAccessibilitySelectToSpeakEnabled); |
| 981 |
| 982 if (select_to_speak_enabled_ == enabled) |
| 983 return; |
| 984 select_to_speak_enabled_ = enabled; |
| 985 |
| 986 // TODO(dmazzoni): implement feature here. |
| 987 } |
| 988 |
| 989 void AccessibilityManager::SetSwitchAccessEnabled(bool enabled) { |
| 990 if (!profile_) |
| 991 return; |
| 992 |
| 993 PrefService* pref_service = profile_->GetPrefs(); |
| 994 pref_service->SetBoolean(prefs::kAccessibilitySwitchAccessEnabled, enabled); |
| 995 pref_service->CommitPendingWrite(); |
| 996 } |
| 997 |
| 998 bool AccessibilityManager::IsSwitchAccessEnabled() const { |
| 999 return switch_access_enabled_; |
| 1000 } |
| 1001 |
| 1002 void AccessibilityManager::UpdateSwitchAccessFromPref() { |
| 1003 if (!profile_) |
| 1004 return; |
| 1005 |
| 1006 const bool enabled = profile_->GetPrefs()->GetBoolean( |
| 1007 prefs::kAccessibilitySwitchAccessEnabled); |
| 1008 |
| 1009 if (switch_access_enabled_ == enabled) |
| 1010 return; |
| 1011 switch_access_enabled_ = enabled; |
| 1012 |
| 1013 // TODO(dmazzoni): implement feature here. |
| 1014 } |
| 1015 |
869 bool AccessibilityManager::IsBrailleDisplayConnected() const { | 1016 bool AccessibilityManager::IsBrailleDisplayConnected() const { |
870 return braille_display_connected_; | 1017 return braille_display_connected_; |
871 } | 1018 } |
872 | 1019 |
873 void AccessibilityManager::CheckBrailleState() { | 1020 void AccessibilityManager::CheckBrailleState() { |
874 BrailleController* braille_controller = GetBrailleController(); | 1021 BrailleController* braille_controller = GetBrailleController(); |
875 if (!scoped_braille_observer_.IsObserving(braille_controller)) | 1022 if (!scoped_braille_observer_.IsObserving(braille_controller)) |
876 scoped_braille_observer_.Add(braille_controller); | 1023 scoped_braille_observer_.Add(braille_controller); |
877 BrowserThread::PostTaskAndReplyWithResult( | 1024 BrowserThread::PostTaskAndReplyWithResult( |
878 BrowserThread::IO, | 1025 BrowserThread::IO, |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
958 base::Bind(&AccessibilityManager::UpdateAutoclickFromPref, | 1105 base::Bind(&AccessibilityManager::UpdateAutoclickFromPref, |
959 base::Unretained(this))); | 1106 base::Unretained(this))); |
960 pref_change_registrar_->Add( | 1107 pref_change_registrar_->Add( |
961 prefs::kAccessibilityAutoclickDelayMs, | 1108 prefs::kAccessibilityAutoclickDelayMs, |
962 base::Bind(&AccessibilityManager::UpdateAutoclickDelayFromPref, | 1109 base::Bind(&AccessibilityManager::UpdateAutoclickDelayFromPref, |
963 base::Unretained(this))); | 1110 base::Unretained(this))); |
964 pref_change_registrar_->Add( | 1111 pref_change_registrar_->Add( |
965 prefs::kAccessibilityVirtualKeyboardEnabled, | 1112 prefs::kAccessibilityVirtualKeyboardEnabled, |
966 base::Bind(&AccessibilityManager::UpdateVirtualKeyboardFromPref, | 1113 base::Bind(&AccessibilityManager::UpdateVirtualKeyboardFromPref, |
967 base::Unretained(this))); | 1114 base::Unretained(this))); |
| 1115 pref_change_registrar_->Add( |
| 1116 prefs::kAccessibilityCaretHighlightEnabled, |
| 1117 base::Bind(&AccessibilityManager::UpdateCaretHighlightFromPref, |
| 1118 base::Unretained(this))); |
| 1119 pref_change_registrar_->Add( |
| 1120 prefs::kAccessibilityCursorHighlightEnabled, |
| 1121 base::Bind(&AccessibilityManager::UpdateCursorHighlightFromPref, |
| 1122 base::Unretained(this))); |
| 1123 pref_change_registrar_->Add( |
| 1124 prefs::kAccessibilityFocusHighlightEnabled, |
| 1125 base::Bind(&AccessibilityManager::UpdateFocusHighlightFromPref, |
| 1126 base::Unretained(this))); |
| 1127 pref_change_registrar_->Add( |
| 1128 prefs::kAccessibilitySelectToSpeakEnabled, |
| 1129 base::Bind(&AccessibilityManager::UpdateSelectToSpeakFromPref, |
| 1130 base::Unretained(this))); |
| 1131 pref_change_registrar_->Add( |
| 1132 prefs::kAccessibilitySwitchAccessEnabled, |
| 1133 base::Bind(&AccessibilityManager::UpdateSwitchAccessFromPref, |
| 1134 base::Unretained(this))); |
968 | 1135 |
969 local_state_pref_change_registrar_.reset(new PrefChangeRegistrar); | 1136 local_state_pref_change_registrar_.reset(new PrefChangeRegistrar); |
970 local_state_pref_change_registrar_->Init(g_browser_process->local_state()); | 1137 local_state_pref_change_registrar_->Init(g_browser_process->local_state()); |
971 local_state_pref_change_registrar_->Add( | 1138 local_state_pref_change_registrar_->Add( |
972 prefs::kApplicationLocale, | 1139 prefs::kApplicationLocale, |
973 base::Bind(&AccessibilityManager::OnLocaleChanged, | 1140 base::Bind(&AccessibilityManager::OnLocaleChanged, |
974 base::Unretained(this))); | 1141 base::Unretained(this))); |
975 | 1142 |
976 content::BrowserAccessibilityState::GetInstance()->AddHistogramCallback( | 1143 content::BrowserAccessibilityState::GetInstance()->AddHistogramCallback( |
977 base::Bind( | 1144 base::Bind( |
978 &AccessibilityManager::UpdateChromeOSAccessibilityHistograms, | 1145 &AccessibilityManager::UpdateChromeOSAccessibilityHistograms, |
979 base::Unretained(this))); | 1146 base::Unretained(this))); |
980 } | 1147 } |
981 | 1148 |
982 large_cursor_pref_handler_.HandleProfileChanged(profile_, profile); | 1149 large_cursor_pref_handler_.HandleProfileChanged(profile_, profile); |
983 spoken_feedback_pref_handler_.HandleProfileChanged(profile_, profile); | 1150 spoken_feedback_pref_handler_.HandleProfileChanged(profile_, profile); |
984 high_contrast_pref_handler_.HandleProfileChanged(profile_, profile); | 1151 high_contrast_pref_handler_.HandleProfileChanged(profile_, profile); |
985 autoclick_pref_handler_.HandleProfileChanged(profile_, profile); | 1152 autoclick_pref_handler_.HandleProfileChanged(profile_, profile); |
986 autoclick_delay_pref_handler_.HandleProfileChanged(profile_, profile); | 1153 autoclick_delay_pref_handler_.HandleProfileChanged(profile_, profile); |
987 virtual_keyboard_pref_handler_.HandleProfileChanged(profile_, profile); | 1154 virtual_keyboard_pref_handler_.HandleProfileChanged(profile_, profile); |
| 1155 caret_highlight_pref_handler_.HandleProfileChanged(profile_, profile); |
| 1156 cursor_highlight_pref_handler_.HandleProfileChanged(profile_, profile); |
| 1157 focus_highlight_pref_handler_.HandleProfileChanged(profile_, profile); |
| 1158 select_to_speak_pref_handler_.HandleProfileChanged(profile_, profile); |
| 1159 switch_access_pref_handler_.HandleProfileChanged(profile_, profile); |
988 | 1160 |
989 bool had_profile = (profile_ != NULL); | 1161 bool had_profile = (profile_ != NULL); |
990 profile_ = profile; | 1162 profile_ = profile; |
991 | 1163 |
992 if (!had_profile && profile) | 1164 if (!had_profile && profile) |
993 CheckBrailleState(); | 1165 CheckBrailleState(); |
994 else | 1166 else |
995 UpdateBrailleImeState(); | 1167 UpdateBrailleImeState(); |
996 UpdateLargeCursorFromPref(); | 1168 UpdateLargeCursorFromPref(); |
997 UpdateStickyKeysFromPref(); | 1169 UpdateStickyKeysFromPref(); |
998 UpdateSpokenFeedbackFromPref(); | 1170 UpdateSpokenFeedbackFromPref(); |
999 UpdateHighContrastFromPref(); | 1171 UpdateHighContrastFromPref(); |
1000 UpdateAutoclickFromPref(); | 1172 UpdateAutoclickFromPref(); |
1001 UpdateAutoclickDelayFromPref(); | 1173 UpdateAutoclickDelayFromPref(); |
1002 UpdateVirtualKeyboardFromPref(); | 1174 UpdateVirtualKeyboardFromPref(); |
| 1175 UpdateCaretHighlightFromPref(); |
| 1176 UpdateCursorHighlightFromPref(); |
| 1177 UpdateFocusHighlightFromPref(); |
| 1178 UpdateSelectToSpeakFromPref(); |
| 1179 UpdateSwitchAccessFromPref(); |
1003 } | 1180 } |
1004 | 1181 |
1005 void AccessibilityManager::ActiveUserChanged(const AccountId& account_id) { | 1182 void AccessibilityManager::ActiveUserChanged(const AccountId& account_id) { |
1006 SetProfile(ProfileManager::GetActiveUserProfile()); | 1183 SetProfile(ProfileManager::GetActiveUserProfile()); |
1007 } | 1184 } |
1008 | 1185 |
1009 void AccessibilityManager::OnAppTerminating() { | 1186 void AccessibilityManager::OnAppTerminating() { |
1010 session_state_observer_.reset(); | 1187 session_state_observer_.reset(); |
1011 } | 1188 } |
1012 | 1189 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1081 // enabled autoclick. | 1258 // enabled autoclick. |
1082 UMA_HISTOGRAM_CUSTOM_TIMES( | 1259 UMA_HISTOGRAM_CUSTOM_TIMES( |
1083 "Accessibility.CrosAutoclickDelay", | 1260 "Accessibility.CrosAutoclickDelay", |
1084 base::TimeDelta::FromMilliseconds( | 1261 base::TimeDelta::FromMilliseconds( |
1085 prefs->GetInteger(prefs::kAccessibilityAutoclickDelayMs)), | 1262 prefs->GetInteger(prefs::kAccessibilityAutoclickDelayMs)), |
1086 base::TimeDelta::FromMilliseconds(1), | 1263 base::TimeDelta::FromMilliseconds(1), |
1087 base::TimeDelta::FromMilliseconds(3000), | 1264 base::TimeDelta::FromMilliseconds(3000), |
1088 50); | 1265 50); |
1089 } | 1266 } |
1090 } | 1267 } |
| 1268 UMA_HISTOGRAM_BOOLEAN("Accessibility.CrosCaretHighlight", |
| 1269 IsCaretHighlightEnabled()); |
| 1270 UMA_HISTOGRAM_BOOLEAN("Accessibility.CrosCursorHighlight", |
| 1271 IsCursorHighlightEnabled()); |
| 1272 UMA_HISTOGRAM_BOOLEAN("Accessibility.CrosFocusHighlight", |
| 1273 IsFocusHighlightEnabled()); |
| 1274 UMA_HISTOGRAM_BOOLEAN("Accessibility.CrosSelectToSpeak", |
| 1275 IsSelectToSpeakEnabled()); |
| 1276 UMA_HISTOGRAM_BOOLEAN("Accessibility.CrosSwitchAccess", |
| 1277 IsSwitchAccessEnabled()); |
1091 } | 1278 } |
1092 | 1279 |
1093 void AccessibilityManager::Observe( | 1280 void AccessibilityManager::Observe( |
1094 int type, | 1281 int type, |
1095 const content::NotificationSource& source, | 1282 const content::NotificationSource& source, |
1096 const content::NotificationDetails& details) { | 1283 const content::NotificationDetails& details) { |
1097 switch (type) { | 1284 switch (type) { |
1098 case chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE: { | 1285 case chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE: { |
1099 // Update |profile_| when entering the login screen. | 1286 // Update |profile_| when entering the login screen. |
1100 Profile* profile = ProfileManager::GetActiveUserProfile(); | 1287 Profile* profile = ProfileManager::GetActiveUserProfile(); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1237 content::BrowserContext* context) { | 1424 content::BrowserContext* context) { |
1238 keyboard_listener_extension_id_ = id; | 1425 keyboard_listener_extension_id_ = id; |
1239 | 1426 |
1240 extensions::ExtensionRegistry* registry = | 1427 extensions::ExtensionRegistry* registry = |
1241 extensions::ExtensionRegistry::Get(context); | 1428 extensions::ExtensionRegistry::Get(context); |
1242 if (!extension_registry_observer_.IsObserving(registry) && !id.empty()) | 1429 if (!extension_registry_observer_.IsObserving(registry) && !id.empty()) |
1243 extension_registry_observer_.Add(registry); | 1430 extension_registry_observer_.Add(registry); |
1244 } | 1431 } |
1245 | 1432 |
1246 } // namespace chromeos | 1433 } // namespace chromeos |
OLD | NEW |