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/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/system/tray/system_tray_notifier.h" | 10 #include "ash/system/tray/system_tray_notifier.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "chrome/browser/chromeos/login/screen_locker.h" | 25 #include "chrome/browser/chromeos/login/screen_locker.h" |
26 #include "chrome/browser/chromeos/login/user_manager.h" | 26 #include "chrome/browser/chromeos/login/user_manager.h" |
27 #include "chrome/browser/chromeos/login/webui_login_view.h" | 27 #include "chrome/browser/chromeos/login/webui_login_view.h" |
28 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 28 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
29 #include "chrome/browser/extensions/component_loader.h" | 29 #include "chrome/browser/extensions/component_loader.h" |
30 #include "chrome/browser/extensions/extension_service.h" | 30 #include "chrome/browser/extensions/extension_service.h" |
31 #include "chrome/browser/extensions/extension_system.h" | 31 #include "chrome/browser/extensions/extension_system.h" |
32 #include "chrome/browser/profiles/profile.h" | 32 #include "chrome/browser/profiles/profile.h" |
33 #include "chrome/browser/profiles/profile_manager.h" | 33 #include "chrome/browser/profiles/profile_manager.h" |
34 #include "chrome/browser/speech/tts_controller.h" | 34 #include "chrome/browser/speech/tts_controller.h" |
| 35 #include "chrome/common/extensions/api/experimental_accessibility.h" |
35 #include "chrome/common/extensions/extension.h" | 36 #include "chrome/common/extensions/extension.h" |
36 #include "chrome/common/extensions/extension_messages.h" | 37 #include "chrome/common/extensions/extension_messages.h" |
37 #include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h" | 38 #include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h" |
38 #include "chrome/common/pref_names.h" | 39 #include "chrome/common/pref_names.h" |
39 #include "chromeos/login/login_state.h" | 40 #include "chromeos/login/login_state.h" |
40 #include "content/public/browser/browser_accessibility_state.h" | 41 #include "content/public/browser/browser_accessibility_state.h" |
41 #include "content/public/browser/browser_thread.h" | 42 #include "content/public/browser/browser_thread.h" |
42 #include "content/public/browser/notification_details.h" | 43 #include "content/public/browser/notification_details.h" |
43 #include "content/public/browser/notification_service.h" | 44 #include "content/public/browser/notification_service.h" |
44 #include "content/public/browser/notification_source.h" | 45 #include "content/public/browser/notification_source.h" |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 spoken_feedback_pref_handler_(prefs::kSpokenFeedbackEnabled), | 281 spoken_feedback_pref_handler_(prefs::kSpokenFeedbackEnabled), |
281 high_contrast_pref_handler_(prefs::kHighContrastEnabled), | 282 high_contrast_pref_handler_(prefs::kHighContrastEnabled), |
282 autoclick_pref_handler_(prefs::kAutoclickEnabled), | 283 autoclick_pref_handler_(prefs::kAutoclickEnabled), |
283 autoclick_delay_pref_handler_(prefs::kAutoclickDelayMs), | 284 autoclick_delay_pref_handler_(prefs::kAutoclickDelayMs), |
284 large_cursor_enabled_(false), | 285 large_cursor_enabled_(false), |
285 sticky_keys_enabled_(false), | 286 sticky_keys_enabled_(false), |
286 spoken_feedback_enabled_(false), | 287 spoken_feedback_enabled_(false), |
287 high_contrast_enabled_(false), | 288 high_contrast_enabled_(false), |
288 autoclick_delay_ms_(ash::AutoclickController::kDefaultAutoclickDelayMs), | 289 autoclick_delay_ms_(ash::AutoclickController::kDefaultAutoclickDelayMs), |
289 spoken_feedback_notification_(ash::A11Y_NOTIFICATION_NONE), | 290 spoken_feedback_notification_(ash::A11Y_NOTIFICATION_NONE), |
290 weak_ptr_factory_(this) { | 291 weak_ptr_factory_(this), |
291 | 292 should_speak_chrome_vox_announcements_on_user_screen_(true) { |
292 notification_registrar_.Add(this, | 293 notification_registrar_.Add(this, |
293 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, | 294 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, |
294 content::NotificationService::AllSources()); | 295 content::NotificationService::AllSources()); |
295 notification_registrar_.Add(this, | 296 notification_registrar_.Add(this, |
296 chrome::NOTIFICATION_SESSION_STARTED, | 297 chrome::NOTIFICATION_SESSION_STARTED, |
297 content::NotificationService::AllSources()); | 298 content::NotificationService::AllSources()); |
298 notification_registrar_.Add(this, | 299 notification_registrar_.Add(this, |
299 chrome::NOTIFICATION_PROFILE_DESTROYED, | 300 chrome::NOTIFICATION_PROFILE_DESTROYED, |
300 content::NotificationService::AllSources()); | 301 content::NotificationService::AllSources()); |
301 notification_registrar_.Add(this, | 302 notification_registrar_.Add(this, |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 return; | 403 return; |
403 | 404 |
404 const bool enabled = | 405 const bool enabled = |
405 profile_->GetPrefs()->GetBoolean(prefs::kSpokenFeedbackEnabled); | 406 profile_->GetPrefs()->GetBoolean(prefs::kSpokenFeedbackEnabled); |
406 | 407 |
407 if (spoken_feedback_enabled_ == enabled) | 408 if (spoken_feedback_enabled_ == enabled) |
408 return; | 409 return; |
409 | 410 |
410 spoken_feedback_enabled_ = enabled; | 411 spoken_feedback_enabled_ = enabled; |
411 | 412 |
412 Speak(l10n_util::GetStringUTF8( | |
413 enabled ? IDS_CHROMEOS_ACC_SPOKEN_FEEDBACK_ENABLED : | |
414 IDS_CHROMEOS_ACC_SPOKEN_FEEDBACK_DISABLED).c_str()); | |
415 | |
416 ExtensionAccessibilityEventRouter::GetInstance()-> | 413 ExtensionAccessibilityEventRouter::GetInstance()-> |
417 SetAccessibilityEnabled(enabled); | 414 SetAccessibilityEnabled(enabled); |
418 | 415 |
419 AccessibilityStatusEventDetails details(enabled, | 416 AccessibilityStatusEventDetails details(enabled, |
420 spoken_feedback_notification_); | 417 spoken_feedback_notification_); |
421 content::NotificationService::current()->Notify( | 418 content::NotificationService::current()->Notify( |
422 chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK, | 419 chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK, |
423 content::NotificationService::AllSources(), | 420 content::NotificationService::AllSources(), |
424 content::Details<AccessibilityStatusEventDetails>(&details)); | 421 content::Details<AccessibilityStatusEventDetails>(&details)); |
425 | 422 |
426 if (enabled) | 423 if (enabled) { |
427 LoadChromeVox(); | 424 LoadChromeVox(); |
428 else | 425 ExtensionAccessibilityEventRouter::GetInstance()-> |
429 UnloadChromeVox(); | 426 OnChromeVoxLoadStateChanged(profile_, |
| 427 true, |
| 428 chrome_vox_loaded_on_lock_screen_ || |
| 429 should_speak_chrome_vox_announcements_on_user_screen_); |
| 430 |
| 431 should_speak_chrome_vox_announcements_on_user_screen_ = |
| 432 chrome_vox_loaded_on_lock_screen_; |
| 433 } else { |
| 434 ExtensionAccessibilityEventRouter::GetInstance()-> |
| 435 OnChromeVoxLoadStateChanged(profile_, false, false); |
| 436 } |
430 } | 437 } |
431 | 438 |
432 void AccessibilityManager::LoadChromeVox() { | 439 void AccessibilityManager::LoadChromeVox() { |
433 ScreenLocker* screen_locker = ScreenLocker::default_screen_locker(); | 440 ScreenLocker* screen_locker = ScreenLocker::default_screen_locker(); |
434 if (screen_locker && screen_locker->locked()) { | 441 if (screen_locker && screen_locker->locked()) { |
435 // If on the lock screen, loads ChromeVox only to the lock screen as for | 442 // If on the lock screen, loads ChromeVox only to the lock screen as for |
436 // now. On unlock, it will be loaded to the user screen. | 443 // now. On unlock, it will be loaded to the user screen. |
437 // (see. AccessibilityManager::Observe()) | 444 // (see. AccessibilityManager::Observe()) |
438 LoadChromeVoxToLockScreen(); | 445 LoadChromeVoxToLockScreen(); |
439 return; | 446 return; |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 local_state_pref_change_registrar_->Init(g_browser_process->local_state()); | 686 local_state_pref_change_registrar_->Init(g_browser_process->local_state()); |
680 local_state_pref_change_registrar_->Add( | 687 local_state_pref_change_registrar_->Add( |
681 prefs::kApplicationLocale, | 688 prefs::kApplicationLocale, |
682 base::Bind(&AccessibilityManager::LocalePrefChanged, | 689 base::Bind(&AccessibilityManager::LocalePrefChanged, |
683 base::Unretained(this))); | 690 base::Unretained(this))); |
684 | 691 |
685 content::BrowserAccessibilityState::GetInstance()->AddHistogramCallback( | 692 content::BrowserAccessibilityState::GetInstance()->AddHistogramCallback( |
686 base::Bind( | 693 base::Bind( |
687 &AccessibilityManager::UpdateChromeOSAccessibilityHistograms, | 694 &AccessibilityManager::UpdateChromeOSAccessibilityHistograms, |
688 base::Unretained(this))); | 695 base::Unretained(this))); |
| 696 |
| 697 extensions::ExtensionSystem::Get(profile)->event_router()->RegisterObserver( |
| 698 this, extensions::api::experimental_accessibility:: |
| 699 OnChromeVoxLoadStateChanged::kEventName); |
689 } | 700 } |
690 | 701 |
691 large_cursor_pref_handler_.HandleProfileChanged(profile_, profile); | 702 large_cursor_pref_handler_.HandleProfileChanged(profile_, profile); |
692 spoken_feedback_pref_handler_.HandleProfileChanged(profile_, profile); | 703 spoken_feedback_pref_handler_.HandleProfileChanged(profile_, profile); |
693 high_contrast_pref_handler_.HandleProfileChanged(profile_, profile); | 704 high_contrast_pref_handler_.HandleProfileChanged(profile_, profile); |
694 autoclick_pref_handler_.HandleProfileChanged(profile_, profile); | 705 autoclick_pref_handler_.HandleProfileChanged(profile_, profile); |
695 autoclick_delay_pref_handler_.HandleProfileChanged(profile_, profile); | 706 autoclick_delay_pref_handler_.HandleProfileChanged(profile_, profile); |
696 | 707 |
697 if (!profile_ && profile) | 708 if (!profile_ && profile) |
698 CheckBrailleState(); | 709 CheckBrailleState(); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
762 case chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE: { | 773 case chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE: { |
763 // Update |profile_| when entering the login screen. | 774 // Update |profile_| when entering the login screen. |
764 Profile* profile = ProfileManager::GetDefaultProfile(); | 775 Profile* profile = ProfileManager::GetDefaultProfile(); |
765 if (ProfileHelper::IsSigninProfile(profile)) | 776 if (ProfileHelper::IsSigninProfile(profile)) |
766 SetProfile(profile); | 777 SetProfile(profile); |
767 break; | 778 break; |
768 } | 779 } |
769 case chrome::NOTIFICATION_SESSION_STARTED: | 780 case chrome::NOTIFICATION_SESSION_STARTED: |
770 // Update |profile_| when entering a session. | 781 // Update |profile_| when entering a session. |
771 SetProfile(ProfileManager::GetDefaultProfile()); | 782 SetProfile(ProfileManager::GetDefaultProfile()); |
| 783 |
| 784 // Ensure ChromeVox makes announcements at the start of new sessions. |
| 785 should_speak_chrome_vox_announcements_on_user_screen_ = true; |
772 break; | 786 break; |
773 case chrome::NOTIFICATION_PROFILE_DESTROYED: { | 787 case chrome::NOTIFICATION_PROFILE_DESTROYED: { |
774 // Update |profile_| when exiting a session or shutting down. | 788 // Update |profile_| when exiting a session or shutting down. |
775 Profile* profile = content::Source<Profile>(source).ptr(); | 789 Profile* profile = content::Source<Profile>(source).ptr(); |
776 if (profile_ == profile) | 790 if (profile_ == profile) |
777 SetProfile(NULL); | 791 SetProfile(NULL); |
778 break; | 792 break; |
779 } | 793 } |
780 case chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED: { | 794 case chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED: { |
781 bool is_screen_locked = *content::Details<bool>(details).ptr(); | 795 bool is_screen_locked = *content::Details<bool>(details).ptr(); |
782 if (is_screen_locked) { | 796 if (is_screen_locked) { |
783 if (spoken_feedback_enabled_) | 797 if (spoken_feedback_enabled_) |
784 LoadChromeVoxToLockScreen(); | 798 LoadChromeVoxToLockScreen(); |
785 } else { | 799 } else { |
786 UnloadChromeVoxFromLockScreen(); | 800 UnloadChromeVoxFromLockScreen(); |
787 | 801 |
788 if (spoken_feedback_enabled_) | 802 if (spoken_feedback_enabled_) |
789 LoadChromeVoxToUserScreen(); | 803 LoadChromeVoxToUserScreen(); |
790 } | 804 } |
791 } | 805 } |
792 } | 806 } |
793 } | 807 } |
794 | 808 |
795 void AccessibilityManager::OnDisplayStateChanged( | 809 void AccessibilityManager::OnDisplayStateChanged( |
796 const DisplayState& display_state) { | 810 const DisplayState& display_state) { |
797 if (display_state.available) | 811 if (display_state.available) |
798 EnableSpokenFeedback(true, ash::A11Y_NOTIFICATION_SHOW); | 812 EnableSpokenFeedback(true, ash::A11Y_NOTIFICATION_SHOW); |
799 } | 813 } |
| 814 |
| 815 void AccessibilityManager::OnListenerAdded( |
| 816 const extensions::EventListenerInfo& details) { |
| 817 if (details.extension_id != extension_misc::kChromeVoxExtensionId) |
| 818 return; |
| 819 |
| 820 ExtensionAccessibilityEventRouter::GetInstance()-> |
| 821 OnChromeVoxLoadStateChanged(profile_, |
| 822 IsSpokenFeedbackEnabled(), |
| 823 chrome_vox_loaded_on_lock_screen_ || |
| 824 should_speak_chrome_vox_announcements_on_user_screen_); |
| 825 |
| 826 should_speak_chrome_vox_announcements_on_user_screen_ = |
| 827 chrome_vox_loaded_on_lock_screen_; |
| 828 } |
| 829 |
| 830 void AccessibilityManager::OnListenerRemoved( |
| 831 const extensions::EventListenerInfo& details) { |
| 832 if (details.extension_id != extension_misc::kChromeVoxExtensionId) |
| 833 return; |
| 834 |
| 835 UnloadChromeVox(); |
| 836 } |
| 837 |
800 } // namespace chromeos | 838 } // namespace chromeos |
OLD | NEW |