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/audio/sounds.h" | 7 #include "ash/audio/sounds.h" |
8 #include "ash/autoclick/autoclick_controller.h" | 8 #include "ash/autoclick/autoclick_controller.h" |
9 #include "ash/high_contrast/high_contrast_controller.h" | 9 #include "ash/high_contrast/high_contrast_controller.h" |
10 #include "ash/metrics/user_metrics_recorder.h" | 10 #include "ash/metrics/user_metrics_recorder.h" |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 chrome::NOTIFICATION_SESSION_STARTED, | 316 chrome::NOTIFICATION_SESSION_STARTED, |
317 content::NotificationService::AllSources()); | 317 content::NotificationService::AllSources()); |
318 notification_registrar_.Add(this, | 318 notification_registrar_.Add(this, |
319 chrome::NOTIFICATION_PROFILE_DESTROYED, | 319 chrome::NOTIFICATION_PROFILE_DESTROYED, |
320 content::NotificationService::AllSources()); | 320 content::NotificationService::AllSources()); |
321 notification_registrar_.Add(this, | 321 notification_registrar_.Add(this, |
322 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, | 322 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, |
323 content::NotificationService::AllSources()); | 323 content::NotificationService::AllSources()); |
324 | 324 |
325 GetBrailleController()->AddObserver(this); | 325 GetBrailleController()->AddObserver(this); |
| 326 input_method::InputMethodManager::Get()->AddObserver(this); |
326 | 327 |
327 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 328 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
328 media::SoundsManager* manager = media::SoundsManager::Get(); | 329 media::SoundsManager* manager = media::SoundsManager::Get(); |
329 manager->Initialize(SOUND_SHUTDOWN, | 330 manager->Initialize(SOUND_SHUTDOWN, |
330 bundle.GetRawDataResource(IDR_SOUND_SHUTDOWN_WAV)); | 331 bundle.GetRawDataResource(IDR_SOUND_SHUTDOWN_WAV)); |
331 manager->Initialize( | 332 manager->Initialize( |
332 SOUND_SPOKEN_FEEDBACK_ENABLED, | 333 SOUND_SPOKEN_FEEDBACK_ENABLED, |
333 bundle.GetRawDataResource(IDR_SOUND_SPOKEN_FEEDBACK_ENABLED_WAV)); | 334 bundle.GetRawDataResource(IDR_SOUND_SPOKEN_FEEDBACK_ENABLED_WAV)); |
334 manager->Initialize( | 335 manager->Initialize( |
335 SOUND_SPOKEN_FEEDBACK_DISABLED, | 336 SOUND_SPOKEN_FEEDBACK_DISABLED, |
336 bundle.GetRawDataResource(IDR_SOUND_SPOKEN_FEEDBACK_DISABLED_WAV)); | 337 bundle.GetRawDataResource(IDR_SOUND_SPOKEN_FEEDBACK_DISABLED_WAV)); |
337 } | 338 } |
338 | 339 |
339 AccessibilityManager::~AccessibilityManager() { | 340 AccessibilityManager::~AccessibilityManager() { |
340 CHECK(this == g_accessibility_manager); | 341 CHECK(this == g_accessibility_manager); |
341 AccessibilityStatusEventDetails details( | 342 AccessibilityStatusEventDetails details( |
342 ACCESSIBILITY_MANAGER_SHUTDOWN, | 343 ACCESSIBILITY_MANAGER_SHUTDOWN, |
343 false, | 344 false, |
344 ash::A11Y_NOTIFICATION_NONE); | 345 ash::A11Y_NOTIFICATION_NONE); |
345 NotifyAccessibilityStatusChanged(details); | 346 NotifyAccessibilityStatusChanged(details); |
| 347 input_method::InputMethodManager::Get()->RemoveObserver(this); |
346 } | 348 } |
347 | 349 |
348 bool AccessibilityManager::ShouldShowAccessibilityMenu() { | 350 bool AccessibilityManager::ShouldShowAccessibilityMenu() { |
349 // If any of the loaded profiles has an accessibility feature turned on - or | 351 // If any of the loaded profiles has an accessibility feature turned on - or |
350 // enforced to always show the menu - we return true to show the menu. | 352 // enforced to always show the menu - we return true to show the menu. |
351 std::vector<Profile*> profiles = | 353 std::vector<Profile*> profiles = |
352 g_browser_process->profile_manager()->GetLoadedProfiles(); | 354 g_browser_process->profile_manager()->GetLoadedProfiles(); |
353 for (std::vector<Profile*>::iterator it = profiles.begin(); | 355 for (std::vector<Profile*>::iterator it = profiles.begin(); |
354 it != profiles.end(); | 356 it != profiles.end(); |
355 ++it) { | 357 ++it) { |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
746 base::Unretained(GetBrailleController())), | 748 base::Unretained(GetBrailleController())), |
747 base::Bind(&AccessibilityManager::ReceiveBrailleDisplayState, | 749 base::Bind(&AccessibilityManager::ReceiveBrailleDisplayState, |
748 weak_ptr_factory_.GetWeakPtr())); | 750 weak_ptr_factory_.GetWeakPtr())); |
749 } | 751 } |
750 | 752 |
751 void AccessibilityManager::ReceiveBrailleDisplayState( | 753 void AccessibilityManager::ReceiveBrailleDisplayState( |
752 scoped_ptr<extensions::api::braille_display_private::DisplayState> state) { | 754 scoped_ptr<extensions::api::braille_display_private::DisplayState> state) { |
753 OnDisplayStateChanged(*state); | 755 OnDisplayStateChanged(*state); |
754 } | 756 } |
755 | 757 |
| 758 // Overridden from InputMethodManager::Observer. |
| 759 void AccessibilityManager::InputMethodChanged( |
| 760 input_method::InputMethodManager* manager, |
| 761 bool show_message) { |
| 762 #if defined(USE_ASH) |
| 763 // Sticky keys is implemented only in ash. |
| 764 ash::Shell::GetInstance()->sticky_keys_controller()->SetModifiersEnabled( |
| 765 manager->IsMod3UsedByCurrentInputMethod(), |
| 766 manager->IsAltGrUsedByCurrentInputMethod()); |
| 767 #endif |
| 768 } |
756 | 769 |
757 void AccessibilityManager::SetProfile(Profile* profile) { | 770 void AccessibilityManager::SetProfile(Profile* profile) { |
758 pref_change_registrar_.reset(); | 771 pref_change_registrar_.reset(); |
759 local_state_pref_change_registrar_.reset(); | 772 local_state_pref_change_registrar_.reset(); |
760 | 773 |
761 if (profile) { | 774 if (profile) { |
762 // TODO(yoshiki): Move following code to PrefHandler. | 775 // TODO(yoshiki): Move following code to PrefHandler. |
763 pref_change_registrar_.reset(new PrefChangeRegistrar); | 776 pref_change_registrar_.reset(new PrefChangeRegistrar); |
764 pref_change_registrar_->Init(profile->GetPrefs()); | 777 pref_change_registrar_->Init(profile->GetPrefs()); |
765 pref_change_registrar_->Add( | 778 pref_change_registrar_->Add( |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
981 chrome_vox_loaded_on_lock_screen_; | 994 chrome_vox_loaded_on_lock_screen_; |
982 } | 995 } |
983 | 996 |
984 void AccessibilityManager::PostUnloadChromeVox(Profile* profile) { | 997 void AccessibilityManager::PostUnloadChromeVox(Profile* profile) { |
985 // Do any teardown work needed immediately after ChromeVox actually unloads. | 998 // Do any teardown work needed immediately after ChromeVox actually unloads. |
986 if (system_sounds_enabled_) | 999 if (system_sounds_enabled_) |
987 ash::PlaySystemSoundAlways(SOUND_SPOKEN_FEEDBACK_DISABLED); | 1000 ash::PlaySystemSoundAlways(SOUND_SPOKEN_FEEDBACK_DISABLED); |
988 } | 1001 } |
989 | 1002 |
990 } // namespace chromeos | 1003 } // namespace chromeos |
OLD | NEW |