Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Side by Side Diff: chrome/browser/chromeos/accessibility/accessibility_manager.cc

Issue 1840913002: A11y setting: mono audio UI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: delete tray a11y hand icon view Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 9
10 #include <memory> 10 #include <memory>
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 #include "chrome/browser/extensions/tab_helper.h" 47 #include "chrome/browser/extensions/tab_helper.h"
48 #include "chrome/browser/prefs/incognito_mode_prefs.h" 48 #include "chrome/browser/prefs/incognito_mode_prefs.h"
49 #include "chrome/browser/profiles/profile.h" 49 #include "chrome/browser/profiles/profile.h"
50 #include "chrome/browser/profiles/profile_manager.h" 50 #include "chrome/browser/profiles/profile_manager.h"
51 #include "chrome/common/chrome_paths.h" 51 #include "chrome/common/chrome_paths.h"
52 #include "chrome/common/extensions/api/accessibility_private.h" 52 #include "chrome/common/extensions/api/accessibility_private.h"
53 #include "chrome/common/extensions/extension_constants.h" 53 #include "chrome/common/extensions/extension_constants.h"
54 #include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h" 54 #include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h"
55 #include "chrome/common/pref_names.h" 55 #include "chrome/common/pref_names.h"
56 #include "chrome/grit/browser_resources.h" 56 #include "chrome/grit/browser_resources.h"
57 #include "chromeos/audio/audio_a11y_controller.h"
57 #include "chromeos/audio/chromeos_sounds.h" 58 #include "chromeos/audio/chromeos_sounds.h"
58 #include "chromeos/login/login_state.h" 59 #include "chromeos/login/login_state.h"
59 #include "components/prefs/pref_member.h" 60 #include "components/prefs/pref_member.h"
60 #include "components/prefs/pref_service.h" 61 #include "components/prefs/pref_service.h"
61 #include "components/user_manager/user_manager.h" 62 #include "components/user_manager/user_manager.h"
62 #include "content/public/browser/browser_accessibility_state.h" 63 #include "content/public/browser/browser_accessibility_state.h"
63 #include "content/public/browser/browser_thread.h" 64 #include "content/public/browser/browser_thread.h"
64 #include "content/public/browser/notification_details.h" 65 #include "content/public/browser/notification_details.h"
65 #include "content/public/browser/notification_service.h" 66 #include "content/public/browser/notification_service.h"
66 #include "content/public/browser/notification_source.h" 67 #include "content/public/browser/notification_source.h"
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 : profile_(NULL), 395 : profile_(NULL),
395 chrome_vox_loaded_on_lock_screen_(false), 396 chrome_vox_loaded_on_lock_screen_(false),
396 chrome_vox_loaded_on_user_screen_(false), 397 chrome_vox_loaded_on_user_screen_(false),
397 large_cursor_pref_handler_(prefs::kAccessibilityLargeCursorEnabled), 398 large_cursor_pref_handler_(prefs::kAccessibilityLargeCursorEnabled),
398 spoken_feedback_pref_handler_(prefs::kAccessibilitySpokenFeedbackEnabled), 399 spoken_feedback_pref_handler_(prefs::kAccessibilitySpokenFeedbackEnabled),
399 high_contrast_pref_handler_(prefs::kAccessibilityHighContrastEnabled), 400 high_contrast_pref_handler_(prefs::kAccessibilityHighContrastEnabled),
400 autoclick_pref_handler_(prefs::kAccessibilityAutoclickEnabled), 401 autoclick_pref_handler_(prefs::kAccessibilityAutoclickEnabled),
401 autoclick_delay_pref_handler_(prefs::kAccessibilityAutoclickDelayMs), 402 autoclick_delay_pref_handler_(prefs::kAccessibilityAutoclickDelayMs),
402 virtual_keyboard_pref_handler_( 403 virtual_keyboard_pref_handler_(
403 prefs::kAccessibilityVirtualKeyboardEnabled), 404 prefs::kAccessibilityVirtualKeyboardEnabled),
405 mono_audio_pref_handler_(
406 prefs::kAccessibilityMonoAudioEnabled),
404 caret_highlight_pref_handler_(prefs::kAccessibilityCaretHighlightEnabled), 407 caret_highlight_pref_handler_(prefs::kAccessibilityCaretHighlightEnabled),
405 cursor_highlight_pref_handler_( 408 cursor_highlight_pref_handler_(
406 prefs::kAccessibilityCursorHighlightEnabled), 409 prefs::kAccessibilityCursorHighlightEnabled),
407 focus_highlight_pref_handler_(prefs::kAccessibilityFocusHighlightEnabled), 410 focus_highlight_pref_handler_(prefs::kAccessibilityFocusHighlightEnabled),
408 select_to_speak_pref_handler_(prefs::kAccessibilitySelectToSpeakEnabled), 411 select_to_speak_pref_handler_(prefs::kAccessibilitySelectToSpeakEnabled),
409 switch_access_pref_handler_(prefs::kAccessibilitySwitchAccessEnabled), 412 switch_access_pref_handler_(prefs::kAccessibilitySwitchAccessEnabled),
410 large_cursor_enabled_(false), 413 large_cursor_enabled_(false),
411 sticky_keys_enabled_(false), 414 sticky_keys_enabled_(false),
412 spoken_feedback_enabled_(false), 415 spoken_feedback_enabled_(false),
413 high_contrast_enabled_(false), 416 high_contrast_enabled_(false),
414 autoclick_enabled_(false), 417 autoclick_enabled_(false),
415 autoclick_delay_ms_(ash::AutoclickController::kDefaultAutoclickDelayMs), 418 autoclick_delay_ms_(ash::AutoclickController::kDefaultAutoclickDelayMs),
416 virtual_keyboard_enabled_(false), 419 virtual_keyboard_enabled_(false),
420 mono_audio_enabled_(false),
417 caret_highlight_enabled_(false), 421 caret_highlight_enabled_(false),
418 cursor_highlight_enabled_(false), 422 cursor_highlight_enabled_(false),
419 focus_highlight_enabled_(false), 423 focus_highlight_enabled_(false),
420 select_to_speak_enabled_(false), 424 select_to_speak_enabled_(false),
421 switch_access_enabled_(false), 425 switch_access_enabled_(false),
422 spoken_feedback_notification_(ui::A11Y_NOTIFICATION_NONE), 426 spoken_feedback_notification_(ui::A11Y_NOTIFICATION_NONE),
423 should_speak_chrome_vox_announcements_on_user_screen_(true), 427 should_speak_chrome_vox_announcements_on_user_screen_(true),
424 system_sounds_enabled_(false), 428 system_sounds_enabled_(false),
425 braille_display_connected_(false), 429 braille_display_connected_(false),
426 scoped_braille_observer_(this), 430 scoped_braille_observer_(this),
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 it != profiles.end(); 489 it != profiles.end();
486 ++it) { 490 ++it) {
487 PrefService* pref_service = (*it)->GetPrefs(); 491 PrefService* pref_service = (*it)->GetPrefs();
488 if (pref_service->GetBoolean(prefs::kAccessibilityStickyKeysEnabled) || 492 if (pref_service->GetBoolean(prefs::kAccessibilityStickyKeysEnabled) ||
489 pref_service->GetBoolean(prefs::kAccessibilityLargeCursorEnabled) || 493 pref_service->GetBoolean(prefs::kAccessibilityLargeCursorEnabled) ||
490 pref_service->GetBoolean(prefs::kAccessibilitySpokenFeedbackEnabled) || 494 pref_service->GetBoolean(prefs::kAccessibilitySpokenFeedbackEnabled) ||
491 pref_service->GetBoolean(prefs::kAccessibilityHighContrastEnabled) || 495 pref_service->GetBoolean(prefs::kAccessibilityHighContrastEnabled) ||
492 pref_service->GetBoolean(prefs::kAccessibilityAutoclickEnabled) || 496 pref_service->GetBoolean(prefs::kAccessibilityAutoclickEnabled) ||
493 pref_service->GetBoolean(prefs::kShouldAlwaysShowAccessibilityMenu) || 497 pref_service->GetBoolean(prefs::kShouldAlwaysShowAccessibilityMenu) ||
494 pref_service->GetBoolean(prefs::kAccessibilityScreenMagnifierEnabled) || 498 pref_service->GetBoolean(prefs::kAccessibilityScreenMagnifierEnabled) ||
495 pref_service->GetBoolean(prefs::kAccessibilityVirtualKeyboardEnabled)) 499 pref_service->GetBoolean(prefs::kAccessibilityVirtualKeyboardEnabled) ||
500 pref_service->GetBoolean(prefs::kAccessibilityMonoAudioEnabled))
496 return true; 501 return true;
497 } 502 }
498 return false; 503 return false;
499 } 504 }
500 505
501 bool AccessibilityManager::ShouldEnableCursorCompositing() { 506 bool AccessibilityManager::ShouldEnableCursorCompositing() {
502 if (!profile_) 507 if (!profile_)
503 return false; 508 return false;
504 PrefService* pref_service = profile_->GetPrefs(); 509 PrefService* pref_service = profile_->GetPrefs();
505 // Enable cursor compositing when one or more of the listed accessibility 510 // Enable cursor compositing when one or more of the listed accessibility
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 else 877 else
873 ash::Shell::GetInstance()->DeactivateKeyboard(); 878 ash::Shell::GetInstance()->DeactivateKeyboard();
874 879
875 AccessibilityStatusEventDetails details( 880 AccessibilityStatusEventDetails details(
876 ACCESSIBILITY_TOGGLE_VIRTUAL_KEYBOARD, 881 ACCESSIBILITY_TOGGLE_VIRTUAL_KEYBOARD,
877 enabled, 882 enabled,
878 ui::A11Y_NOTIFICATION_NONE); 883 ui::A11Y_NOTIFICATION_NONE);
879 NotifyAccessibilityStatusChanged(details); 884 NotifyAccessibilityStatusChanged(details);
880 } 885 }
881 886
887 void AccessibilityManager::EnableMonoAudio(bool enabled) {
888 if (!profile_)
889 return;
890
891 PrefService* pref_service = profile_->GetPrefs();
892 pref_service->SetBoolean(prefs::kAccessibilityMonoAudioEnabled,
893 enabled);
894 pref_service->CommitPendingWrite();
895 }
896
897 bool AccessibilityManager::IsMonoAudioEnabled() {
898 return mono_audio_enabled_;
899 }
900
901 void AccessibilityManager::UpdateMonoAudioFromPref() {
902 if (!profile_)
903 return;
904
905 const bool enabled = profile_->GetPrefs()->GetBoolean(
906 prefs::kAccessibilityMonoAudioEnabled);
907
908 if (mono_audio_enabled_ == enabled)
909 return;
910 mono_audio_enabled_ = enabled;
911
912 AccessibilityStatusEventDetails details(
913 ACCESSIBILITY_TOGGLE_MONO_AUDIO,
914 enabled,
915 ui::A11Y_NOTIFICATION_NONE);
916 NotifyAccessibilityStatusChanged(details);
917
918 ash::Shell::GetInstance()->audio_a11y_controller()->SetOutputMono(enabled);
919 }
920
882 void AccessibilityManager::SetCaretHighlightEnabled(bool enabled) { 921 void AccessibilityManager::SetCaretHighlightEnabled(bool enabled) {
883 if (!profile_) 922 if (!profile_)
884 return; 923 return;
885 924
886 PrefService* pref_service = profile_->GetPrefs(); 925 PrefService* pref_service = profile_->GetPrefs();
887 pref_service->SetBoolean(prefs::kAccessibilityCaretHighlightEnabled, enabled); 926 pref_service->SetBoolean(prefs::kAccessibilityCaretHighlightEnabled, enabled);
888 pref_service->CommitPendingWrite(); 927 pref_service->CommitPendingWrite();
889 } 928 }
890 929
891 bool AccessibilityManager::IsCaretHighlightEnabled() const { 930 bool AccessibilityManager::IsCaretHighlightEnabled() const {
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
1125 base::Unretained(this))); 1164 base::Unretained(this)));
1126 pref_change_registrar_->Add( 1165 pref_change_registrar_->Add(
1127 prefs::kAccessibilityAutoclickDelayMs, 1166 prefs::kAccessibilityAutoclickDelayMs,
1128 base::Bind(&AccessibilityManager::UpdateAutoclickDelayFromPref, 1167 base::Bind(&AccessibilityManager::UpdateAutoclickDelayFromPref,
1129 base::Unretained(this))); 1168 base::Unretained(this)));
1130 pref_change_registrar_->Add( 1169 pref_change_registrar_->Add(
1131 prefs::kAccessibilityVirtualKeyboardEnabled, 1170 prefs::kAccessibilityVirtualKeyboardEnabled,
1132 base::Bind(&AccessibilityManager::UpdateVirtualKeyboardFromPref, 1171 base::Bind(&AccessibilityManager::UpdateVirtualKeyboardFromPref,
1133 base::Unretained(this))); 1172 base::Unretained(this)));
1134 pref_change_registrar_->Add( 1173 pref_change_registrar_->Add(
1174 prefs::kAccessibilityMonoAudioEnabled,
1175 base::Bind(&AccessibilityManager::UpdateMonoAudioFromPref,
1176 base::Unretained(this)));
1177 pref_change_registrar_->Add(
1135 prefs::kAccessibilityCaretHighlightEnabled, 1178 prefs::kAccessibilityCaretHighlightEnabled,
1136 base::Bind(&AccessibilityManager::UpdateCaretHighlightFromPref, 1179 base::Bind(&AccessibilityManager::UpdateCaretHighlightFromPref,
1137 base::Unretained(this))); 1180 base::Unretained(this)));
1138 pref_change_registrar_->Add( 1181 pref_change_registrar_->Add(
1139 prefs::kAccessibilityCursorHighlightEnabled, 1182 prefs::kAccessibilityCursorHighlightEnabled,
1140 base::Bind(&AccessibilityManager::UpdateCursorHighlightFromPref, 1183 base::Bind(&AccessibilityManager::UpdateCursorHighlightFromPref,
1141 base::Unretained(this))); 1184 base::Unretained(this)));
1142 pref_change_registrar_->Add( 1185 pref_change_registrar_->Add(
1143 prefs::kAccessibilityFocusHighlightEnabled, 1186 prefs::kAccessibilityFocusHighlightEnabled,
1144 base::Bind(&AccessibilityManager::UpdateFocusHighlightFromPref, 1187 base::Bind(&AccessibilityManager::UpdateFocusHighlightFromPref,
(...skipping 19 matching lines...) Expand all
1164 &AccessibilityManager::UpdateChromeOSAccessibilityHistograms, 1207 &AccessibilityManager::UpdateChromeOSAccessibilityHistograms,
1165 base::Unretained(this))); 1208 base::Unretained(this)));
1166 } 1209 }
1167 1210
1168 large_cursor_pref_handler_.HandleProfileChanged(profile_, profile); 1211 large_cursor_pref_handler_.HandleProfileChanged(profile_, profile);
1169 spoken_feedback_pref_handler_.HandleProfileChanged(profile_, profile); 1212 spoken_feedback_pref_handler_.HandleProfileChanged(profile_, profile);
1170 high_contrast_pref_handler_.HandleProfileChanged(profile_, profile); 1213 high_contrast_pref_handler_.HandleProfileChanged(profile_, profile);
1171 autoclick_pref_handler_.HandleProfileChanged(profile_, profile); 1214 autoclick_pref_handler_.HandleProfileChanged(profile_, profile);
1172 autoclick_delay_pref_handler_.HandleProfileChanged(profile_, profile); 1215 autoclick_delay_pref_handler_.HandleProfileChanged(profile_, profile);
1173 virtual_keyboard_pref_handler_.HandleProfileChanged(profile_, profile); 1216 virtual_keyboard_pref_handler_.HandleProfileChanged(profile_, profile);
1217 mono_audio_pref_handler_.HandleProfileChanged(profile_, profile);
1174 caret_highlight_pref_handler_.HandleProfileChanged(profile_, profile); 1218 caret_highlight_pref_handler_.HandleProfileChanged(profile_, profile);
1175 cursor_highlight_pref_handler_.HandleProfileChanged(profile_, profile); 1219 cursor_highlight_pref_handler_.HandleProfileChanged(profile_, profile);
1176 focus_highlight_pref_handler_.HandleProfileChanged(profile_, profile); 1220 focus_highlight_pref_handler_.HandleProfileChanged(profile_, profile);
1177 select_to_speak_pref_handler_.HandleProfileChanged(profile_, profile); 1221 select_to_speak_pref_handler_.HandleProfileChanged(profile_, profile);
1178 switch_access_pref_handler_.HandleProfileChanged(profile_, profile); 1222 switch_access_pref_handler_.HandleProfileChanged(profile_, profile);
1179 1223
1180 bool had_profile = (profile_ != NULL); 1224 bool had_profile = (profile_ != NULL);
1181 profile_ = profile; 1225 profile_ = profile;
1182 1226
1183 if (!had_profile && profile) 1227 if (!had_profile && profile)
1184 CheckBrailleState(); 1228 CheckBrailleState();
1185 else 1229 else
1186 UpdateBrailleImeState(); 1230 UpdateBrailleImeState();
1187 UpdateLargeCursorFromPref(); 1231 UpdateLargeCursorFromPref();
1188 UpdateStickyKeysFromPref(); 1232 UpdateStickyKeysFromPref();
1189 UpdateSpokenFeedbackFromPref(); 1233 UpdateSpokenFeedbackFromPref();
1190 UpdateHighContrastFromPref(); 1234 UpdateHighContrastFromPref();
1191 UpdateAutoclickFromPref(); 1235 UpdateAutoclickFromPref();
1192 UpdateAutoclickDelayFromPref(); 1236 UpdateAutoclickDelayFromPref();
1193 UpdateVirtualKeyboardFromPref(); 1237 UpdateVirtualKeyboardFromPref();
1238 UpdateMonoAudioFromPref();
1194 UpdateCaretHighlightFromPref(); 1239 UpdateCaretHighlightFromPref();
1195 UpdateCursorHighlightFromPref(); 1240 UpdateCursorHighlightFromPref();
1196 UpdateFocusHighlightFromPref(); 1241 UpdateFocusHighlightFromPref();
1197 UpdateSelectToSpeakFromPref(); 1242 UpdateSelectToSpeakFromPref();
1198 UpdateSwitchAccessFromPref(); 1243 UpdateSwitchAccessFromPref();
1199 1244
1200 // Update the panel height in the shelf layout manager when the profile 1245 // Update the panel height in the shelf layout manager when the profile
1201 // changes, since the shelf layout manager doesn't exist in the login profile. 1246 // changes, since the shelf layout manager doesn't exist in the login profile.
1202 if (chromevox_panel_) 1247 if (chromevox_panel_)
1203 chromevox_panel_->UpdatePanelHeight(); 1248 chromevox_panel_->UpdatePanelHeight();
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
1458 content::BrowserContext* context) { 1503 content::BrowserContext* context) {
1459 keyboard_listener_extension_id_ = id; 1504 keyboard_listener_extension_id_ = id;
1460 1505
1461 extensions::ExtensionRegistry* registry = 1506 extensions::ExtensionRegistry* registry =
1462 extensions::ExtensionRegistry::Get(context); 1507 extensions::ExtensionRegistry::Get(context);
1463 if (!extension_registry_observer_.IsObserving(registry) && !id.empty()) 1508 if (!extension_registry_observer_.IsObserving(registry) && !id.empty())
1464 extension_registry_observer_.Add(registry); 1509 extension_registry_observer_.Add(registry);
1465 } 1510 }
1466 1511
1467 } // namespace chromeos 1512 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698