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 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 return; | 447 return; |
448 | 448 |
449 large_cursor_enabled_ = enabled; | 449 large_cursor_enabled_ = enabled; |
450 | 450 |
451 AccessibilityStatusEventDetails details( | 451 AccessibilityStatusEventDetails details( |
452 ACCESSIBILITY_TOGGLE_LARGE_CURSOR, | 452 ACCESSIBILITY_TOGGLE_LARGE_CURSOR, |
453 enabled, | 453 enabled, |
454 ash::A11Y_NOTIFICATION_NONE); | 454 ash::A11Y_NOTIFICATION_NONE); |
455 | 455 |
456 NotifyAccessibilityStatusChanged(details); | 456 NotifyAccessibilityStatusChanged(details); |
| 457 #if !defined(USE_ATHENA) |
| 458 // crbug.com/408733 (and for all USE_ATHENA in this file) |
457 | 459 |
458 #if defined(USE_ASH) | 460 #if defined(USE_ASH) |
459 // Large cursor is implemented only in ash. | 461 // Large cursor is implemented only in ash. |
460 ash::Shell::GetInstance()->cursor_manager()->SetCursorSet( | 462 ash::Shell::GetInstance()->cursor_manager()->SetCursorSet( |
461 enabled ? ui::CURSOR_SET_LARGE : ui::CURSOR_SET_NORMAL); | 463 enabled ? ui::CURSOR_SET_LARGE : ui::CURSOR_SET_NORMAL); |
462 #endif | 464 #endif |
463 | 465 |
464 #if defined(OS_CHROMEOS) | 466 #if defined(OS_CHROMEOS) |
465 ash::Shell::GetInstance()->SetCursorCompositingEnabled( | 467 ash::Shell::GetInstance()->SetCursorCompositingEnabled( |
466 ShouldEnableCursorCompositing()); | 468 ShouldEnableCursorCompositing()); |
467 #endif | 469 #endif |
| 470 |
| 471 #endif // !USE_ATHENA |
468 } | 472 } |
469 | 473 |
470 bool AccessibilityManager::IsIncognitoAllowed() { | 474 bool AccessibilityManager::IsIncognitoAllowed() { |
471 // Supervised users can't create incognito-mode windows. | 475 // Supervised users can't create incognito-mode windows. |
472 return !(user_manager::UserManager::Get()->IsLoggedInAsSupervisedUser()); | 476 return !(user_manager::UserManager::Get()->IsLoggedInAsSupervisedUser()); |
473 } | 477 } |
474 | 478 |
475 bool AccessibilityManager::IsLargeCursorEnabled() { | 479 bool AccessibilityManager::IsLargeCursorEnabled() { |
476 return large_cursor_enabled_; | 480 return large_cursor_enabled_; |
477 } | 481 } |
(...skipping 14 matching lines...) Expand all Loading... |
492 if (!profile_) | 496 if (!profile_) |
493 return; | 497 return; |
494 | 498 |
495 const bool enabled = | 499 const bool enabled = |
496 profile_->GetPrefs()->GetBoolean(prefs::kAccessibilityStickyKeysEnabled); | 500 profile_->GetPrefs()->GetBoolean(prefs::kAccessibilityStickyKeysEnabled); |
497 | 501 |
498 if (sticky_keys_enabled_ == enabled) | 502 if (sticky_keys_enabled_ == enabled) |
499 return; | 503 return; |
500 | 504 |
501 sticky_keys_enabled_ = enabled; | 505 sticky_keys_enabled_ = enabled; |
502 #if defined(USE_ASH) | 506 #if defined(USE_ASH) && !defined(USE_ATHENA) |
503 // Sticky keys is implemented only in ash. | |
504 ash::Shell::GetInstance()->sticky_keys_controller()->Enable(enabled); | 507 ash::Shell::GetInstance()->sticky_keys_controller()->Enable(enabled); |
505 #endif | 508 #endif |
506 } | 509 } |
507 | 510 |
508 void AccessibilityManager::EnableSpokenFeedback( | 511 void AccessibilityManager::EnableSpokenFeedback( |
509 bool enabled, | 512 bool enabled, |
510 ash::AccessibilityNotificationVisibility notify) { | 513 ash::AccessibilityNotificationVisibility notify) { |
511 if (!profile_) | 514 if (!profile_) |
512 return; | 515 return; |
513 | 516 #if !defined(USE_ATHENA) |
514 ash::Shell::GetInstance()->metrics()->RecordUserMetricsAction( | 517 ash::Shell::GetInstance()->metrics()->RecordUserMetricsAction( |
515 enabled ? ash::UMA_STATUS_AREA_ENABLE_SPOKEN_FEEDBACK | 518 enabled ? ash::UMA_STATUS_AREA_ENABLE_SPOKEN_FEEDBACK |
516 : ash::UMA_STATUS_AREA_DISABLE_SPOKEN_FEEDBACK); | 519 : ash::UMA_STATUS_AREA_DISABLE_SPOKEN_FEEDBACK); |
| 520 #endif |
517 | 521 |
518 spoken_feedback_notification_ = notify; | 522 spoken_feedback_notification_ = notify; |
519 | 523 |
520 PrefService* pref_service = profile_->GetPrefs(); | 524 PrefService* pref_service = profile_->GetPrefs(); |
521 pref_service->SetBoolean(prefs::kAccessibilitySpokenFeedbackEnabled, enabled); | 525 pref_service->SetBoolean(prefs::kAccessibilitySpokenFeedbackEnabled, enabled); |
522 pref_service->CommitPendingWrite(); | 526 pref_service->CommitPendingWrite(); |
523 | 527 |
524 spoken_feedback_notification_ = ash::A11Y_NOTIFICATION_NONE; | 528 spoken_feedback_notification_ = ash::A11Y_NOTIFICATION_NONE; |
525 } | 529 } |
526 | 530 |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 | 670 |
667 high_contrast_enabled_ = enabled; | 671 high_contrast_enabled_ = enabled; |
668 | 672 |
669 AccessibilityStatusEventDetails details( | 673 AccessibilityStatusEventDetails details( |
670 ACCESSIBILITY_TOGGLE_HIGH_CONTRAST_MODE, | 674 ACCESSIBILITY_TOGGLE_HIGH_CONTRAST_MODE, |
671 enabled, | 675 enabled, |
672 ash::A11Y_NOTIFICATION_NONE); | 676 ash::A11Y_NOTIFICATION_NONE); |
673 | 677 |
674 NotifyAccessibilityStatusChanged(details); | 678 NotifyAccessibilityStatusChanged(details); |
675 | 679 |
| 680 #if !defined(USE_ATHENA) |
| 681 |
676 #if defined(USE_ASH) | 682 #if defined(USE_ASH) |
677 ash::Shell::GetInstance()->high_contrast_controller()->SetEnabled(enabled); | 683 ash::Shell::GetInstance()->high_contrast_controller()->SetEnabled(enabled); |
678 #endif | 684 #endif |
679 | 685 |
680 #if defined(OS_CHROMEOS) | 686 #if defined(OS_CHROMEOS) |
681 ash::Shell::GetInstance()->SetCursorCompositingEnabled( | 687 ash::Shell::GetInstance()->SetCursorCompositingEnabled( |
682 ShouldEnableCursorCompositing()); | 688 ShouldEnableCursorCompositing()); |
683 #endif | 689 #endif |
| 690 |
| 691 #endif |
684 } | 692 } |
685 | 693 |
686 void AccessibilityManager::OnLocaleChanged() { | 694 void AccessibilityManager::OnLocaleChanged() { |
687 if (!profile_) | 695 if (!profile_) |
688 return; | 696 return; |
689 | 697 |
690 if (!IsSpokenFeedbackEnabled()) | 698 if (!IsSpokenFeedbackEnabled()) |
691 return; | 699 return; |
692 | 700 |
693 // If the system locale changes and spoken feedback is enabled, | 701 // If the system locale changes and spoken feedback is enabled, |
(...skipping 26 matching lines...) Expand all Loading... |
720 } | 728 } |
721 | 729 |
722 void AccessibilityManager::UpdateAutoclickFromPref() { | 730 void AccessibilityManager::UpdateAutoclickFromPref() { |
723 bool enabled = | 731 bool enabled = |
724 profile_->GetPrefs()->GetBoolean(prefs::kAccessibilityAutoclickEnabled); | 732 profile_->GetPrefs()->GetBoolean(prefs::kAccessibilityAutoclickEnabled); |
725 | 733 |
726 if (autoclick_enabled_ == enabled) | 734 if (autoclick_enabled_ == enabled) |
727 return; | 735 return; |
728 autoclick_enabled_ = enabled; | 736 autoclick_enabled_ = enabled; |
729 | 737 |
730 #if defined(USE_ASH) | 738 #if defined(USE_ASH) && !defined(USE_ATHENA) |
731 ash::Shell::GetInstance()->autoclick_controller()->SetEnabled(enabled); | 739 ash::Shell::GetInstance()->autoclick_controller()->SetEnabled(enabled); |
732 #endif | 740 #endif |
733 } | 741 } |
734 | 742 |
735 void AccessibilityManager::SetAutoclickDelay(int delay_ms) { | 743 void AccessibilityManager::SetAutoclickDelay(int delay_ms) { |
736 if (!profile_) | 744 if (!profile_) |
737 return; | 745 return; |
738 | 746 |
739 PrefService* pref_service = profile_->GetPrefs(); | 747 PrefService* pref_service = profile_->GetPrefs(); |
740 pref_service->SetInteger(prefs::kAccessibilityAutoclickDelayMs, delay_ms); | 748 pref_service->SetInteger(prefs::kAccessibilityAutoclickDelayMs, delay_ms); |
741 pref_service->CommitPendingWrite(); | 749 pref_service->CommitPendingWrite(); |
742 } | 750 } |
743 | 751 |
744 int AccessibilityManager::GetAutoclickDelay() const { | 752 int AccessibilityManager::GetAutoclickDelay() const { |
745 return autoclick_delay_ms_; | 753 return autoclick_delay_ms_; |
746 } | 754 } |
747 | 755 |
748 void AccessibilityManager::UpdateAutoclickDelayFromPref() { | 756 void AccessibilityManager::UpdateAutoclickDelayFromPref() { |
749 int autoclick_delay_ms = | 757 int autoclick_delay_ms = |
750 profile_->GetPrefs()->GetInteger(prefs::kAccessibilityAutoclickDelayMs); | 758 profile_->GetPrefs()->GetInteger(prefs::kAccessibilityAutoclickDelayMs); |
751 | 759 |
752 if (autoclick_delay_ms == autoclick_delay_ms_) | 760 if (autoclick_delay_ms == autoclick_delay_ms_) |
753 return; | 761 return; |
754 autoclick_delay_ms_ = autoclick_delay_ms; | 762 autoclick_delay_ms_ = autoclick_delay_ms; |
755 | 763 |
756 #if defined(USE_ASH) | 764 #if defined(USE_ASH) && !defined(USE_ATHENA) |
757 ash::Shell::GetInstance()->autoclick_controller()->SetAutoclickDelay( | 765 ash::Shell::GetInstance()->autoclick_controller()->SetAutoclickDelay( |
758 autoclick_delay_ms_); | 766 autoclick_delay_ms_); |
759 #endif | 767 #endif |
760 } | 768 } |
761 | 769 |
762 void AccessibilityManager::EnableVirtualKeyboard(bool enabled) { | 770 void AccessibilityManager::EnableVirtualKeyboard(bool enabled) { |
763 if (!profile_) | 771 if (!profile_) |
764 return; | 772 return; |
765 | 773 |
766 PrefService* pref_service = profile_->GetPrefs(); | 774 PrefService* pref_service = profile_->GetPrefs(); |
(...skipping 17 matching lines...) Expand all Loading... |
784 return; | 792 return; |
785 virtual_keyboard_enabled_ = enabled; | 793 virtual_keyboard_enabled_ = enabled; |
786 | 794 |
787 AccessibilityStatusEventDetails details( | 795 AccessibilityStatusEventDetails details( |
788 ACCESSIBILITY_TOGGLE_VIRTUAL_KEYBOARD, | 796 ACCESSIBILITY_TOGGLE_VIRTUAL_KEYBOARD, |
789 enabled, | 797 enabled, |
790 ash::A11Y_NOTIFICATION_NONE); | 798 ash::A11Y_NOTIFICATION_NONE); |
791 | 799 |
792 NotifyAccessibilityStatusChanged(details); | 800 NotifyAccessibilityStatusChanged(details); |
793 | 801 |
794 #if defined(USE_ASH) | 802 #if defined(USE_ASH) && !defined(USE_ATHENA) |
795 keyboard::SetAccessibilityKeyboardEnabled(enabled); | 803 keyboard::SetAccessibilityKeyboardEnabled(enabled); |
796 // Note that there are two versions of the on-screen keyboard. A full layout | 804 // Note that there are two versions of the on-screen keyboard. A full layout |
797 // is provided for accessibility, which includes sticky modifier keys to | 805 // is provided for accessibility, which includes sticky modifier keys to |
798 // enable typing of hotkeys. A compact version is used in touchview mode | 806 // enable typing of hotkeys. A compact version is used in touchview mode |
799 // to provide a layout with larger keys to facilitate touch typing. In the | 807 // to provide a layout with larger keys to facilitate touch typing. In the |
800 // event that the a11y keyboard is being disabled, an on-screen keyboard might | 808 // event that the a11y keyboard is being disabled, an on-screen keyboard might |
801 // still be enabled and a forced reset is required to pick up the layout | 809 // still be enabled and a forced reset is required to pick up the layout |
802 // change. | 810 // change. |
803 if (keyboard::IsKeyboardEnabled()) | 811 if (keyboard::IsKeyboardEnabled()) |
804 ash::Shell::GetInstance()->CreateKeyboard(); | 812 ash::Shell::GetInstance()->CreateKeyboard(); |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
959 } | 967 } |
960 | 968 |
961 void AccessibilityManager::EnableSystemSounds(bool system_sounds_enabled) { | 969 void AccessibilityManager::EnableSystemSounds(bool system_sounds_enabled) { |
962 system_sounds_enabled_ = system_sounds_enabled; | 970 system_sounds_enabled_ = system_sounds_enabled; |
963 } | 971 } |
964 | 972 |
965 base::TimeDelta AccessibilityManager::PlayShutdownSound() { | 973 base::TimeDelta AccessibilityManager::PlayShutdownSound() { |
966 if (!system_sounds_enabled_) | 974 if (!system_sounds_enabled_) |
967 return base::TimeDelta(); | 975 return base::TimeDelta(); |
968 system_sounds_enabled_ = false; | 976 system_sounds_enabled_ = false; |
| 977 #if !defined(USE_ATHENA) |
969 if (!ash::PlaySystemSoundIfSpokenFeedback(SOUND_SHUTDOWN)) | 978 if (!ash::PlaySystemSoundIfSpokenFeedback(SOUND_SHUTDOWN)) |
970 return base::TimeDelta(); | 979 return base::TimeDelta(); |
| 980 #endif |
971 return media::SoundsManager::Get()->GetDuration(SOUND_SHUTDOWN); | 981 return media::SoundsManager::Get()->GetDuration(SOUND_SHUTDOWN); |
972 } | 982 } |
973 | 983 |
974 void AccessibilityManager::InjectChromeVox(RenderViewHost* render_view_host) { | 984 void AccessibilityManager::InjectChromeVox(RenderViewHost* render_view_host) { |
975 LoadChromeVoxExtension(profile_, render_view_host, base::Closure()); | 985 LoadChromeVoxExtension(profile_, render_view_host, base::Closure()); |
976 } | 986 } |
977 | 987 |
978 scoped_ptr<AccessibilityStatusSubscription> | 988 scoped_ptr<AccessibilityStatusSubscription> |
979 AccessibilityManager::RegisterCallback( | 989 AccessibilityManager::RegisterCallback( |
980 const AccessibilityStatusCallback& cb) { | 990 const AccessibilityStatusCallback& cb) { |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1117 chrome_vox_loaded_on_lock_screen_; | 1127 chrome_vox_loaded_on_lock_screen_; |
1118 } | 1128 } |
1119 | 1129 |
1120 void AccessibilityManager::PostUnloadChromeVox(Profile* profile) { | 1130 void AccessibilityManager::PostUnloadChromeVox(Profile* profile) { |
1121 // Do any teardown work needed immediately after ChromeVox actually unloads. | 1131 // Do any teardown work needed immediately after ChromeVox actually unloads. |
1122 if (system_sounds_enabled_) | 1132 if (system_sounds_enabled_) |
1123 ash::PlaySystemSoundAlways(SOUND_SPOKEN_FEEDBACK_DISABLED); | 1133 ash::PlaySystemSoundAlways(SOUND_SPOKEN_FEEDBACK_DISABLED); |
1124 } | 1134 } |
1125 | 1135 |
1126 } // namespace chromeos | 1136 } // namespace chromeos |
OLD | NEW |