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 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
755 base::Unretained(GetBrailleController())), | 757 base::Unretained(GetBrailleController())), |
756 base::Bind(&AccessibilityManager::ReceiveBrailleDisplayState, | 758 base::Bind(&AccessibilityManager::ReceiveBrailleDisplayState, |
757 weak_ptr_factory_.GetWeakPtr())); | 759 weak_ptr_factory_.GetWeakPtr())); |
758 } | 760 } |
759 | 761 |
760 void AccessibilityManager::ReceiveBrailleDisplayState( | 762 void AccessibilityManager::ReceiveBrailleDisplayState( |
761 scoped_ptr<extensions::api::braille_display_private::DisplayState> state) { | 763 scoped_ptr<extensions::api::braille_display_private::DisplayState> state) { |
762 OnDisplayStateChanged(*state); | 764 OnDisplayStateChanged(*state); |
763 } | 765 } |
764 | 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->IsMod3UsedByCurrentInputMethod(), |
| 775 manager->IsAltGrUsedByCurrentInputMethod()); |
| 776 #endif |
| 777 } |
765 | 778 |
766 void AccessibilityManager::SetProfile(Profile* profile) { | 779 void AccessibilityManager::SetProfile(Profile* profile) { |
767 pref_change_registrar_.reset(); | 780 pref_change_registrar_.reset(); |
768 local_state_pref_change_registrar_.reset(); | 781 local_state_pref_change_registrar_.reset(); |
769 | 782 |
770 if (profile) { | 783 if (profile) { |
771 // TODO(yoshiki): Move following code to PrefHandler. | 784 // TODO(yoshiki): Move following code to PrefHandler. |
772 pref_change_registrar_.reset(new PrefChangeRegistrar); | 785 pref_change_registrar_.reset(new PrefChangeRegistrar); |
773 pref_change_registrar_->Init(profile->GetPrefs()); | 786 pref_change_registrar_->Init(profile->GetPrefs()); |
774 pref_change_registrar_->Add( | 787 pref_change_registrar_->Add( |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
990 chrome_vox_loaded_on_lock_screen_; | 1003 chrome_vox_loaded_on_lock_screen_; |
991 } | 1004 } |
992 | 1005 |
993 void AccessibilityManager::PostUnloadChromeVox(Profile* profile) { | 1006 void AccessibilityManager::PostUnloadChromeVox(Profile* profile) { |
994 // Do any teardown work needed immediately after ChromeVox actually unloads. | 1007 // Do any teardown work needed immediately after ChromeVox actually unloads. |
995 if (system_sounds_enabled_) | 1008 if (system_sounds_enabled_) |
996 ash::PlaySystemSoundAlways(SOUND_SPOKEN_FEEDBACK_DISABLED); | 1009 ash::PlaySystemSoundAlways(SOUND_SPOKEN_FEEDBACK_DISABLED); |
997 } | 1010 } |
998 | 1011 |
999 } // namespace chromeos | 1012 } // namespace chromeos |
OLD | NEW |