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" |
| 8 #include "ash/autoclick/autoclick_controller.h" |
| 9 #include "ash/high_contrast/high_contrast_controller.h" |
| 10 #include "ash/metrics/user_metrics_recorder.h" |
| 11 #include "ash/session/session_state_delegate.h" |
| 12 #include "ash/shell.h" |
| 13 #include "ash/sticky_keys/sticky_keys_controller.h" |
| 14 #include "ash/system/tray/system_tray_notifier.h" |
7 #include "base/callback.h" | 15 #include "base/callback.h" |
8 #include "base/callback_helpers.h" | 16 #include "base/callback_helpers.h" |
9 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
10 #include "base/memory/singleton.h" | 18 #include "base/memory/singleton.h" |
11 #include "base/metrics/histogram.h" | 19 #include "base/metrics/histogram.h" |
12 #include "base/path_service.h" | 20 #include "base/path_service.h" |
13 #include "base/prefs/pref_member.h" | 21 #include "base/prefs/pref_member.h" |
14 #include "base/prefs/pref_service.h" | 22 #include "base/prefs/pref_service.h" |
15 #include "base/strings/string_split.h" | 23 #include "base/strings/string_split.h" |
16 #include "base/strings/string_util.h" | 24 #include "base/strings/string_util.h" |
17 #include "base/time/time.h" | 25 #include "base/time/time.h" |
18 #include "base/values.h" | 26 #include "base/values.h" |
19 #include "chrome/browser/accessibility/accessibility_extension_api.h" | 27 #include "chrome/browser/accessibility/accessibility_extension_api.h" |
20 #include "chrome/browser/browser_process.h" | 28 #include "chrome/browser/browser_process.h" |
21 #include "chrome/browser/chrome_notification_types.h" | 29 #include "chrome/browser/chrome_notification_types.h" |
| 30 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" |
22 #include "chrome/browser/chromeos/login/lock/screen_locker.h" | 31 #include "chrome/browser/chromeos/login/lock/screen_locker.h" |
23 #include "chrome/browser/chromeos/login/ui/login_display_host.h" | 32 #include "chrome/browser/chromeos/login/ui/login_display_host.h" |
24 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" | 33 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" |
25 #include "chrome/browser/chromeos/login/ui/webui_login_view.h" | 34 #include "chrome/browser/chromeos/login/ui/webui_login_view.h" |
26 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 35 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
27 #include "chrome/browser/chromeos/ui/accessibility_focus_ring_controller.h" | 36 #include "chrome/browser/chromeos/ui/accessibility_focus_ring_controller.h" |
28 #include "chrome/browser/extensions/component_loader.h" | 37 #include "chrome/browser/extensions/component_loader.h" |
29 #include "chrome/browser/extensions/extension_service.h" | 38 #include "chrome/browser/extensions/extension_service.h" |
30 #include "chrome/browser/profiles/profile.h" | 39 #include "chrome/browser/profiles/profile.h" |
31 #include "chrome/browser/profiles/profile_manager.h" | 40 #include "chrome/browser/profiles/profile_manager.h" |
(...skipping 20 matching lines...) Expand all Loading... |
52 #include "extensions/browser/file_reader.h" | 61 #include "extensions/browser/file_reader.h" |
53 #include "extensions/common/extension.h" | 62 #include "extensions/common/extension.h" |
54 #include "extensions/common/extension_messages.h" | 63 #include "extensions/common/extension_messages.h" |
55 #include "extensions/common/extension_resource.h" | 64 #include "extensions/common/extension_resource.h" |
56 #include "media/audio/sounds/sounds_manager.h" | 65 #include "media/audio/sounds/sounds_manager.h" |
57 #include "ui/base/ime/chromeos/input_method_manager.h" | 66 #include "ui/base/ime/chromeos/input_method_manager.h" |
58 #include "ui/base/resource/resource_bundle.h" | 67 #include "ui/base/resource/resource_bundle.h" |
59 #include "ui/keyboard/keyboard_controller.h" | 68 #include "ui/keyboard/keyboard_controller.h" |
60 #include "ui/keyboard/keyboard_util.h" | 69 #include "ui/keyboard/keyboard_util.h" |
61 | 70 |
62 #if !defined(USE_ATHENA) | |
63 #include "ash/audio/sounds.h" | |
64 #include "ash/autoclick/autoclick_controller.h" | |
65 #include "ash/high_contrast/high_contrast_controller.h" | |
66 #include "ash/metrics/user_metrics_recorder.h" | |
67 #include "ash/session/session_state_delegate.h" | |
68 #include "ash/shell.h" | |
69 #include "ash/sticky_keys/sticky_keys_controller.h" | |
70 #include "ash/system/tray/system_tray_notifier.h" | |
71 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" | |
72 #endif | |
73 | |
74 using content::BrowserThread; | 71 using content::BrowserThread; |
75 using content::RenderViewHost; | 72 using content::RenderViewHost; |
76 using extensions::api::braille_display_private::BrailleController; | 73 using extensions::api::braille_display_private::BrailleController; |
77 using extensions::api::braille_display_private::DisplayState; | 74 using extensions::api::braille_display_private::DisplayState; |
78 using extensions::api::braille_display_private::KeyEvent; | 75 using extensions::api::braille_display_private::KeyEvent; |
79 | 76 |
80 namespace chromeos { | 77 namespace chromeos { |
81 | 78 |
82 namespace { | 79 namespace { |
83 | 80 |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 high_contrast_pref_handler_(prefs::kAccessibilityHighContrastEnabled), | 334 high_contrast_pref_handler_(prefs::kAccessibilityHighContrastEnabled), |
338 autoclick_pref_handler_(prefs::kAccessibilityAutoclickEnabled), | 335 autoclick_pref_handler_(prefs::kAccessibilityAutoclickEnabled), |
339 autoclick_delay_pref_handler_(prefs::kAccessibilityAutoclickDelayMs), | 336 autoclick_delay_pref_handler_(prefs::kAccessibilityAutoclickDelayMs), |
340 virtual_keyboard_pref_handler_( | 337 virtual_keyboard_pref_handler_( |
341 prefs::kAccessibilityVirtualKeyboardEnabled), | 338 prefs::kAccessibilityVirtualKeyboardEnabled), |
342 large_cursor_enabled_(false), | 339 large_cursor_enabled_(false), |
343 sticky_keys_enabled_(false), | 340 sticky_keys_enabled_(false), |
344 spoken_feedback_enabled_(false), | 341 spoken_feedback_enabled_(false), |
345 high_contrast_enabled_(false), | 342 high_contrast_enabled_(false), |
346 autoclick_enabled_(false), | 343 autoclick_enabled_(false), |
347 #if defined(USE_ATHENA) | |
348 autoclick_delay_ms_(400), | |
349 #else | |
350 autoclick_delay_ms_(ash::AutoclickController::kDefaultAutoclickDelayMs), | 344 autoclick_delay_ms_(ash::AutoclickController::kDefaultAutoclickDelayMs), |
351 #endif | |
352 virtual_keyboard_enabled_(false), | 345 virtual_keyboard_enabled_(false), |
353 spoken_feedback_notification_(ui::A11Y_NOTIFICATION_NONE), | 346 spoken_feedback_notification_(ui::A11Y_NOTIFICATION_NONE), |
354 should_speak_chrome_vox_announcements_on_user_screen_(true), | 347 should_speak_chrome_vox_announcements_on_user_screen_(true), |
355 system_sounds_enabled_(false), | 348 system_sounds_enabled_(false), |
356 braille_display_connected_(false), | 349 braille_display_connected_(false), |
357 scoped_braille_observer_(this), | 350 scoped_braille_observer_(this), |
358 braille_ime_current_(false), | 351 braille_ime_current_(false), |
359 weak_ptr_factory_(this) { | 352 weak_ptr_factory_(this) { |
360 notification_registrar_.Add(this, | 353 notification_registrar_.Add(this, |
361 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, | 354 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 pref_service->GetBoolean(prefs::kAccessibilityAutoclickEnabled) || | 409 pref_service->GetBoolean(prefs::kAccessibilityAutoclickEnabled) || |
417 pref_service->GetBoolean(prefs::kShouldAlwaysShowAccessibilityMenu) || | 410 pref_service->GetBoolean(prefs::kShouldAlwaysShowAccessibilityMenu) || |
418 pref_service->GetBoolean(prefs::kAccessibilityScreenMagnifierEnabled) || | 411 pref_service->GetBoolean(prefs::kAccessibilityScreenMagnifierEnabled) || |
419 pref_service->GetBoolean(prefs::kAccessibilityVirtualKeyboardEnabled)) | 412 pref_service->GetBoolean(prefs::kAccessibilityVirtualKeyboardEnabled)) |
420 return true; | 413 return true; |
421 } | 414 } |
422 return false; | 415 return false; |
423 } | 416 } |
424 | 417 |
425 bool AccessibilityManager::ShouldEnableCursorCompositing() { | 418 bool AccessibilityManager::ShouldEnableCursorCompositing() { |
426 #if defined(OS_CHROMEOS) | |
427 if (!profile_) | 419 if (!profile_) |
428 return false; | 420 return false; |
429 PrefService* pref_service = profile_->GetPrefs(); | 421 PrefService* pref_service = profile_->GetPrefs(); |
430 // Enable cursor compositing when one or more of the listed accessibility | 422 // Enable cursor compositing when one or more of the listed accessibility |
431 // features are turned on. | 423 // features are turned on. |
432 if (pref_service->GetBoolean(prefs::kAccessibilityLargeCursorEnabled) || | 424 if (pref_service->GetBoolean(prefs::kAccessibilityLargeCursorEnabled) || |
433 pref_service->GetBoolean(prefs::kAccessibilityHighContrastEnabled) || | 425 pref_service->GetBoolean(prefs::kAccessibilityHighContrastEnabled) || |
434 pref_service->GetBoolean(prefs::kAccessibilityScreenMagnifierEnabled)) | 426 pref_service->GetBoolean(prefs::kAccessibilityScreenMagnifierEnabled)) |
435 return true; | 427 return true; |
436 #endif | |
437 return false; | 428 return false; |
438 } | 429 } |
439 | 430 |
440 void AccessibilityManager::EnableLargeCursor(bool enabled) { | 431 void AccessibilityManager::EnableLargeCursor(bool enabled) { |
441 if (!profile_) | 432 if (!profile_) |
442 return; | 433 return; |
443 | 434 |
444 PrefService* pref_service = profile_->GetPrefs(); | 435 PrefService* pref_service = profile_->GetPrefs(); |
445 pref_service->SetBoolean(prefs::kAccessibilityLargeCursorEnabled, enabled); | 436 pref_service->SetBoolean(prefs::kAccessibilityLargeCursorEnabled, enabled); |
446 pref_service->CommitPendingWrite(); | 437 pref_service->CommitPendingWrite(); |
(...skipping 10 matching lines...) Expand all Loading... |
457 return; | 448 return; |
458 | 449 |
459 large_cursor_enabled_ = enabled; | 450 large_cursor_enabled_ = enabled; |
460 | 451 |
461 AccessibilityStatusEventDetails details( | 452 AccessibilityStatusEventDetails details( |
462 ACCESSIBILITY_TOGGLE_LARGE_CURSOR, | 453 ACCESSIBILITY_TOGGLE_LARGE_CURSOR, |
463 enabled, | 454 enabled, |
464 ui::A11Y_NOTIFICATION_NONE); | 455 ui::A11Y_NOTIFICATION_NONE); |
465 | 456 |
466 NotifyAccessibilityStatusChanged(details); | 457 NotifyAccessibilityStatusChanged(details); |
467 #if !defined(USE_ATHENA) | |
468 // crbug.com/408733 (and for all USE_ATHENA in this file) | |
469 | 458 |
470 #if defined(USE_ASH) | |
471 // Large cursor is implemented only in ash. | |
472 ash::Shell::GetInstance()->cursor_manager()->SetCursorSet( | 459 ash::Shell::GetInstance()->cursor_manager()->SetCursorSet( |
473 enabled ? ui::CURSOR_SET_LARGE : ui::CURSOR_SET_NORMAL); | 460 enabled ? ui::CURSOR_SET_LARGE : ui::CURSOR_SET_NORMAL); |
474 #endif | |
475 | |
476 #if defined(OS_CHROMEOS) | |
477 ash::Shell::GetInstance()->SetCursorCompositingEnabled( | 461 ash::Shell::GetInstance()->SetCursorCompositingEnabled( |
478 ShouldEnableCursorCompositing()); | 462 ShouldEnableCursorCompositing()); |
479 #endif | |
480 | |
481 #endif // !USE_ATHENA | |
482 } | 463 } |
483 | 464 |
484 bool AccessibilityManager::IsIncognitoAllowed() { | 465 bool AccessibilityManager::IsIncognitoAllowed() { |
485 // Supervised users can't create incognito-mode windows. | 466 // Supervised users can't create incognito-mode windows. |
486 return !user_manager::UserManager::Get()->IsLoggedInAsSupervisedUser() && | 467 return !user_manager::UserManager::Get()->IsLoggedInAsSupervisedUser() && |
487 !user_manager::UserManager::Get()->IsLoggedInAsChildUser(); | 468 !user_manager::UserManager::Get()->IsLoggedInAsChildUser(); |
488 } | 469 } |
489 | 470 |
490 bool AccessibilityManager::IsLargeCursorEnabled() { | 471 bool AccessibilityManager::IsLargeCursorEnabled() { |
491 return large_cursor_enabled_; | 472 return large_cursor_enabled_; |
(...skipping 15 matching lines...) Expand all Loading... |
507 if (!profile_) | 488 if (!profile_) |
508 return; | 489 return; |
509 | 490 |
510 const bool enabled = | 491 const bool enabled = |
511 profile_->GetPrefs()->GetBoolean(prefs::kAccessibilityStickyKeysEnabled); | 492 profile_->GetPrefs()->GetBoolean(prefs::kAccessibilityStickyKeysEnabled); |
512 | 493 |
513 if (sticky_keys_enabled_ == enabled) | 494 if (sticky_keys_enabled_ == enabled) |
514 return; | 495 return; |
515 | 496 |
516 sticky_keys_enabled_ = enabled; | 497 sticky_keys_enabled_ = enabled; |
517 #if defined(USE_ASH) && !defined(USE_ATHENA) | |
518 ash::Shell::GetInstance()->sticky_keys_controller()->Enable(enabled); | 498 ash::Shell::GetInstance()->sticky_keys_controller()->Enable(enabled); |
519 #endif | |
520 } | 499 } |
521 | 500 |
522 void AccessibilityManager::EnableSpokenFeedback( | 501 void AccessibilityManager::EnableSpokenFeedback( |
523 bool enabled, | 502 bool enabled, |
524 ui::AccessibilityNotificationVisibility notify) { | 503 ui::AccessibilityNotificationVisibility notify) { |
525 if (!profile_) | 504 if (!profile_) |
526 return; | 505 return; |
527 #if !defined(USE_ATHENA) | |
528 ash::Shell::GetInstance()->metrics()->RecordUserMetricsAction( | 506 ash::Shell::GetInstance()->metrics()->RecordUserMetricsAction( |
529 enabled ? ash::UMA_STATUS_AREA_ENABLE_SPOKEN_FEEDBACK | 507 enabled ? ash::UMA_STATUS_AREA_ENABLE_SPOKEN_FEEDBACK |
530 : ash::UMA_STATUS_AREA_DISABLE_SPOKEN_FEEDBACK); | 508 : ash::UMA_STATUS_AREA_DISABLE_SPOKEN_FEEDBACK); |
531 #endif | |
532 | 509 |
533 spoken_feedback_notification_ = notify; | 510 spoken_feedback_notification_ = notify; |
534 | 511 |
535 PrefService* pref_service = profile_->GetPrefs(); | 512 PrefService* pref_service = profile_->GetPrefs(); |
536 pref_service->SetBoolean(prefs::kAccessibilitySpokenFeedbackEnabled, enabled); | 513 pref_service->SetBoolean(prefs::kAccessibilitySpokenFeedbackEnabled, enabled); |
537 pref_service->CommitPendingWrite(); | 514 pref_service->CommitPendingWrite(); |
538 | 515 |
539 spoken_feedback_notification_ = ui::A11Y_NOTIFICATION_NONE; | 516 spoken_feedback_notification_ = ui::A11Y_NOTIFICATION_NONE; |
540 } | 517 } |
541 | 518 |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 | 658 |
682 high_contrast_enabled_ = enabled; | 659 high_contrast_enabled_ = enabled; |
683 | 660 |
684 AccessibilityStatusEventDetails details( | 661 AccessibilityStatusEventDetails details( |
685 ACCESSIBILITY_TOGGLE_HIGH_CONTRAST_MODE, | 662 ACCESSIBILITY_TOGGLE_HIGH_CONTRAST_MODE, |
686 enabled, | 663 enabled, |
687 ui::A11Y_NOTIFICATION_NONE); | 664 ui::A11Y_NOTIFICATION_NONE); |
688 | 665 |
689 NotifyAccessibilityStatusChanged(details); | 666 NotifyAccessibilityStatusChanged(details); |
690 | 667 |
691 #if !defined(USE_ATHENA) | |
692 | |
693 #if defined(USE_ASH) | |
694 ash::Shell::GetInstance()->high_contrast_controller()->SetEnabled(enabled); | 668 ash::Shell::GetInstance()->high_contrast_controller()->SetEnabled(enabled); |
695 #endif | |
696 | |
697 #if defined(OS_CHROMEOS) | |
698 ash::Shell::GetInstance()->SetCursorCompositingEnabled( | 669 ash::Shell::GetInstance()->SetCursorCompositingEnabled( |
699 ShouldEnableCursorCompositing()); | 670 ShouldEnableCursorCompositing()); |
700 #endif | |
701 | |
702 #endif | |
703 } | 671 } |
704 | 672 |
705 void AccessibilityManager::OnLocaleChanged() { | 673 void AccessibilityManager::OnLocaleChanged() { |
706 if (!profile_) | 674 if (!profile_) |
707 return; | 675 return; |
708 | 676 |
709 if (!IsSpokenFeedbackEnabled()) | 677 if (!IsSpokenFeedbackEnabled()) |
710 return; | 678 return; |
711 | 679 |
712 // If the system locale changes and spoken feedback is enabled, | 680 // If the system locale changes and spoken feedback is enabled, |
713 // reload ChromeVox so that it switches its internal translations | 681 // reload ChromeVox so that it switches its internal translations |
714 // to the new language. | 682 // to the new language. |
715 EnableSpokenFeedback(false, ui::A11Y_NOTIFICATION_NONE); | 683 EnableSpokenFeedback(false, ui::A11Y_NOTIFICATION_NONE); |
716 EnableSpokenFeedback(true, ui::A11Y_NOTIFICATION_NONE); | 684 EnableSpokenFeedback(true, ui::A11Y_NOTIFICATION_NONE); |
717 } | 685 } |
718 | 686 |
719 void AccessibilityManager::PlayEarcon(int sound_key) { | 687 void AccessibilityManager::PlayEarcon(int sound_key) { |
720 #if !defined(USE_ATHENA) | |
721 DCHECK(sound_key < chromeos::SOUND_COUNT); | 688 DCHECK(sound_key < chromeos::SOUND_COUNT); |
722 ash::PlaySystemSoundIfSpokenFeedback(sound_key); | 689 ash::PlaySystemSoundIfSpokenFeedback(sound_key); |
723 #endif | |
724 } | 690 } |
725 | 691 |
726 bool AccessibilityManager::IsHighContrastEnabled() { | 692 bool AccessibilityManager::IsHighContrastEnabled() { |
727 return high_contrast_enabled_; | 693 return high_contrast_enabled_; |
728 } | 694 } |
729 | 695 |
730 void AccessibilityManager::EnableAutoclick(bool enabled) { | 696 void AccessibilityManager::EnableAutoclick(bool enabled) { |
731 if (!profile_) | 697 if (!profile_) |
732 return; | 698 return; |
733 | 699 |
(...skipping 10 matching lines...) Expand all Loading... |
744 if (!profile_) | 710 if (!profile_) |
745 return; | 711 return; |
746 | 712 |
747 bool enabled = | 713 bool enabled = |
748 profile_->GetPrefs()->GetBoolean(prefs::kAccessibilityAutoclickEnabled); | 714 profile_->GetPrefs()->GetBoolean(prefs::kAccessibilityAutoclickEnabled); |
749 | 715 |
750 if (autoclick_enabled_ == enabled) | 716 if (autoclick_enabled_ == enabled) |
751 return; | 717 return; |
752 autoclick_enabled_ = enabled; | 718 autoclick_enabled_ = enabled; |
753 | 719 |
754 #if defined(USE_ASH) && !defined(USE_ATHENA) | |
755 ash::Shell::GetInstance()->autoclick_controller()->SetEnabled(enabled); | 720 ash::Shell::GetInstance()->autoclick_controller()->SetEnabled(enabled); |
756 #endif | |
757 } | 721 } |
758 | 722 |
759 void AccessibilityManager::SetAutoclickDelay(int delay_ms) { | 723 void AccessibilityManager::SetAutoclickDelay(int delay_ms) { |
760 if (!profile_) | 724 if (!profile_) |
761 return; | 725 return; |
762 | 726 |
763 PrefService* pref_service = profile_->GetPrefs(); | 727 PrefService* pref_service = profile_->GetPrefs(); |
764 pref_service->SetInteger(prefs::kAccessibilityAutoclickDelayMs, delay_ms); | 728 pref_service->SetInteger(prefs::kAccessibilityAutoclickDelayMs, delay_ms); |
765 pref_service->CommitPendingWrite(); | 729 pref_service->CommitPendingWrite(); |
766 } | 730 } |
767 | 731 |
768 int AccessibilityManager::GetAutoclickDelay() const { | 732 int AccessibilityManager::GetAutoclickDelay() const { |
769 return autoclick_delay_ms_; | 733 return autoclick_delay_ms_; |
770 } | 734 } |
771 | 735 |
772 void AccessibilityManager::UpdateAutoclickDelayFromPref() { | 736 void AccessibilityManager::UpdateAutoclickDelayFromPref() { |
773 if (!profile_) | 737 if (!profile_) |
774 return; | 738 return; |
775 | 739 |
776 int autoclick_delay_ms = | 740 int autoclick_delay_ms = |
777 profile_->GetPrefs()->GetInteger(prefs::kAccessibilityAutoclickDelayMs); | 741 profile_->GetPrefs()->GetInteger(prefs::kAccessibilityAutoclickDelayMs); |
778 | 742 |
779 if (autoclick_delay_ms == autoclick_delay_ms_) | 743 if (autoclick_delay_ms == autoclick_delay_ms_) |
780 return; | 744 return; |
781 autoclick_delay_ms_ = autoclick_delay_ms; | 745 autoclick_delay_ms_ = autoclick_delay_ms; |
782 | 746 |
783 #if defined(USE_ASH) && !defined(USE_ATHENA) | |
784 ash::Shell::GetInstance()->autoclick_controller()->SetAutoclickDelay( | 747 ash::Shell::GetInstance()->autoclick_controller()->SetAutoclickDelay( |
785 autoclick_delay_ms_); | 748 autoclick_delay_ms_); |
786 #endif | |
787 } | 749 } |
788 | 750 |
789 void AccessibilityManager::EnableVirtualKeyboard(bool enabled) { | 751 void AccessibilityManager::EnableVirtualKeyboard(bool enabled) { |
790 if (!profile_) | 752 if (!profile_) |
791 return; | 753 return; |
792 | 754 |
793 PrefService* pref_service = profile_->GetPrefs(); | 755 PrefService* pref_service = profile_->GetPrefs(); |
794 pref_service->SetBoolean(prefs::kAccessibilityVirtualKeyboardEnabled, | 756 pref_service->SetBoolean(prefs::kAccessibilityVirtualKeyboardEnabled, |
795 enabled); | 757 enabled); |
796 pref_service->CommitPendingWrite(); | 758 pref_service->CommitPendingWrite(); |
797 } | 759 } |
798 | 760 |
799 bool AccessibilityManager::IsVirtualKeyboardEnabled() { | 761 bool AccessibilityManager::IsVirtualKeyboardEnabled() { |
800 return virtual_keyboard_enabled_; | 762 return virtual_keyboard_enabled_; |
801 } | 763 } |
802 | 764 |
803 void AccessibilityManager::UpdateVirtualKeyboardFromPref() { | 765 void AccessibilityManager::UpdateVirtualKeyboardFromPref() { |
804 if (!profile_) | 766 if (!profile_) |
805 return; | 767 return; |
806 | 768 |
807 const bool enabled = profile_->GetPrefs()->GetBoolean( | 769 const bool enabled = profile_->GetPrefs()->GetBoolean( |
808 prefs::kAccessibilityVirtualKeyboardEnabled); | 770 prefs::kAccessibilityVirtualKeyboardEnabled); |
809 | 771 |
810 if (virtual_keyboard_enabled_ == enabled) | 772 if (virtual_keyboard_enabled_ == enabled) |
811 return; | 773 return; |
812 virtual_keyboard_enabled_ = enabled; | 774 virtual_keyboard_enabled_ = enabled; |
813 | 775 |
814 #if defined(USE_ASH) && !defined(USE_ATHENA) | |
815 keyboard::SetAccessibilityKeyboardEnabled(enabled); | 776 keyboard::SetAccessibilityKeyboardEnabled(enabled); |
816 // Note that there are two versions of the on-screen keyboard. A full layout | 777 // Note that there are two versions of the on-screen keyboard. A full layout |
817 // is provided for accessibility, which includes sticky modifier keys to | 778 // is provided for accessibility, which includes sticky modifier keys to |
818 // enable typing of hotkeys. A compact version is used in touchview mode | 779 // enable typing of hotkeys. A compact version is used in touchview mode |
819 // to provide a layout with larger keys to facilitate touch typing. In the | 780 // to provide a layout with larger keys to facilitate touch typing. In the |
820 // event that the a11y keyboard is being disabled, an on-screen keyboard might | 781 // event that the a11y keyboard is being disabled, an on-screen keyboard might |
821 // still be enabled and a forced reset is required to pick up the layout | 782 // still be enabled and a forced reset is required to pick up the layout |
822 // change. | 783 // change. |
823 if (keyboard::IsKeyboardEnabled()) | 784 if (keyboard::IsKeyboardEnabled()) |
824 ash::Shell::GetInstance()->CreateKeyboard(); | 785 ash::Shell::GetInstance()->CreateKeyboard(); |
825 else | 786 else |
826 ash::Shell::GetInstance()->DeactivateKeyboard(); | 787 ash::Shell::GetInstance()->DeactivateKeyboard(); |
827 #endif | |
828 | 788 |
829 AccessibilityStatusEventDetails details( | 789 AccessibilityStatusEventDetails details( |
830 ACCESSIBILITY_TOGGLE_VIRTUAL_KEYBOARD, | 790 ACCESSIBILITY_TOGGLE_VIRTUAL_KEYBOARD, |
831 enabled, | 791 enabled, |
832 ui::A11Y_NOTIFICATION_NONE); | 792 ui::A11Y_NOTIFICATION_NONE); |
833 NotifyAccessibilityStatusChanged(details); | 793 NotifyAccessibilityStatusChanged(details); |
834 } | 794 } |
835 | 795 |
836 bool AccessibilityManager::IsBrailleDisplayConnected() const { | 796 bool AccessibilityManager::IsBrailleDisplayConnected() const { |
837 return braille_display_connected_; | 797 return braille_display_connected_; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
878 preload_engines.erase(it); | 838 preload_engines.erase(it); |
879 pref_service->SetString(prefs::kLanguagePreloadEngines, | 839 pref_service->SetString(prefs::kLanguagePreloadEngines, |
880 JoinString(preload_engines, ',')); | 840 JoinString(preload_engines, ',')); |
881 braille_ime_current_ = false; | 841 braille_ime_current_ = false; |
882 } | 842 } |
883 | 843 |
884 // Overridden from InputMethodManager::Observer. | 844 // Overridden from InputMethodManager::Observer. |
885 void AccessibilityManager::InputMethodChanged( | 845 void AccessibilityManager::InputMethodChanged( |
886 input_method::InputMethodManager* manager, | 846 input_method::InputMethodManager* manager, |
887 bool show_message) { | 847 bool show_message) { |
888 #if defined(USE_ASH) && !defined(USE_ATHENA) | |
889 // Sticky keys is implemented only in ash. | 848 // Sticky keys is implemented only in ash. |
890 // TODO(dpolukhin): support Athena, crbug.com/408733. | 849 // TODO(dpolukhin): support Athena, crbug.com/408733. |
891 ash::Shell::GetInstance()->sticky_keys_controller()->SetModifiersEnabled( | 850 ash::Shell::GetInstance()->sticky_keys_controller()->SetModifiersEnabled( |
892 manager->IsISOLevel5ShiftUsedByCurrentInputMethod(), | 851 manager->IsISOLevel5ShiftUsedByCurrentInputMethod(), |
893 manager->IsAltGrUsedByCurrentInputMethod()); | 852 manager->IsAltGrUsedByCurrentInputMethod()); |
894 #endif | |
895 const chromeos::input_method::InputMethodDescriptor descriptor = | 853 const chromeos::input_method::InputMethodDescriptor descriptor = |
896 manager->GetActiveIMEState()->GetCurrentInputMethod(); | 854 manager->GetActiveIMEState()->GetCurrentInputMethod(); |
897 braille_ime_current_ = | 855 braille_ime_current_ = |
898 (descriptor.id() == extension_misc::kBrailleImeEngineId); | 856 (descriptor.id() == extension_misc::kBrailleImeEngineId); |
899 } | 857 } |
900 | 858 |
901 void AccessibilityManager::SetProfile(Profile* profile) { | 859 void AccessibilityManager::SetProfile(Profile* profile) { |
902 pref_change_registrar_.reset(); | 860 pref_change_registrar_.reset(); |
903 local_state_pref_change_registrar_.reset(); | 861 local_state_pref_change_registrar_.reset(); |
904 | 862 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
964 UpdateBrailleImeState(); | 922 UpdateBrailleImeState(); |
965 UpdateLargeCursorFromPref(); | 923 UpdateLargeCursorFromPref(); |
966 UpdateStickyKeysFromPref(); | 924 UpdateStickyKeysFromPref(); |
967 UpdateSpokenFeedbackFromPref(); | 925 UpdateSpokenFeedbackFromPref(); |
968 UpdateHighContrastFromPref(); | 926 UpdateHighContrastFromPref(); |
969 UpdateAutoclickFromPref(); | 927 UpdateAutoclickFromPref(); |
970 UpdateAutoclickDelayFromPref(); | 928 UpdateAutoclickDelayFromPref(); |
971 UpdateVirtualKeyboardFromPref(); | 929 UpdateVirtualKeyboardFromPref(); |
972 } | 930 } |
973 | 931 |
974 #if !defined(USE_ATHENA) | |
975 void AccessibilityManager::ActiveUserChanged(const std::string& user_id) { | 932 void AccessibilityManager::ActiveUserChanged(const std::string& user_id) { |
976 SetProfile(ProfileManager::GetActiveUserProfile()); | 933 SetProfile(ProfileManager::GetActiveUserProfile()); |
977 } | 934 } |
978 #endif | |
979 | 935 |
980 void AccessibilityManager::SetProfileForTest(Profile* profile) { | 936 void AccessibilityManager::SetProfileForTest(Profile* profile) { |
981 SetProfile(profile); | 937 SetProfile(profile); |
982 } | 938 } |
983 | 939 |
984 void AccessibilityManager::SetBrailleControllerForTest( | 940 void AccessibilityManager::SetBrailleControllerForTest( |
985 BrailleController* controller) { | 941 BrailleController* controller) { |
986 g_braille_controller_for_test = controller; | 942 g_braille_controller_for_test = controller; |
987 } | 943 } |
988 | 944 |
989 void AccessibilityManager::EnableSystemSounds(bool system_sounds_enabled) { | 945 void AccessibilityManager::EnableSystemSounds(bool system_sounds_enabled) { |
990 system_sounds_enabled_ = system_sounds_enabled; | 946 system_sounds_enabled_ = system_sounds_enabled; |
991 } | 947 } |
992 | 948 |
993 base::TimeDelta AccessibilityManager::PlayShutdownSound() { | 949 base::TimeDelta AccessibilityManager::PlayShutdownSound() { |
994 if (!system_sounds_enabled_) | 950 if (!system_sounds_enabled_) |
995 return base::TimeDelta(); | 951 return base::TimeDelta(); |
996 system_sounds_enabled_ = false; | 952 system_sounds_enabled_ = false; |
997 #if !defined(USE_ATHENA) | |
998 if (!ash::PlaySystemSoundIfSpokenFeedback(SOUND_SHUTDOWN)) | 953 if (!ash::PlaySystemSoundIfSpokenFeedback(SOUND_SHUTDOWN)) |
999 return base::TimeDelta(); | 954 return base::TimeDelta(); |
1000 #endif | |
1001 return media::SoundsManager::Get()->GetDuration(SOUND_SHUTDOWN); | 955 return media::SoundsManager::Get()->GetDuration(SOUND_SHUTDOWN); |
1002 } | 956 } |
1003 | 957 |
1004 void AccessibilityManager::InjectChromeVox(RenderViewHost* render_view_host) { | 958 void AccessibilityManager::InjectChromeVox(RenderViewHost* render_view_host) { |
1005 LoadChromeVoxExtension(profile_, render_view_host, base::Closure()); | 959 LoadChromeVoxExtension(profile_, render_view_host, base::Closure()); |
1006 } | 960 } |
1007 | 961 |
1008 scoped_ptr<AccessibilityStatusSubscription> | 962 scoped_ptr<AccessibilityStatusSubscription> |
1009 AccessibilityManager::RegisterCallback( | 963 AccessibilityManager::RegisterCallback( |
1010 const AccessibilityStatusCallback& cb) { | 964 const AccessibilityStatusCallback& cb) { |
1011 return callback_list_.Add(cb); | 965 return callback_list_.Add(cb); |
1012 } | 966 } |
1013 | 967 |
1014 void AccessibilityManager::NotifyAccessibilityStatusChanged( | 968 void AccessibilityManager::NotifyAccessibilityStatusChanged( |
1015 AccessibilityStatusEventDetails& details) { | 969 AccessibilityStatusEventDetails& details) { |
1016 callback_list_.Notify(details); | 970 callback_list_.Notify(details); |
1017 } | 971 } |
1018 | 972 |
1019 void AccessibilityManager::UpdateChromeOSAccessibilityHistograms() { | 973 void AccessibilityManager::UpdateChromeOSAccessibilityHistograms() { |
1020 UMA_HISTOGRAM_BOOLEAN("Accessibility.CrosSpokenFeedback", | 974 UMA_HISTOGRAM_BOOLEAN("Accessibility.CrosSpokenFeedback", |
1021 IsSpokenFeedbackEnabled()); | 975 IsSpokenFeedbackEnabled()); |
1022 UMA_HISTOGRAM_BOOLEAN("Accessibility.CrosHighContrast", | 976 UMA_HISTOGRAM_BOOLEAN("Accessibility.CrosHighContrast", |
1023 IsHighContrastEnabled()); | 977 IsHighContrastEnabled()); |
1024 UMA_HISTOGRAM_BOOLEAN("Accessibility.CrosVirtualKeyboard", | 978 UMA_HISTOGRAM_BOOLEAN("Accessibility.CrosVirtualKeyboard", |
1025 IsVirtualKeyboardEnabled()); | 979 IsVirtualKeyboardEnabled()); |
1026 UMA_HISTOGRAM_BOOLEAN("Accessibility.CrosStickyKeys", IsStickyKeysEnabled()); | 980 UMA_HISTOGRAM_BOOLEAN("Accessibility.CrosStickyKeys", IsStickyKeysEnabled()); |
1027 #if !defined(USE_ATHENA) | |
1028 if (MagnificationManager::Get()) { | 981 if (MagnificationManager::Get()) { |
1029 uint32 type = MagnificationManager::Get()->IsMagnifierEnabled() ? | 982 uint32 type = MagnificationManager::Get()->IsMagnifierEnabled() ? |
1030 MagnificationManager::Get()->GetMagnifierType() : 0; | 983 MagnificationManager::Get()->GetMagnifierType() : 0; |
1031 // '0' means magnifier is disabled. | 984 // '0' means magnifier is disabled. |
1032 UMA_HISTOGRAM_ENUMERATION("Accessibility.CrosScreenMagnifier", | 985 UMA_HISTOGRAM_ENUMERATION("Accessibility.CrosScreenMagnifier", |
1033 type, | 986 type, |
1034 ui::kMaxMagnifierType + 1); | 987 ui::kMaxMagnifierType + 1); |
1035 } | 988 } |
1036 #endif | |
1037 if (profile_) { | 989 if (profile_) { |
1038 const PrefService* const prefs = profile_->GetPrefs(); | 990 const PrefService* const prefs = profile_->GetPrefs(); |
1039 UMA_HISTOGRAM_BOOLEAN( | 991 UMA_HISTOGRAM_BOOLEAN( |
1040 "Accessibility.CrosLargeCursor", | 992 "Accessibility.CrosLargeCursor", |
1041 prefs->GetBoolean(prefs::kAccessibilityLargeCursorEnabled)); | 993 prefs->GetBoolean(prefs::kAccessibilityLargeCursorEnabled)); |
1042 UMA_HISTOGRAM_BOOLEAN( | 994 UMA_HISTOGRAM_BOOLEAN( |
1043 "Accessibility.CrosAlwaysShowA11yMenu", | 995 "Accessibility.CrosAlwaysShowA11yMenu", |
1044 prefs->GetBoolean(prefs::kShouldAlwaysShowAccessibilityMenu)); | 996 prefs->GetBoolean(prefs::kShouldAlwaysShowAccessibilityMenu)); |
1045 | 997 |
1046 bool autoclick_enabled = | 998 bool autoclick_enabled = |
(...skipping 25 matching lines...) Expand all Loading... |
1072 SetProfile(profile); | 1024 SetProfile(profile); |
1073 break; | 1025 break; |
1074 } | 1026 } |
1075 case chrome::NOTIFICATION_SESSION_STARTED: | 1027 case chrome::NOTIFICATION_SESSION_STARTED: |
1076 // Update |profile_| when entering a session. | 1028 // Update |profile_| when entering a session. |
1077 SetProfile(ProfileManager::GetActiveUserProfile()); | 1029 SetProfile(ProfileManager::GetActiveUserProfile()); |
1078 | 1030 |
1079 // Ensure ChromeVox makes announcements at the start of new sessions. | 1031 // Ensure ChromeVox makes announcements at the start of new sessions. |
1080 should_speak_chrome_vox_announcements_on_user_screen_ = true; | 1032 should_speak_chrome_vox_announcements_on_user_screen_ = true; |
1081 | 1033 |
1082 #if !defined(USE_ATHENA) | |
1083 // Add a session state observer to be able to monitor session changes. | 1034 // Add a session state observer to be able to monitor session changes. |
1084 if (!session_state_observer_.get() && ash::Shell::HasInstance()) | 1035 if (!session_state_observer_.get() && ash::Shell::HasInstance()) |
1085 session_state_observer_.reset( | 1036 session_state_observer_.reset( |
1086 new ash::ScopedSessionStateObserver(this)); | 1037 new ash::ScopedSessionStateObserver(this)); |
1087 #endif | |
1088 break; | 1038 break; |
1089 case chrome::NOTIFICATION_PROFILE_DESTROYED: { | 1039 case chrome::NOTIFICATION_PROFILE_DESTROYED: { |
1090 // Update |profile_| when exiting a session or shutting down. | 1040 // Update |profile_| when exiting a session or shutting down. |
1091 Profile* profile = content::Source<Profile>(source).ptr(); | 1041 Profile* profile = content::Source<Profile>(source).ptr(); |
1092 if (profile_ == profile) | 1042 if (profile_ == profile) |
1093 SetProfile(NULL); | 1043 SetProfile(NULL); |
1094 break; | 1044 break; |
1095 } | 1045 } |
1096 case chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED: { | 1046 case chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED: { |
1097 bool is_screen_locked = *content::Details<bool>(details).ptr(); | 1047 bool is_screen_locked = *content::Details<bool>(details).ptr(); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1130 extensions::api::braille_display_private::KEY_COMMAND_DOTS) && | 1080 extensions::api::braille_display_private::KEY_COMMAND_DOTS) && |
1131 !braille_ime_current_) { | 1081 !braille_ime_current_) { |
1132 input_method::InputMethodManager::Get() | 1082 input_method::InputMethodManager::Get() |
1133 ->GetActiveIMEState() | 1083 ->GetActiveIMEState() |
1134 ->ChangeInputMethod(extension_misc::kBrailleImeEngineId, | 1084 ->ChangeInputMethod(extension_misc::kBrailleImeEngineId, |
1135 false /* show_message */); | 1085 false /* show_message */); |
1136 } | 1086 } |
1137 } | 1087 } |
1138 | 1088 |
1139 void AccessibilityManager::PostLoadChromeVox(Profile* profile) { | 1089 void AccessibilityManager::PostLoadChromeVox(Profile* profile) { |
1140 #if !defined(USE_ATHENA) | |
1141 // Do any setup work needed immediately after ChromeVox actually loads. | 1090 // Do any setup work needed immediately after ChromeVox actually loads. |
1142 if (system_sounds_enabled_) | 1091 if (system_sounds_enabled_) |
1143 ash::PlaySystemSoundAlways(SOUND_SPOKEN_FEEDBACK_ENABLED); | 1092 ash::PlaySystemSoundAlways(SOUND_SPOKEN_FEEDBACK_ENABLED); |
1144 #endif | |
1145 | 1093 |
1146 ExtensionAccessibilityEventRouter::GetInstance()-> | 1094 ExtensionAccessibilityEventRouter::GetInstance()-> |
1147 OnChromeVoxLoadStateChanged(profile_, | 1095 OnChromeVoxLoadStateChanged(profile_, |
1148 IsSpokenFeedbackEnabled(), | 1096 IsSpokenFeedbackEnabled(), |
1149 chrome_vox_loaded_on_lock_screen_ || | 1097 chrome_vox_loaded_on_lock_screen_ || |
1150 should_speak_chrome_vox_announcements_on_user_screen_); | 1098 should_speak_chrome_vox_announcements_on_user_screen_); |
1151 | 1099 |
1152 should_speak_chrome_vox_announcements_on_user_screen_ = | 1100 should_speak_chrome_vox_announcements_on_user_screen_ = |
1153 chrome_vox_loaded_on_lock_screen_; | 1101 chrome_vox_loaded_on_lock_screen_; |
1154 } | 1102 } |
1155 | 1103 |
1156 void AccessibilityManager::PostUnloadChromeVox(Profile* profile) { | 1104 void AccessibilityManager::PostUnloadChromeVox(Profile* profile) { |
1157 #if !defined(USE_ATHENA) | |
1158 // Do any teardown work needed immediately after ChromeVox actually unloads. | 1105 // Do any teardown work needed immediately after ChromeVox actually unloads. |
1159 if (system_sounds_enabled_) | 1106 if (system_sounds_enabled_) |
1160 ash::PlaySystemSoundAlways(SOUND_SPOKEN_FEEDBACK_DISABLED); | 1107 ash::PlaySystemSoundAlways(SOUND_SPOKEN_FEEDBACK_DISABLED); |
1161 #endif | |
1162 // Clear the accessibility focus ring. | 1108 // Clear the accessibility focus ring. |
1163 AccessibilityFocusRingController::GetInstance()->SetFocusRing( | 1109 AccessibilityFocusRingController::GetInstance()->SetFocusRing( |
1164 std::vector<gfx::Rect>()); | 1110 std::vector<gfx::Rect>()); |
1165 } | 1111 } |
1166 | 1112 |
1167 } // namespace chromeos | 1113 } // namespace chromeos |
OLD | NEW |