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/autoclick/autoclick_controller.h" | 7 #include "ash/autoclick/autoclick_controller.h" |
8 #include "ash/high_contrast/high_contrast_controller.h" | 8 #include "ash/high_contrast/high_contrast_controller.h" |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/system/tray/system_tray_notifier.h" | 10 #include "ash/system/tray/system_tray_notifier.h" |
(...skipping 18 matching lines...) Expand all Loading... | |
29 #include "chrome/browser/extensions/extension_system.h" | 29 #include "chrome/browser/extensions/extension_system.h" |
30 #include "chrome/browser/profiles/profile.h" | 30 #include "chrome/browser/profiles/profile.h" |
31 #include "chrome/browser/profiles/profile_manager.h" | 31 #include "chrome/browser/profiles/profile_manager.h" |
32 #include "chrome/browser/speech/tts_controller.h" | 32 #include "chrome/browser/speech/tts_controller.h" |
33 #include "chrome/common/extensions/extension.h" | 33 #include "chrome/common/extensions/extension.h" |
34 #include "chrome/common/extensions/extension_messages.h" | 34 #include "chrome/common/extensions/extension_messages.h" |
35 #include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h" | 35 #include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h" |
36 #include "chrome/common/pref_names.h" | 36 #include "chrome/common/pref_names.h" |
37 #include "chromeos/login/login_state.h" | 37 #include "chromeos/login/login_state.h" |
38 #include "content/public/browser/browser_accessibility_state.h" | 38 #include "content/public/browser/browser_accessibility_state.h" |
39 #include "content/public/browser/browser_thread.h" | |
39 #include "content/public/browser/notification_details.h" | 40 #include "content/public/browser/notification_details.h" |
40 #include "content/public/browser/notification_service.h" | 41 #include "content/public/browser/notification_service.h" |
41 #include "content/public/browser/notification_source.h" | 42 #include "content/public/browser/notification_source.h" |
42 #include "content/public/browser/render_process_host.h" | 43 #include "content/public/browser/render_process_host.h" |
43 #include "content/public/browser/render_view_host.h" | 44 #include "content/public/browser/render_view_host.h" |
44 #include "content/public/browser/web_contents.h" | 45 #include "content/public/browser/web_contents.h" |
45 #include "content/public/browser/web_ui.h" | 46 #include "content/public/browser/web_ui.h" |
46 #include "extensions/browser/file_reader.h" | 47 #include "extensions/browser/file_reader.h" |
47 #include "extensions/common/extension_resource.h" | 48 #include "extensions/common/extension_resource.h" |
48 #include "grit/browser_resources.h" | 49 #include "grit/browser_resources.h" |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
265 large_cursor_pref_handler_(prefs::kLargeCursorEnabled), | 266 large_cursor_pref_handler_(prefs::kLargeCursorEnabled), |
266 spoken_feedback_pref_handler_(prefs::kSpokenFeedbackEnabled), | 267 spoken_feedback_pref_handler_(prefs::kSpokenFeedbackEnabled), |
267 high_contrast_pref_handler_(prefs::kHighContrastEnabled), | 268 high_contrast_pref_handler_(prefs::kHighContrastEnabled), |
268 autoclick_pref_handler_(prefs::kAutoclickEnabled), | 269 autoclick_pref_handler_(prefs::kAutoclickEnabled), |
269 autoclick_delay_pref_handler_(prefs::kAutoclickDelayMs), | 270 autoclick_delay_pref_handler_(prefs::kAutoclickDelayMs), |
270 large_cursor_enabled_(false), | 271 large_cursor_enabled_(false), |
271 sticky_keys_enabled_(false), | 272 sticky_keys_enabled_(false), |
272 spoken_feedback_enabled_(false), | 273 spoken_feedback_enabled_(false), |
273 high_contrast_enabled_(false), | 274 high_contrast_enabled_(false), |
274 autoclick_delay_ms_(ash::AutoclickController::kDefaultAutoclickDelayMs), | 275 autoclick_delay_ms_(ash::AutoclickController::kDefaultAutoclickDelayMs), |
275 spoken_feedback_notification_(ash::A11Y_NOTIFICATION_NONE) { | 276 spoken_feedback_notification_(ash::A11Y_NOTIFICATION_NONE), |
276 | 277 should_speak_chrome_vox_announcements_on_user_screen_(true) { |
277 notification_registrar_.Add(this, | 278 notification_registrar_.Add(this, |
278 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, | 279 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, |
279 content::NotificationService::AllSources()); | 280 content::NotificationService::AllSources()); |
280 notification_registrar_.Add(this, | 281 notification_registrar_.Add(this, |
281 chrome::NOTIFICATION_SESSION_STARTED, | 282 chrome::NOTIFICATION_SESSION_STARTED, |
282 content::NotificationService::AllSources()); | 283 content::NotificationService::AllSources()); |
283 notification_registrar_.Add(this, | 284 notification_registrar_.Add(this, |
284 chrome::NOTIFICATION_PROFILE_DESTROYED, | 285 chrome::NOTIFICATION_PROFILE_DESTROYED, |
285 content::NotificationService::AllSources()); | 286 content::NotificationService::AllSources()); |
286 notification_registrar_.Add(this, | 287 notification_registrar_.Add(this, |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
380 return; | 381 return; |
381 | 382 |
382 const bool enabled = | 383 const bool enabled = |
383 profile_->GetPrefs()->GetBoolean(prefs::kSpokenFeedbackEnabled); | 384 profile_->GetPrefs()->GetBoolean(prefs::kSpokenFeedbackEnabled); |
384 | 385 |
385 if (spoken_feedback_enabled_ == enabled) | 386 if (spoken_feedback_enabled_ == enabled) |
386 return; | 387 return; |
387 | 388 |
388 spoken_feedback_enabled_ = enabled; | 389 spoken_feedback_enabled_ = enabled; |
389 | 390 |
390 Speak(l10n_util::GetStringUTF8( | |
391 enabled ? IDS_CHROMEOS_ACC_SPOKEN_FEEDBACK_ENABLED : | |
392 IDS_CHROMEOS_ACC_SPOKEN_FEEDBACK_DISABLED).c_str()); | |
393 | |
394 ExtensionAccessibilityEventRouter::GetInstance()-> | 391 ExtensionAccessibilityEventRouter::GetInstance()-> |
395 SetAccessibilityEnabled(enabled); | 392 SetAccessibilityEnabled(enabled); |
396 | 393 |
397 AccessibilityStatusEventDetails details(enabled, | 394 AccessibilityStatusEventDetails details(enabled, |
398 spoken_feedback_notification_); | 395 spoken_feedback_notification_); |
399 content::NotificationService::current()->Notify( | 396 content::NotificationService::current()->Notify( |
400 chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK, | 397 chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK, |
401 content::NotificationService::AllSources(), | 398 content::NotificationService::AllSources(), |
402 content::Details<AccessibilityStatusEventDetails>(&details)); | 399 content::Details<AccessibilityStatusEventDetails>(&details)); |
403 | 400 |
404 if (enabled) | 401 if (enabled) { |
405 LoadChromeVox(); | 402 LoadChromeVox(); |
406 else | 403 ExtensionAccessibilityEventRouter::GetInstance()-> |
407 UnloadChromeVox(); | 404 OnSpokenFeedbackEnabled(profile_, |
405 chrome_vox_loaded_on_lock_screen_ || | |
406 should_speak_chrome_vox_announcements_on_user_screen_); | |
407 | |
408 should_speak_chrome_vox_announcements_on_user_screen_ = | |
409 chrome_vox_loaded_on_lock_screen_; | |
410 } else { | |
411 ExtensionAccessibilityEventRouter::GetInstance()-> | |
412 OnSpokenFeedbackDisabled(profile_); | |
413 | |
414 // Give ChromeVox a chance to speak/braille outgoing messages. | |
dmazzoni
2013/10/25 23:09:16
How about "announce" instead of speak/braille
| |
415 content::BrowserThread::PostDelayedTask( | |
416 content::BrowserThread::UI, | |
417 FROM_HERE, | |
418 base::Bind(&AccessibilityManager::UnloadChromeVox, | |
419 base::Unretained(this)), | |
420 base::TimeDelta::FromSeconds(1)); | |
dmazzoni
2013/10/25 23:09:16
I know it's trivial, but let's make 1 a named cons
| |
421 } | |
408 } | 422 } |
409 | 423 |
410 void AccessibilityManager::LoadChromeVox() { | 424 void AccessibilityManager::LoadChromeVox() { |
411 ScreenLocker* screen_locker = ScreenLocker::default_screen_locker(); | 425 ScreenLocker* screen_locker = ScreenLocker::default_screen_locker(); |
412 if (screen_locker && screen_locker->locked()) { | 426 if (screen_locker && screen_locker->locked()) { |
413 // If on the lock screen, loads ChromeVox only to the lock screen as for | 427 // If on the lock screen, loads ChromeVox only to the lock screen as for |
414 // now. On unlock, it will be loaded to the user screen. | 428 // now. On unlock, it will be loaded to the user screen. |
415 // (see. AccessibilityManager::Observe()) | 429 // (see. AccessibilityManager::Observe()) |
416 LoadChromeVoxToLockScreen(); | 430 LoadChromeVoxToLockScreen(); |
417 return; | 431 return; |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
703 case chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE: { | 717 case chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE: { |
704 // Update |profile_| when entering the login screen. | 718 // Update |profile_| when entering the login screen. |
705 Profile* profile = ProfileManager::GetDefaultProfile(); | 719 Profile* profile = ProfileManager::GetDefaultProfile(); |
706 if (ProfileHelper::IsSigninProfile(profile)) | 720 if (ProfileHelper::IsSigninProfile(profile)) |
707 SetProfile(profile); | 721 SetProfile(profile); |
708 break; | 722 break; |
709 } | 723 } |
710 case chrome::NOTIFICATION_SESSION_STARTED: | 724 case chrome::NOTIFICATION_SESSION_STARTED: |
711 // Update |profile_| when entering a session. | 725 // Update |profile_| when entering a session. |
712 SetProfile(ProfileManager::GetDefaultProfile()); | 726 SetProfile(ProfileManager::GetDefaultProfile()); |
727 | |
728 // Ensure ChromeVox makes announcements at the start of new sessions. | |
729 should_speak_chrome_vox_announcements_on_user_screen_ = true; | |
713 break; | 730 break; |
714 case chrome::NOTIFICATION_PROFILE_DESTROYED: { | 731 case chrome::NOTIFICATION_PROFILE_DESTROYED: { |
715 // Update |profile_| when exiting a session or shutting down. | 732 // Update |profile_| when exiting a session or shutting down. |
716 Profile* profile = content::Source<Profile>(source).ptr(); | 733 Profile* profile = content::Source<Profile>(source).ptr(); |
717 if (profile_ == profile) | 734 if (profile_ == profile) |
718 SetProfile(NULL); | 735 SetProfile(NULL); |
719 break; | 736 break; |
720 } | 737 } |
721 case chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED: { | 738 case chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED: { |
722 bool is_screen_locked = *content::Details<bool>(details).ptr(); | 739 bool is_screen_locked = *content::Details<bool>(details).ptr(); |
723 if (is_screen_locked) { | 740 if (is_screen_locked) { |
724 if (spoken_feedback_enabled_) | 741 if (spoken_feedback_enabled_) |
725 LoadChromeVoxToLockScreen(); | 742 LoadChromeVoxToLockScreen(); |
726 } else { | 743 } else { |
727 UnloadChromeVoxFromLockScreen(); | 744 UnloadChromeVoxFromLockScreen(); |
728 | 745 |
729 if (spoken_feedback_enabled_) | 746 if (spoken_feedback_enabled_) |
730 LoadChromeVoxToUserScreen(); | 747 LoadChromeVoxToUserScreen(); |
731 } | 748 } |
732 } | 749 } |
733 } | 750 } |
734 } | 751 } |
735 | 752 |
736 } // namespace chromeos | 753 } // namespace chromeos |
OLD | NEW |