| 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 "ash/autoclick/autoclick_controller.h" | 7 #include "ash/autoclick/autoclick_controller.h" |
| 8 #include "ash/high_contrast/high_contrast_controller.h" | 8 #include "ash/high_contrast/high_contrast_controller.h" |
| 9 #include "ash/metrics/user_metrics_recorder.h" | 9 #include "ash/metrics/user_metrics_recorder.h" |
| 10 #include "ash/session_state_delegate.h" | 10 #include "ash/session_state_delegate.h" |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 // static | 284 // static |
| 285 AccessibilityManager* AccessibilityManager::Get() { | 285 AccessibilityManager* AccessibilityManager::Get() { |
| 286 return g_accessibility_manager; | 286 return g_accessibility_manager; |
| 287 } | 287 } |
| 288 | 288 |
| 289 AccessibilityManager::AccessibilityManager() | 289 AccessibilityManager::AccessibilityManager() |
| 290 : profile_(NULL), | 290 : profile_(NULL), |
| 291 chrome_vox_loaded_on_lock_screen_(false), | 291 chrome_vox_loaded_on_lock_screen_(false), |
| 292 chrome_vox_loaded_on_user_screen_(false), | 292 chrome_vox_loaded_on_user_screen_(false), |
| 293 large_cursor_pref_handler_(prefs::kLargeCursorEnabled), | 293 large_cursor_pref_handler_(prefs::kLargeCursorEnabled), |
| 294 spoken_feedback_pref_handler_(prefs::kSpokenFeedbackEnabled), | |
| 295 high_contrast_pref_handler_(prefs::kHighContrastEnabled), | 294 high_contrast_pref_handler_(prefs::kHighContrastEnabled), |
| 296 autoclick_pref_handler_(prefs::kAutoclickEnabled), | 295 autoclick_pref_handler_(prefs::kAutoclickEnabled), |
| 297 autoclick_delay_pref_handler_(prefs::kAutoclickDelayMs), | 296 autoclick_delay_pref_handler_(prefs::kAutoclickDelayMs), |
| 298 large_cursor_enabled_(false), | 297 large_cursor_enabled_(false), |
| 299 sticky_keys_enabled_(false), | 298 sticky_keys_enabled_(false), |
| 300 spoken_feedback_enabled_(false), | 299 spoken_feedback_enabled_(false), |
| 301 high_contrast_enabled_(false), | 300 high_contrast_enabled_(false), |
| 302 autoclick_enabled_(false), | 301 autoclick_enabled_(false), |
| 303 autoclick_delay_ms_(ash::AutoclickController::kDefaultAutoclickDelayMs), | 302 autoclick_delay_ms_(ash::AutoclickController::kDefaultAutoclickDelayMs), |
| 304 spoken_feedback_notification_(ash::A11Y_NOTIFICATION_NONE), | 303 spoken_feedback_notification_(ash::A11Y_NOTIFICATION_NONE), |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 // we clean up ChromeVox observers here. | 344 // we clean up ChromeVox observers here. |
| 346 for (std::set<Profile*>::iterator it = chromevox_profiles_.begin(); | 345 for (std::set<Profile*>::iterator it = chromevox_profiles_.begin(); |
| 347 it != chromevox_profiles_.end(); | 346 it != chromevox_profiles_.end(); |
| 348 it++) { | 347 it++) { |
| 349 extensions::ExtensionSystem::Get(*it)-> | 348 extensions::ExtensionSystem::Get(*it)-> |
| 350 event_router()->UnregisterObserver(this); | 349 event_router()->UnregisterObserver(this); |
| 351 } | 350 } |
| 352 } | 351 } |
| 353 | 352 |
| 354 bool AccessibilityManager::ShouldShowAccessibilityMenu() { | 353 bool AccessibilityManager::ShouldShowAccessibilityMenu() { |
| 354 if (!g_browser_process) |
| 355 return false; |
| 356 |
| 357 PrefService* global_pref_service = g_browser_process->local_state(); |
| 358 if (global_pref_service->GetBoolean(prefs::kSpokenFeedbackEnabled)) |
| 359 return true; |
| 360 |
| 355 // If any of the loaded profiles has an accessibility feature turned on - or | 361 // If any of the loaded profiles has an accessibility feature turned on - or |
| 356 // enforced to always show the menu - we return true to show the menu. | 362 // enforced to always show the menu - we return true to show the menu. |
| 357 std::vector<Profile*> profiles = | 363 std::vector<Profile*> profiles = |
| 358 g_browser_process->profile_manager()->GetLoadedProfiles(); | 364 g_browser_process->profile_manager()->GetLoadedProfiles(); |
| 359 for (std::vector<Profile*>::iterator it = profiles.begin(); | 365 for (std::vector<Profile*>::iterator it = profiles.begin(); |
| 360 it != profiles.end(); | 366 it != profiles.end(); |
| 361 ++it) { | 367 ++it) { |
| 362 PrefService* pref_service = (*it)->GetPrefs(); | 368 PrefService* pref_service = (*it)->GetPrefs(); |
| 363 if (pref_service->GetBoolean(prefs::kStickyKeysEnabled) || | 369 if (pref_service->GetBoolean(prefs::kStickyKeysEnabled) || |
| 364 pref_service->GetBoolean(prefs::kLargeCursorEnabled) || | 370 pref_service->GetBoolean(prefs::kLargeCursorEnabled) || |
| 365 pref_service->GetBoolean(prefs::kSpokenFeedbackEnabled) || | |
| 366 pref_service->GetBoolean(prefs::kHighContrastEnabled) || | 371 pref_service->GetBoolean(prefs::kHighContrastEnabled) || |
| 367 pref_service->GetBoolean(prefs::kAutoclickEnabled) || | 372 pref_service->GetBoolean(prefs::kAutoclickEnabled) || |
| 368 pref_service->GetBoolean(prefs::kShouldAlwaysShowAccessibilityMenu) || | 373 pref_service->GetBoolean(prefs::kShouldAlwaysShowAccessibilityMenu) || |
| 369 pref_service->GetBoolean(prefs::kScreenMagnifierEnabled)) | 374 pref_service->GetBoolean(prefs::kScreenMagnifierEnabled)) |
| 370 return true; | 375 return true; |
| 371 } | 376 } |
| 372 return false; | 377 return false; |
| 373 } | 378 } |
| 374 | 379 |
| 375 void AccessibilityManager::EnableLargeCursor(bool enabled) { | 380 void AccessibilityManager::EnableLargeCursor(bool enabled) { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 sticky_keys_enabled_ = enabled; | 446 sticky_keys_enabled_ = enabled; |
| 442 #if defined(USE_ASH) | 447 #if defined(USE_ASH) |
| 443 // Sticky keys is implemented only in ash. | 448 // Sticky keys is implemented only in ash. |
| 444 ash::Shell::GetInstance()->sticky_keys_controller()->Enable(enabled); | 449 ash::Shell::GetInstance()->sticky_keys_controller()->Enable(enabled); |
| 445 #endif | 450 #endif |
| 446 } | 451 } |
| 447 | 452 |
| 448 void AccessibilityManager::EnableSpokenFeedback( | 453 void AccessibilityManager::EnableSpokenFeedback( |
| 449 bool enabled, | 454 bool enabled, |
| 450 ash::AccessibilityNotificationVisibility notify) { | 455 ash::AccessibilityNotificationVisibility notify) { |
| 451 if (!profile_) | 456 if (!g_browser_process) |
| 452 return; | 457 return; |
| 453 | 458 |
| 454 ash::Shell::GetInstance()->metrics()->RecordUserMetricsAction( | 459 ash::Shell::GetInstance()->metrics()->RecordUserMetricsAction( |
| 455 enabled ? ash::UMA_STATUS_AREA_ENABLE_SPOKEN_FEEDBACK | 460 enabled ? ash::UMA_STATUS_AREA_ENABLE_SPOKEN_FEEDBACK |
| 456 : ash::UMA_STATUS_AREA_DISABLE_SPOKEN_FEEDBACK); | 461 : ash::UMA_STATUS_AREA_DISABLE_SPOKEN_FEEDBACK); |
| 457 | 462 |
| 458 spoken_feedback_notification_ = notify; | 463 spoken_feedback_notification_ = notify; |
| 459 | 464 |
| 460 PrefService* pref_service = profile_->GetPrefs(); | 465 PrefService* global_pref_service = g_browser_process->local_state(); |
| 461 pref_service->SetBoolean( | 466 global_pref_service->SetBoolean( |
| 462 prefs::kSpokenFeedbackEnabled, enabled); | 467 prefs::kSpokenFeedbackEnabled, enabled); |
| 463 pref_service->CommitPendingWrite(); | 468 global_pref_service->CommitPendingWrite(); |
| 464 | 469 |
| 465 spoken_feedback_notification_ = ash::A11Y_NOTIFICATION_NONE; | 470 spoken_feedback_notification_ = ash::A11Y_NOTIFICATION_NONE; |
| 466 } | 471 } |
| 467 | 472 |
| 468 void AccessibilityManager::UpdateSpokenFeedbackFromPref() { | 473 void AccessibilityManager::UpdateSpokenFeedbackFromPref() { |
| 469 if (!profile_) | 474 if (!g_browser_process) |
| 470 return; | 475 return; |
| 471 | 476 |
| 477 PrefService* global_pref_service = g_browser_process->local_state(); |
| 472 const bool enabled = | 478 const bool enabled = |
| 473 profile_->GetPrefs()->GetBoolean(prefs::kSpokenFeedbackEnabled); | 479 global_pref_service->GetBoolean(prefs::kSpokenFeedbackEnabled); |
| 474 | 480 |
| 475 if (spoken_feedback_enabled_ == enabled) | 481 if (spoken_feedback_enabled_ == enabled) |
| 476 return; | 482 return; |
| 477 | 483 |
| 478 spoken_feedback_enabled_ = enabled; | 484 spoken_feedback_enabled_ = enabled; |
| 479 | 485 |
| 480 ExtensionAccessibilityEventRouter::GetInstance()-> | 486 ExtensionAccessibilityEventRouter::GetInstance()-> |
| 481 SetAccessibilityEnabled(enabled); | 487 SetAccessibilityEnabled(enabled); |
| 482 | 488 |
| 483 AccessibilityStatusEventDetails details(enabled, | 489 AccessibilityStatusEventDetails details(enabled, |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 content::WebUI* login_web_ui = NULL; | 525 content::WebUI* login_web_ui = NULL; |
| 520 | 526 |
| 521 if (ProfileHelper::IsSigninProfile(profile_)) { | 527 if (ProfileHelper::IsSigninProfile(profile_)) { |
| 522 LoginDisplayHost* login_display_host = LoginDisplayHostImpl::default_host(); | 528 LoginDisplayHost* login_display_host = LoginDisplayHostImpl::default_host(); |
| 523 if (login_display_host) { | 529 if (login_display_host) { |
| 524 WebUILoginView* web_ui_login_view = | 530 WebUILoginView* web_ui_login_view = |
| 525 login_display_host->GetWebUILoginView(); | 531 login_display_host->GetWebUILoginView(); |
| 526 if (web_ui_login_view) | 532 if (web_ui_login_view) |
| 527 login_web_ui = web_ui_login_view->GetWebUI(); | 533 login_web_ui = web_ui_login_view->GetWebUI(); |
| 528 } | 534 } |
| 535 |
| 536 // Lock screen uses the signin progile. |
| 537 chrome_vox_loaded_on_lock_screen_ = true; |
| 529 } | 538 } |
| 530 | 539 |
| 531 LoadChromeVoxExtension(profile_, login_web_ui); | 540 LoadChromeVoxExtension(profile_, login_web_ui); |
| 532 chrome_vox_loaded_on_user_screen_ = true; | 541 chrome_vox_loaded_on_user_screen_ = true; |
| 533 } | 542 } |
| 534 | 543 |
| 535 void AccessibilityManager::LoadChromeVoxToLockScreen() { | 544 void AccessibilityManager::LoadChromeVoxToLockScreen() { |
| 536 if (chrome_vox_loaded_on_lock_screen_) | 545 if (chrome_vox_loaded_on_lock_screen_) |
| 537 return; | 546 return; |
| 538 | 547 |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 pref_change_registrar_->Init(profile->GetPrefs()); | 711 pref_change_registrar_->Init(profile->GetPrefs()); |
| 703 pref_change_registrar_->Add( | 712 pref_change_registrar_->Add( |
| 704 prefs::kLargeCursorEnabled, | 713 prefs::kLargeCursorEnabled, |
| 705 base::Bind(&AccessibilityManager::UpdateLargeCursorFromPref, | 714 base::Bind(&AccessibilityManager::UpdateLargeCursorFromPref, |
| 706 base::Unretained(this))); | 715 base::Unretained(this))); |
| 707 pref_change_registrar_->Add( | 716 pref_change_registrar_->Add( |
| 708 prefs::kStickyKeysEnabled, | 717 prefs::kStickyKeysEnabled, |
| 709 base::Bind(&AccessibilityManager::UpdateStickyKeysFromPref, | 718 base::Bind(&AccessibilityManager::UpdateStickyKeysFromPref, |
| 710 base::Unretained(this))); | 719 base::Unretained(this))); |
| 711 pref_change_registrar_->Add( | 720 pref_change_registrar_->Add( |
| 712 prefs::kSpokenFeedbackEnabled, | |
| 713 base::Bind(&AccessibilityManager::UpdateSpokenFeedbackFromPref, | |
| 714 base::Unretained(this))); | |
| 715 pref_change_registrar_->Add( | |
| 716 prefs::kHighContrastEnabled, | 721 prefs::kHighContrastEnabled, |
| 717 base::Bind(&AccessibilityManager::UpdateHighContrastFromPref, | 722 base::Bind(&AccessibilityManager::UpdateHighContrastFromPref, |
| 718 base::Unretained(this))); | 723 base::Unretained(this))); |
| 719 pref_change_registrar_->Add( | 724 pref_change_registrar_->Add( |
| 720 prefs::kAutoclickEnabled, | 725 prefs::kAutoclickEnabled, |
| 721 base::Bind(&AccessibilityManager::UpdateAutoclickFromPref, | 726 base::Bind(&AccessibilityManager::UpdateAutoclickFromPref, |
| 722 base::Unretained(this))); | 727 base::Unretained(this))); |
| 723 pref_change_registrar_->Add( | 728 pref_change_registrar_->Add( |
| 724 prefs::kAutoclickDelayMs, | 729 prefs::kAutoclickDelayMs, |
| 725 base::Bind(&AccessibilityManager::UpdateAutoclickDelayFromPref, | 730 base::Bind(&AccessibilityManager::UpdateAutoclickDelayFromPref, |
| 726 base::Unretained(this))); | 731 base::Unretained(this))); |
| 727 | 732 |
| 728 local_state_pref_change_registrar_.reset(new PrefChangeRegistrar); | 733 local_state_pref_change_registrar_.reset(new PrefChangeRegistrar); |
| 729 local_state_pref_change_registrar_->Init(g_browser_process->local_state()); | 734 local_state_pref_change_registrar_->Init(g_browser_process->local_state()); |
| 730 local_state_pref_change_registrar_->Add( | 735 local_state_pref_change_registrar_->Add( |
| 736 prefs::kSpokenFeedbackEnabled, |
| 737 base::Bind(&AccessibilityManager::UpdateSpokenFeedbackFromPref, |
| 738 base::Unretained(this))); |
| 739 local_state_pref_change_registrar_->Add( |
| 731 prefs::kApplicationLocale, | 740 prefs::kApplicationLocale, |
| 732 base::Bind(&AccessibilityManager::LocalePrefChanged, | 741 base::Bind(&AccessibilityManager::LocalePrefChanged, |
| 733 base::Unretained(this))); | 742 base::Unretained(this))); |
| 734 | 743 |
| 735 content::BrowserAccessibilityState::GetInstance()->AddHistogramCallback( | 744 content::BrowserAccessibilityState::GetInstance()->AddHistogramCallback( |
| 736 base::Bind( | 745 base::Bind( |
| 737 &AccessibilityManager::UpdateChromeOSAccessibilityHistograms, | 746 &AccessibilityManager::UpdateChromeOSAccessibilityHistograms, |
| 738 base::Unretained(this))); | 747 base::Unretained(this))); |
| 739 } | 748 } |
| 740 | 749 |
| 741 large_cursor_pref_handler_.HandleProfileChanged(profile_, profile); | 750 large_cursor_pref_handler_.HandleProfileChanged(profile_, profile); |
| 742 spoken_feedback_pref_handler_.HandleProfileChanged(profile_, profile); | |
| 743 high_contrast_pref_handler_.HandleProfileChanged(profile_, profile); | 751 high_contrast_pref_handler_.HandleProfileChanged(profile_, profile); |
| 744 autoclick_pref_handler_.HandleProfileChanged(profile_, profile); | 752 autoclick_pref_handler_.HandleProfileChanged(profile_, profile); |
| 745 autoclick_delay_pref_handler_.HandleProfileChanged(profile_, profile); | 753 autoclick_delay_pref_handler_.HandleProfileChanged(profile_, profile); |
| 746 | 754 |
| 747 if (profile && spoken_feedback_enabled_) | 755 if (profile && spoken_feedback_enabled_) |
| 748 SetUpPreLoadChromeVox(profile); | 756 SetUpPreLoadChromeVox(profile); |
| 749 | 757 |
| 750 if (!profile_ && profile) | 758 if (!profile_ && profile) |
| 751 CheckBrailleState(); | 759 CheckBrailleState(); |
| 752 | 760 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 861 case chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED: { | 869 case chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED: { |
| 862 bool is_screen_locked = *content::Details<bool>(details).ptr(); | 870 bool is_screen_locked = *content::Details<bool>(details).ptr(); |
| 863 if (spoken_feedback_enabled_) { | 871 if (spoken_feedback_enabled_) { |
| 864 if (is_screen_locked) { | 872 if (is_screen_locked) { |
| 865 LoadChromeVoxToLockScreen(); | 873 LoadChromeVoxToLockScreen(); |
| 866 | 874 |
| 867 // Status tray gets verbalized by user screen ChromeVox, so we need | 875 // Status tray gets verbalized by user screen ChromeVox, so we need |
| 868 // this as well. | 876 // this as well. |
| 869 LoadChromeVoxToUserScreen(); | 877 LoadChromeVoxToUserScreen(); |
| 870 } else { | 878 } else { |
| 871 // Lock screen destroys its resources; no need for us to explicitly | 879 // If spoken feedback was enabled, also enable it on the user screen. |
| 872 // unload ChromeVox. | |
| 873 chrome_vox_loaded_on_lock_screen_ = false; | |
| 874 | |
| 875 // However, if spoken feedback was enabled, also enable it on the user | |
| 876 // screen. | |
| 877 LoadChromeVoxToUserScreen(); | 880 LoadChromeVoxToUserScreen(); |
| 878 } | 881 } |
| 879 } | 882 } |
| 880 break; | 883 break; |
| 881 } | 884 } |
| 882 case chrome::NOTIFICATION_EXTENSION_UNLOADED: { | 885 case chrome::NOTIFICATION_EXTENSION_UNLOADED: { |
| 883 extensions::UnloadedExtensionInfo* info = | 886 extensions::UnloadedExtensionInfo* info = |
| 884 content::Details<extensions::UnloadedExtensionInfo>(details).ptr(); | 887 content::Details<extensions::UnloadedExtensionInfo>(details).ptr(); |
| 885 const extensions::Extension* extension = info->extension; | 888 const extensions::Extension* extension = info->extension; |
| 886 if (extension->id() == extension_misc::kChromeVoxExtensionId) { | 889 if (extension->id() == extension_misc::kChromeVoxExtensionId) { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 955 event_router()->UnregisterObserver(this); | 958 event_router()->UnregisterObserver(this); |
| 956 chromevox_profiles_.erase(profile); | 959 chromevox_profiles_.erase(profile); |
| 957 } | 960 } |
| 958 } | 961 } |
| 959 | 962 |
| 960 void AccessibilityManager::PlaySound(int sound_key) const { | 963 void AccessibilityManager::PlaySound(int sound_key) const { |
| 961 media::SoundsManager::Get()->Play(sound_key); | 964 media::SoundsManager::Get()->Play(sound_key); |
| 962 } | 965 } |
| 963 | 966 |
| 964 } // namespace chromeos | 967 } // namespace chromeos |
| OLD | NEW |