Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(499)

Side by Side Diff: chrome/browser/chromeos/accessibility/accessibility_manager.cc

Issue 42743003: Adjust ChromeVox (spoken feedback) strings and make it possible for announcemen (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rename. Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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"
49 #include "grit/generated_resources.h" 50 #include "grit/generated_resources.h"
50 #include "ui/base/l10n/l10n_util.h" 51 #include "ui/base/l10n/l10n_util.h"
51 #include "ui/base/resource/resource_bundle.h" 52 #include "ui/base/resource/resource_bundle.h"
52 53
53 using content::RenderViewHost; 54 using content::RenderViewHost;
54 55
55 namespace chromeos { 56 namespace chromeos {
56 57
57 namespace { 58 namespace {
58 59
59 static chromeos::AccessibilityManager* g_accessibility_manager = NULL; 60 static chromeos::AccessibilityManager* g_accessibility_manager = NULL;
60 61
62 namespace {
63 const int kChromeVoxUnloadDelaySeconds = 1;
64 } // namespace
65
61 // Helper class that directly loads an extension's content scripts into 66 // Helper class that directly loads an extension's content scripts into
62 // all of the frames corresponding to a given RenderViewHost. 67 // all of the frames corresponding to a given RenderViewHost.
63 class ContentScriptLoader { 68 class ContentScriptLoader {
64 public: 69 public:
65 // Initialize the ContentScriptLoader with the ID of the extension 70 // Initialize the ContentScriptLoader with the ID of the extension
66 // and the RenderViewHost where the scripts should be loaded. 71 // and the RenderViewHost where the scripts should be loaded.
67 ContentScriptLoader(const std::string& extension_id, 72 ContentScriptLoader(const std::string& extension_id,
68 int render_process_id, 73 int render_process_id,
69 int render_view_id) 74 int render_view_id)
70 : extension_id_(extension_id), 75 : extension_id_(extension_id),
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 large_cursor_pref_handler_(prefs::kLargeCursorEnabled), 270 large_cursor_pref_handler_(prefs::kLargeCursorEnabled),
266 spoken_feedback_pref_handler_(prefs::kSpokenFeedbackEnabled), 271 spoken_feedback_pref_handler_(prefs::kSpokenFeedbackEnabled),
267 high_contrast_pref_handler_(prefs::kHighContrastEnabled), 272 high_contrast_pref_handler_(prefs::kHighContrastEnabled),
268 autoclick_pref_handler_(prefs::kAutoclickEnabled), 273 autoclick_pref_handler_(prefs::kAutoclickEnabled),
269 autoclick_delay_pref_handler_(prefs::kAutoclickDelayMs), 274 autoclick_delay_pref_handler_(prefs::kAutoclickDelayMs),
270 large_cursor_enabled_(false), 275 large_cursor_enabled_(false),
271 sticky_keys_enabled_(false), 276 sticky_keys_enabled_(false),
272 spoken_feedback_enabled_(false), 277 spoken_feedback_enabled_(false),
273 high_contrast_enabled_(false), 278 high_contrast_enabled_(false),
274 autoclick_delay_ms_(ash::AutoclickController::kDefaultAutoclickDelayMs), 279 autoclick_delay_ms_(ash::AutoclickController::kDefaultAutoclickDelayMs),
275 spoken_feedback_notification_(ash::A11Y_NOTIFICATION_NONE) { 280 spoken_feedback_notification_(ash::A11Y_NOTIFICATION_NONE),
276 281 should_speak_chrome_vox_announcements_on_user_screen_(true) {
277 notification_registrar_.Add(this, 282 notification_registrar_.Add(this,
278 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, 283 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE,
279 content::NotificationService::AllSources()); 284 content::NotificationService::AllSources());
280 notification_registrar_.Add(this, 285 notification_registrar_.Add(this,
281 chrome::NOTIFICATION_SESSION_STARTED, 286 chrome::NOTIFICATION_SESSION_STARTED,
282 content::NotificationService::AllSources()); 287 content::NotificationService::AllSources());
283 notification_registrar_.Add(this, 288 notification_registrar_.Add(this,
284 chrome::NOTIFICATION_PROFILE_DESTROYED, 289 chrome::NOTIFICATION_PROFILE_DESTROYED,
285 content::NotificationService::AllSources()); 290 content::NotificationService::AllSources());
286 notification_registrar_.Add(this, 291 notification_registrar_.Add(this,
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 return; 385 return;
381 386
382 const bool enabled = 387 const bool enabled =
383 profile_->GetPrefs()->GetBoolean(prefs::kSpokenFeedbackEnabled); 388 profile_->GetPrefs()->GetBoolean(prefs::kSpokenFeedbackEnabled);
384 389
385 if (spoken_feedback_enabled_ == enabled) 390 if (spoken_feedback_enabled_ == enabled)
386 return; 391 return;
387 392
388 spoken_feedback_enabled_ = enabled; 393 spoken_feedback_enabled_ = enabled;
389 394
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()-> 395 ExtensionAccessibilityEventRouter::GetInstance()->
395 SetAccessibilityEnabled(enabled); 396 SetAccessibilityEnabled(enabled);
396 397
397 AccessibilityStatusEventDetails details(enabled, 398 AccessibilityStatusEventDetails details(enabled,
398 spoken_feedback_notification_); 399 spoken_feedback_notification_);
399 content::NotificationService::current()->Notify( 400 content::NotificationService::current()->Notify(
400 chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK, 401 chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK,
401 content::NotificationService::AllSources(), 402 content::NotificationService::AllSources(),
402 content::Details<AccessibilityStatusEventDetails>(&details)); 403 content::Details<AccessibilityStatusEventDetails>(&details));
403 404
404 if (enabled) 405 if (enabled) {
405 LoadChromeVox(); 406 LoadChromeVox();
406 else 407 ExtensionAccessibilityEventRouter::GetInstance()->
407 UnloadChromeVox(); 408 OnSpokenFeedbackEnabled(profile_,
409 chrome_vox_loaded_on_lock_screen_ ||
410 should_speak_chrome_vox_announcements_on_user_screen_);
411
412 should_speak_chrome_vox_announcements_on_user_screen_ =
413 chrome_vox_loaded_on_lock_screen_;
414 } else {
415 ExtensionAccessibilityEventRouter::GetInstance()->
416 OnSpokenFeedbackDisabled(profile_);
417
418 // Give ChromeVox a chance to announce outgoing messages.
419 content::BrowserThread::PostDelayedTask(
420 content::BrowserThread::UI,
421 FROM_HERE,
422 base::Bind(&AccessibilityManager::UnloadChromeVox,
423 base::Unretained(this)),
424 base::TimeDelta::FromSeconds(kChromeVoxUnloadDelaySeconds));
425 }
408 } 426 }
409 427
410 void AccessibilityManager::LoadChromeVox() { 428 void AccessibilityManager::LoadChromeVox() {
411 ScreenLocker* screen_locker = ScreenLocker::default_screen_locker(); 429 ScreenLocker* screen_locker = ScreenLocker::default_screen_locker();
412 if (screen_locker && screen_locker->locked()) { 430 if (screen_locker && screen_locker->locked()) {
413 // If on the lock screen, loads ChromeVox only to the lock screen as for 431 // 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. 432 // now. On unlock, it will be loaded to the user screen.
415 // (see. AccessibilityManager::Observe()) 433 // (see. AccessibilityManager::Observe())
416 LoadChromeVoxToLockScreen(); 434 LoadChromeVoxToLockScreen();
417 return; 435 return;
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 case chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE: { 721 case chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE: {
704 // Update |profile_| when entering the login screen. 722 // Update |profile_| when entering the login screen.
705 Profile* profile = ProfileManager::GetDefaultProfile(); 723 Profile* profile = ProfileManager::GetDefaultProfile();
706 if (ProfileHelper::IsSigninProfile(profile)) 724 if (ProfileHelper::IsSigninProfile(profile))
707 SetProfile(profile); 725 SetProfile(profile);
708 break; 726 break;
709 } 727 }
710 case chrome::NOTIFICATION_SESSION_STARTED: 728 case chrome::NOTIFICATION_SESSION_STARTED:
711 // Update |profile_| when entering a session. 729 // Update |profile_| when entering a session.
712 SetProfile(ProfileManager::GetDefaultProfile()); 730 SetProfile(ProfileManager::GetDefaultProfile());
731
732 // Ensure ChromeVox makes announcements at the start of new sessions.
733 should_speak_chrome_vox_announcements_on_user_screen_ = true;
713 break; 734 break;
714 case chrome::NOTIFICATION_PROFILE_DESTROYED: { 735 case chrome::NOTIFICATION_PROFILE_DESTROYED: {
715 // Update |profile_| when exiting a session or shutting down. 736 // Update |profile_| when exiting a session or shutting down.
716 Profile* profile = content::Source<Profile>(source).ptr(); 737 Profile* profile = content::Source<Profile>(source).ptr();
717 if (profile_ == profile) 738 if (profile_ == profile)
718 SetProfile(NULL); 739 SetProfile(NULL);
719 break; 740 break;
720 } 741 }
721 case chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED: { 742 case chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED: {
722 bool is_screen_locked = *content::Details<bool>(details).ptr(); 743 bool is_screen_locked = *content::Details<bool>(details).ptr();
723 if (is_screen_locked) { 744 if (is_screen_locked) {
724 if (spoken_feedback_enabled_) 745 if (spoken_feedback_enabled_)
725 LoadChromeVoxToLockScreen(); 746 LoadChromeVoxToLockScreen();
726 } else { 747 } else {
727 UnloadChromeVoxFromLockScreen(); 748 UnloadChromeVoxFromLockScreen();
728 749
729 if (spoken_feedback_enabled_) 750 if (spoken_feedback_enabled_)
730 LoadChromeVoxToUserScreen(); 751 LoadChromeVoxToUserScreen();
731 } 752 }
732 } 753 }
733 } 754 }
734 } 755 }
735 756
736 } // namespace chromeos 757 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698