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 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 notification_registrar_.Add(this, | 317 notification_registrar_.Add(this, |
318 chrome::NOTIFICATION_SESSION_STARTED, | 318 chrome::NOTIFICATION_SESSION_STARTED, |
319 content::NotificationService::AllSources()); | 319 content::NotificationService::AllSources()); |
320 notification_registrar_.Add(this, | 320 notification_registrar_.Add(this, |
321 chrome::NOTIFICATION_PROFILE_DESTROYED, | 321 chrome::NOTIFICATION_PROFILE_DESTROYED, |
322 content::NotificationService::AllSources()); | 322 content::NotificationService::AllSources()); |
323 notification_registrar_.Add(this, | 323 notification_registrar_.Add(this, |
324 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, | 324 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, |
325 content::NotificationService::AllSources()); | 325 content::NotificationService::AllSources()); |
326 | 326 |
| 327 input_method::InputMethodManager::Get()->AddObserver(this); |
| 328 |
327 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 329 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
328 media::SoundsManager* manager = media::SoundsManager::Get(); | 330 media::SoundsManager* manager = media::SoundsManager::Get(); |
329 manager->Initialize(SOUND_SHUTDOWN, | 331 manager->Initialize(SOUND_SHUTDOWN, |
330 bundle.GetRawDataResource(IDR_SOUND_SHUTDOWN_WAV)); | 332 bundle.GetRawDataResource(IDR_SOUND_SHUTDOWN_WAV)); |
331 manager->Initialize( | 333 manager->Initialize( |
332 SOUND_SPOKEN_FEEDBACK_ENABLED, | 334 SOUND_SPOKEN_FEEDBACK_ENABLED, |
333 bundle.GetRawDataResource(IDR_SOUND_SPOKEN_FEEDBACK_ENABLED_WAV)); | 335 bundle.GetRawDataResource(IDR_SOUND_SPOKEN_FEEDBACK_ENABLED_WAV)); |
334 manager->Initialize( | 336 manager->Initialize( |
335 SOUND_SPOKEN_FEEDBACK_DISABLED, | 337 SOUND_SPOKEN_FEEDBACK_DISABLED, |
336 bundle.GetRawDataResource(IDR_SOUND_SPOKEN_FEEDBACK_DISABLED_WAV)); | 338 bundle.GetRawDataResource(IDR_SOUND_SPOKEN_FEEDBACK_DISABLED_WAV)); |
337 } | 339 } |
338 | 340 |
339 AccessibilityManager::~AccessibilityManager() { | 341 AccessibilityManager::~AccessibilityManager() { |
340 CHECK(this == g_accessibility_manager); | 342 CHECK(this == g_accessibility_manager); |
341 AccessibilityStatusEventDetails details( | 343 AccessibilityStatusEventDetails details( |
342 ACCESSIBILITY_MANAGER_SHUTDOWN, | 344 ACCESSIBILITY_MANAGER_SHUTDOWN, |
343 false, | 345 false, |
344 ash::A11Y_NOTIFICATION_NONE); | 346 ash::A11Y_NOTIFICATION_NONE); |
345 NotifyAccessibilityStatusChanged(details); | 347 NotifyAccessibilityStatusChanged(details); |
| 348 input_method::InputMethodManager::Get()->RemoveObserver(this); |
346 } | 349 } |
347 | 350 |
348 bool AccessibilityManager::ShouldShowAccessibilityMenu() { | 351 bool AccessibilityManager::ShouldShowAccessibilityMenu() { |
349 // If any of the loaded profiles has an accessibility feature turned on - or | 352 // 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. | 353 // enforced to always show the menu - we return true to show the menu. |
351 std::vector<Profile*> profiles = | 354 std::vector<Profile*> profiles = |
352 g_browser_process->profile_manager()->GetLoadedProfiles(); | 355 g_browser_process->profile_manager()->GetLoadedProfiles(); |
353 for (std::vector<Profile*>::iterator it = profiles.begin(); | 356 for (std::vector<Profile*>::iterator it = profiles.begin(); |
354 it != profiles.end(); | 357 it != profiles.end(); |
355 ++it) { | 358 ++it) { |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
754 base::Unretained(braille_controller)), | 757 base::Unretained(braille_controller)), |
755 base::Bind(&AccessibilityManager::ReceiveBrailleDisplayState, | 758 base::Bind(&AccessibilityManager::ReceiveBrailleDisplayState, |
756 weak_ptr_factory_.GetWeakPtr())); | 759 weak_ptr_factory_.GetWeakPtr())); |
757 } | 760 } |
758 | 761 |
759 void AccessibilityManager::ReceiveBrailleDisplayState( | 762 void AccessibilityManager::ReceiveBrailleDisplayState( |
760 scoped_ptr<extensions::api::braille_display_private::DisplayState> state) { | 763 scoped_ptr<extensions::api::braille_display_private::DisplayState> state) { |
761 OnDisplayStateChanged(*state); | 764 OnDisplayStateChanged(*state); |
762 } | 765 } |
763 | 766 |
| 767 // Overridden from InputMethodManager::Observer. |
| 768 void AccessibilityManager::InputMethodChanged( |
| 769 input_method::InputMethodManager* manager, |
| 770 bool show_message) { |
| 771 #if defined(USE_ASH) |
| 772 // Sticky keys is implemented only in ash. |
| 773 ash::Shell::GetInstance()->sticky_keys_controller()->SetModifiersEnabled( |
| 774 manager->IsISOLevel5ShiftUsedByCurrentInputMethod(), |
| 775 manager->IsAltGrUsedByCurrentInputMethod()); |
| 776 #endif |
| 777 } |
764 | 778 |
765 void AccessibilityManager::SetProfile(Profile* profile) { | 779 void AccessibilityManager::SetProfile(Profile* profile) { |
766 pref_change_registrar_.reset(); | 780 pref_change_registrar_.reset(); |
767 local_state_pref_change_registrar_.reset(); | 781 local_state_pref_change_registrar_.reset(); |
768 | 782 |
769 if (profile) { | 783 if (profile) { |
770 // TODO(yoshiki): Move following code to PrefHandler. | 784 // TODO(yoshiki): Move following code to PrefHandler. |
771 pref_change_registrar_.reset(new PrefChangeRegistrar); | 785 pref_change_registrar_.reset(new PrefChangeRegistrar); |
772 pref_change_registrar_->Init(profile->GetPrefs()); | 786 pref_change_registrar_->Init(profile->GetPrefs()); |
773 pref_change_registrar_->Add( | 787 pref_change_registrar_->Add( |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
998 chrome_vox_loaded_on_lock_screen_; | 1012 chrome_vox_loaded_on_lock_screen_; |
999 } | 1013 } |
1000 | 1014 |
1001 void AccessibilityManager::PostUnloadChromeVox(Profile* profile) { | 1015 void AccessibilityManager::PostUnloadChromeVox(Profile* profile) { |
1002 // Do any teardown work needed immediately after ChromeVox actually unloads. | 1016 // Do any teardown work needed immediately after ChromeVox actually unloads. |
1003 if (system_sounds_enabled_) | 1017 if (system_sounds_enabled_) |
1004 ash::PlaySystemSoundAlways(SOUND_SPOKEN_FEEDBACK_DISABLED); | 1018 ash::PlaySystemSoundAlways(SOUND_SPOKEN_FEEDBACK_DISABLED); |
1005 } | 1019 } |
1006 | 1020 |
1007 } // namespace chromeos | 1021 } // namespace chromeos |
OLD | NEW |