Chromium Code Reviews| 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 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 336 manager->Initialize( | 336 manager->Initialize( |
| 337 SOUND_SPOKEN_FEEDBACK_DISABLED, | 337 SOUND_SPOKEN_FEEDBACK_DISABLED, |
| 338 bundle.GetRawDataResource(IDR_SOUND_SPOKEN_FEEDBACK_DISABLED_WAV)); | 338 bundle.GetRawDataResource(IDR_SOUND_SPOKEN_FEEDBACK_DISABLED_WAV)); |
| 339 } | 339 } |
| 340 | 340 |
| 341 AccessibilityManager::~AccessibilityManager() { | 341 AccessibilityManager::~AccessibilityManager() { |
| 342 CHECK(this == g_accessibility_manager); | 342 CHECK(this == g_accessibility_manager); |
| 343 | 343 |
| 344 // Component extensions don't always notify us when they're unloaded. Ensure | 344 // Component extensions don't always notify us when they're unloaded. Ensure |
| 345 // we clean up ChromeVox observers here. | 345 // we clean up ChromeVox observers here. |
| 346 if (profile_) { | 346 for (std::set<Profile*>::iterator it = chromevox_profiles_.begin(); |
| 347 extensions::ExtensionSystem::Get(profile_)-> | 347 it != chromevox_profiles_.end(); |
| 348 it++) { | |
| 349 extensions::ExtensionSystem::Get(*it)-> | |
| 348 event_router()->UnregisterObserver(this); | 350 event_router()->UnregisterObserver(this); |
| 349 } | 351 } |
| 350 } | 352 } |
| 351 | 353 |
| 352 bool AccessibilityManager::ShouldShowAccessibilityMenu() { | 354 bool AccessibilityManager::ShouldShowAccessibilityMenu() { |
| 353 // If any of the loaded profiles has an accessibility feature turned on - or | 355 // If any of the loaded profiles has an accessibility feature turned on - or |
| 354 // enforced to always show the menu - we return true to show the menu. | 356 // enforced to always show the menu - we return true to show the menu. |
| 355 std::vector<Profile*> profiles = | 357 std::vector<Profile*> profiles = |
| 356 g_browser_process->profile_manager()->GetLoadedProfiles(); | 358 g_browser_process->profile_manager()->GetLoadedProfiles(); |
| 357 for (std::vector<Profile*>::iterator it = profiles.begin(); | 359 for (std::vector<Profile*>::iterator it = profiles.begin(); |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 738 | 740 |
| 739 large_cursor_pref_handler_.HandleProfileChanged(profile_, profile); | 741 large_cursor_pref_handler_.HandleProfileChanged(profile_, profile); |
| 740 spoken_feedback_pref_handler_.HandleProfileChanged(profile_, profile); | 742 spoken_feedback_pref_handler_.HandleProfileChanged(profile_, profile); |
| 741 high_contrast_pref_handler_.HandleProfileChanged(profile_, profile); | 743 high_contrast_pref_handler_.HandleProfileChanged(profile_, profile); |
| 742 autoclick_pref_handler_.HandleProfileChanged(profile_, profile); | 744 autoclick_pref_handler_.HandleProfileChanged(profile_, profile); |
| 743 autoclick_delay_pref_handler_.HandleProfileChanged(profile_, profile); | 745 autoclick_delay_pref_handler_.HandleProfileChanged(profile_, profile); |
| 744 | 746 |
| 745 if (!profile && profile_) { | 747 if (!profile && profile_) { |
| 746 extensions::ExtensionSystem::Get(profile_)-> | 748 extensions::ExtensionSystem::Get(profile_)-> |
| 747 event_router()->UnregisterObserver(this); | 749 event_router()->UnregisterObserver(this); |
| 750 std::set<Profile*>::iterator item = chromevox_profiles_.find(profile_); | |
| 751 if (item != chromevox_profiles_.end()) | |
| 752 chromevox_profiles_.erase(item); | |
|
James Cook
2014/01/06 20:38:19
I think you can just do chromevox_profiles_.erase(
| |
| 748 } | 753 } |
| 749 | 754 |
| 750 if (profile && spoken_feedback_enabled_) | 755 if (profile && spoken_feedback_enabled_) |
| 751 SetUpPreLoadChromeVox(profile); | 756 SetUpPreLoadChromeVox(profile); |
| 752 | 757 |
| 753 if (!profile_ && profile) | 758 if (!profile_ && profile) |
| 754 CheckBrailleState(); | 759 CheckBrailleState(); |
| 755 | 760 |
| 756 profile_ = profile; | 761 profile_ = profile; |
| 757 UpdateLargeCursorFromPref(); | 762 UpdateLargeCursorFromPref(); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 847 should_speak_chrome_vox_announcements_on_user_screen_ = true; | 852 should_speak_chrome_vox_announcements_on_user_screen_ = true; |
| 848 | 853 |
| 849 // Add a session state observer to be able to monitor session changes. | 854 // Add a session state observer to be able to monitor session changes. |
| 850 if (!session_state_observer_.get() && ash::Shell::HasInstance()) | 855 if (!session_state_observer_.get() && ash::Shell::HasInstance()) |
| 851 session_state_observer_.reset( | 856 session_state_observer_.reset( |
| 852 new ash::ScopedSessionStateObserver(this)); | 857 new ash::ScopedSessionStateObserver(this)); |
| 853 break; | 858 break; |
| 854 case chrome::NOTIFICATION_PROFILE_DESTROYED: { | 859 case chrome::NOTIFICATION_PROFILE_DESTROYED: { |
| 855 // Update |profile_| when exiting a session or shutting down. | 860 // Update |profile_| when exiting a session or shutting down. |
| 856 Profile* profile = content::Source<Profile>(source).ptr(); | 861 Profile* profile = content::Source<Profile>(source).ptr(); |
| 857 if (profile_ == profile) | 862 if (profile_ == profile) |
|
James Cook
2014/01/06 20:38:19
Should this clean up observers if *any* profile in
| |
| 858 SetProfile(NULL); | 863 SetProfile(NULL); |
| 859 break; | 864 break; |
| 860 } | 865 } |
| 861 case chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED: { | 866 case chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED: { |
| 862 bool is_screen_locked = *content::Details<bool>(details).ptr(); | 867 bool is_screen_locked = *content::Details<bool>(details).ptr(); |
| 863 if (spoken_feedback_enabled_) { | 868 if (spoken_feedback_enabled_) { |
| 864 if (is_screen_locked) { | 869 if (is_screen_locked) { |
| 865 LoadChromeVoxToLockScreen(); | 870 LoadChromeVoxToLockScreen(); |
| 866 | 871 |
| 867 // Status tray gets verbalized by user screen ChromeVox, so we need | 872 // Status tray gets verbalized by user screen ChromeVox, so we need |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 937 | 942 |
| 938 void AccessibilityManager::SetUpPreLoadChromeVox(Profile* profile) { | 943 void AccessibilityManager::SetUpPreLoadChromeVox(Profile* profile) { |
| 939 // Do any setup work needed immediately before ChromeVox actually loads. | 944 // Do any setup work needed immediately before ChromeVox actually loads. |
| 940 PlaySound(SOUND_SPOKEN_FEEDBACK_ENABLED); | 945 PlaySound(SOUND_SPOKEN_FEEDBACK_ENABLED); |
| 941 | 946 |
| 942 if (profile) { | 947 if (profile) { |
| 943 extensions::ExtensionSystem::Get(profile)-> | 948 extensions::ExtensionSystem::Get(profile)-> |
| 944 event_router()->RegisterObserver(this, | 949 event_router()->RegisterObserver(this, |
| 945 extensions::api::experimental_accessibility:: | 950 extensions::api::experimental_accessibility:: |
| 946 OnChromeVoxLoadStateChanged::kEventName); | 951 OnChromeVoxLoadStateChanged::kEventName); |
| 952 chromevox_profiles_.insert(profile); | |
| 947 } | 953 } |
| 948 } | 954 } |
| 949 | 955 |
| 950 void AccessibilityManager::TearDownPostUnloadChromeVox(Profile* profile) { | 956 void AccessibilityManager::TearDownPostUnloadChromeVox(Profile* profile) { |
| 951 // Do any teardown work needed immediately after ChromeVox actually unloads. | 957 // Do any teardown work needed immediately after ChromeVox actually unloads. |
| 952 if (profile) { | 958 if (profile) { |
| 953 extensions::ExtensionSystem::Get(profile)-> | 959 extensions::ExtensionSystem::Get(profile)-> |
| 954 event_router()->UnregisterObserver(this); | 960 event_router()->UnregisterObserver(this); |
| 961 std::set<Profile*>::iterator item = chromevox_profiles_.find(profile_); | |
| 962 if (item != chromevox_profiles_.end()) | |
|
James Cook
2014/01/06 20:38:19
same thing, I don't think you need to check if it
| |
| 963 chromevox_profiles_.erase(item); | |
| 955 } | 964 } |
| 956 } | 965 } |
| 957 | 966 |
| 958 void AccessibilityManager::PlaySound(int sound_key) const { | 967 void AccessibilityManager::PlaySound(int sound_key) const { |
| 959 if (system_sounds_enabled_) | 968 media::SoundsManager::Get()->Play(sound_key); |
| 960 media::SoundsManager::Get()->Play(sound_key); | |
| 961 } | 969 } |
| 962 | 970 |
| 963 } // namespace chromeos | 971 } // namespace chromeos |
| OLD | NEW |