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

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

Issue 166273014: Remove dependency on NotificationService for cros a11y settings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge ToT. Created 6 years, 10 months 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 | Annotate | Revision Log
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/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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 extensions::ExtensionSystem::Get(profile)->extension_service(); 202 extensions::ExtensionSystem::Get(profile)->extension_service();
203 extension_service->component_loader()->Remove(path); 203 extension_service->component_loader()->Remove(path);
204 } 204 }
205 205
206 } // namespace 206 } // namespace
207 207
208 /////////////////////////////////////////////////////////////////////////////// 208 ///////////////////////////////////////////////////////////////////////////////
209 // AccessibilityStatusEventDetails 209 // AccessibilityStatusEventDetails
210 210
211 AccessibilityStatusEventDetails::AccessibilityStatusEventDetails( 211 AccessibilityStatusEventDetails::AccessibilityStatusEventDetails(
212 AccessibilityNotificationType notification_type,
212 bool enabled, 213 bool enabled,
213 ash::AccessibilityNotificationVisibility notify) 214 ash::AccessibilityNotificationVisibility notify)
214 : enabled(enabled), 215 : notification_type(notification_type),
216 enabled(enabled),
215 magnifier_type(ash::kDefaultMagnifierType), 217 magnifier_type(ash::kDefaultMagnifierType),
216 notify(notify) {} 218 notify(notify) {}
217 219
218 AccessibilityStatusEventDetails::AccessibilityStatusEventDetails( 220 AccessibilityStatusEventDetails::AccessibilityStatusEventDetails(
221 AccessibilityNotificationType notification_type,
219 bool enabled, 222 bool enabled,
220 ash::MagnifierType magnifier_type, 223 ash::MagnifierType magnifier_type,
221 ash::AccessibilityNotificationVisibility notify) 224 ash::AccessibilityNotificationVisibility notify)
222 : enabled(enabled), 225 : notification_type(notification_type),
226 enabled(enabled),
223 magnifier_type(magnifier_type), 227 magnifier_type(magnifier_type),
224 notify(notify) {} 228 notify(notify) {}
225 229
226 /////////////////////////////////////////////////////////////////////////////// 230 ///////////////////////////////////////////////////////////////////////////////
227 // 231 //
228 // AccessibilityManager::PrefHandler 232 // AccessibilityManager::PrefHandler
229 233
230 AccessibilityManager::PrefHandler::PrefHandler(const char* pref_path) 234 AccessibilityManager::PrefHandler::PrefHandler(const char* pref_path)
231 : pref_path_(pref_path) {} 235 : pref_path_(pref_path) {}
232 236
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 manager->Initialize( 331 manager->Initialize(
328 SOUND_SPOKEN_FEEDBACK_ENABLED, 332 SOUND_SPOKEN_FEEDBACK_ENABLED,
329 bundle.GetRawDataResource(IDR_SOUND_SPOKEN_FEEDBACK_ENABLED_WAV)); 333 bundle.GetRawDataResource(IDR_SOUND_SPOKEN_FEEDBACK_ENABLED_WAV));
330 manager->Initialize( 334 manager->Initialize(
331 SOUND_SPOKEN_FEEDBACK_DISABLED, 335 SOUND_SPOKEN_FEEDBACK_DISABLED,
332 bundle.GetRawDataResource(IDR_SOUND_SPOKEN_FEEDBACK_DISABLED_WAV)); 336 bundle.GetRawDataResource(IDR_SOUND_SPOKEN_FEEDBACK_DISABLED_WAV));
333 } 337 }
334 338
335 AccessibilityManager::~AccessibilityManager() { 339 AccessibilityManager::~AccessibilityManager() {
336 CHECK(this == g_accessibility_manager); 340 CHECK(this == g_accessibility_manager);
341 AccessibilityStatusEventDetails details(
342 ACCESSIBILITY_MANAGER_SHUTDOWN,
343 false,
344 ash::A11Y_NOTIFICATION_NONE);
345 NotifyAccessibilityStatusChanged(details);
337 } 346 }
338 347
339 bool AccessibilityManager::ShouldShowAccessibilityMenu() { 348 bool AccessibilityManager::ShouldShowAccessibilityMenu() {
340 // If any of the loaded profiles has an accessibility feature turned on - or 349 // If any of the loaded profiles has an accessibility feature turned on - or
341 // enforced to always show the menu - we return true to show the menu. 350 // enforced to always show the menu - we return true to show the menu.
342 std::vector<Profile*> profiles = 351 std::vector<Profile*> profiles =
343 g_browser_process->profile_manager()->GetLoadedProfiles(); 352 g_browser_process->profile_manager()->GetLoadedProfiles();
344 for (std::vector<Profile*>::iterator it = profiles.begin(); 353 for (std::vector<Profile*>::iterator it = profiles.begin();
345 it != profiles.end(); 354 it != profiles.end();
346 ++it) { 355 ++it) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 return; 396 return;
388 397
389 const bool enabled = 398 const bool enabled =
390 profile_->GetPrefs()->GetBoolean(prefs::kLargeCursorEnabled); 399 profile_->GetPrefs()->GetBoolean(prefs::kLargeCursorEnabled);
391 400
392 if (large_cursor_enabled_ == enabled) 401 if (large_cursor_enabled_ == enabled)
393 return; 402 return;
394 403
395 large_cursor_enabled_ = enabled; 404 large_cursor_enabled_ = enabled;
396 405
397 AccessibilityStatusEventDetails details(enabled, ash::A11Y_NOTIFICATION_NONE); 406 AccessibilityStatusEventDetails details(
398 content::NotificationService::current()->Notify( 407 ACCESSIBILITY_TOGGLE_LARGE_CURSOR,
399 chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_LARGE_CURSOR, 408 enabled,
400 content::NotificationService::AllSources(), 409 ash::A11Y_NOTIFICATION_NONE);
401 content::Details<AccessibilityStatusEventDetails>(&details)); 410
411 NotifyAccessibilityStatusChanged(details);
402 412
403 #if defined(USE_ASH) 413 #if defined(USE_ASH)
404 // Large cursor is implemented only in ash. 414 // Large cursor is implemented only in ash.
405 ash::Shell::GetInstance()->cursor_manager()->SetCursorSet( 415 ash::Shell::GetInstance()->cursor_manager()->SetCursorSet(
406 enabled ? ui::CURSOR_SET_LARGE : ui::CURSOR_SET_NORMAL); 416 enabled ? ui::CURSOR_SET_LARGE : ui::CURSOR_SET_NORMAL);
407 #endif 417 #endif
408 418
409 #if defined(OS_CHROMEOS) 419 #if defined(OS_CHROMEOS)
410 ash::Shell::GetInstance()->SetCursorCompositingEnabled( 420 ash::Shell::GetInstance()->SetCursorCompositingEnabled(
411 ShouldEnableCursorCompositing()); 421 ShouldEnableCursorCompositing());
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 profile_->GetPrefs()->GetBoolean(prefs::kSpokenFeedbackEnabled); 489 profile_->GetPrefs()->GetBoolean(prefs::kSpokenFeedbackEnabled);
480 490
481 if (spoken_feedback_enabled_ == enabled) 491 if (spoken_feedback_enabled_ == enabled)
482 return; 492 return;
483 493
484 spoken_feedback_enabled_ = enabled; 494 spoken_feedback_enabled_ = enabled;
485 495
486 ExtensionAccessibilityEventRouter::GetInstance()-> 496 ExtensionAccessibilityEventRouter::GetInstance()->
487 SetAccessibilityEnabled(enabled); 497 SetAccessibilityEnabled(enabled);
488 498
489 AccessibilityStatusEventDetails details(enabled, 499 AccessibilityStatusEventDetails details(
490 spoken_feedback_notification_); 500 ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK,
491 content::NotificationService::current()->Notify( 501 enabled,
492 chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK, 502 spoken_feedback_notification_);
493 content::NotificationService::AllSources(), 503
494 content::Details<AccessibilityStatusEventDetails>(&details)); 504 NotifyAccessibilityStatusChanged(details);
495 505
496 if (enabled) { 506 if (enabled) {
497 LoadChromeVox(); 507 LoadChromeVox();
498 } else { 508 } else {
499 UnloadChromeVox(); 509 UnloadChromeVox();
500 } 510 }
501 } 511 }
502 512
503 void AccessibilityManager::LoadChromeVox() { 513 void AccessibilityManager::LoadChromeVox() {
504 ScreenLocker* screen_locker = ScreenLocker::default_screen_locker(); 514 ScreenLocker* screen_locker = ScreenLocker::default_screen_locker();
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 return; 604 return;
595 605
596 const bool enabled = 606 const bool enabled =
597 profile_->GetPrefs()->GetBoolean(prefs::kHighContrastEnabled); 607 profile_->GetPrefs()->GetBoolean(prefs::kHighContrastEnabled);
598 608
599 if (high_contrast_enabled_ == enabled) 609 if (high_contrast_enabled_ == enabled)
600 return; 610 return;
601 611
602 high_contrast_enabled_ = enabled; 612 high_contrast_enabled_ = enabled;
603 613
604 AccessibilityStatusEventDetails detail(enabled, ash::A11Y_NOTIFICATION_NONE); 614 AccessibilityStatusEventDetails details(
605 content::NotificationService::current()->Notify( 615 ACCESSIBILITY_TOGGLE_HIGH_CONTRAST_MODE,
606 chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_HIGH_CONTRAST_MODE, 616 enabled,
607 content::NotificationService::AllSources(), 617 ash::A11Y_NOTIFICATION_NONE);
608 content::Details<AccessibilityStatusEventDetails>(&detail)); 618
619 NotifyAccessibilityStatusChanged(details);
609 620
610 #if defined(USE_ASH) 621 #if defined(USE_ASH)
611 ash::Shell::GetInstance()->high_contrast_controller()->SetEnabled(enabled); 622 ash::Shell::GetInstance()->high_contrast_controller()->SetEnabled(enabled);
612 #endif 623 #endif
613 624
614 #if defined(OS_CHROMEOS) 625 #if defined(OS_CHROMEOS)
615 ash::Shell::GetInstance()->SetCursorCompositingEnabled( 626 ash::Shell::GetInstance()->SetCursorCompositingEnabled(
616 ShouldEnableCursorCompositing()); 627 ShouldEnableCursorCompositing());
617 #endif 628 #endif
618 } 629 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 if (!profile_) 716 if (!profile_)
706 return; 717 return;
707 718
708 const bool enabled = 719 const bool enabled =
709 profile_->GetPrefs()->GetBoolean(prefs::kVirtualKeyboardEnabled); 720 profile_->GetPrefs()->GetBoolean(prefs::kVirtualKeyboardEnabled);
710 721
711 if (virtual_keyboard_enabled_ == enabled) 722 if (virtual_keyboard_enabled_ == enabled)
712 return; 723 return;
713 virtual_keyboard_enabled_ = enabled; 724 virtual_keyboard_enabled_ = enabled;
714 725
715 AccessibilityStatusEventDetails detail(enabled, ash::A11Y_NOTIFICATION_NONE); 726 AccessibilityStatusEventDetails details(
716 content::NotificationService::current()->Notify( 727 ACCESSIBILITY_TOGGLE_VIRTUAL_KEYBOARD,
717 chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_VIRTUAL_KEYBOARD, 728 enabled,
718 content::NotificationService::AllSources(), 729 ash::A11Y_NOTIFICATION_NONE);
719 content::Details<AccessibilityStatusEventDetails>(&detail)); 730
731 NotifyAccessibilityStatusChanged(details);
720 732
721 #if defined(USE_ASH) 733 #if defined(USE_ASH)
722 keyboard::SetAccessibilityKeyboardEnabled(enabled); 734 keyboard::SetAccessibilityKeyboardEnabled(enabled);
723 if (enabled) 735 if (enabled)
724 ash::Shell::GetInstance()->CreateKeyboard(); 736 ash::Shell::GetInstance()->CreateKeyboard();
725 else if (!keyboard::IsKeyboardEnabled()) 737 else if (!keyboard::IsKeyboardEnabled())
726 ash::Shell::GetInstance()->DeactivateKeyboard(); 738 ash::Shell::GetInstance()->DeactivateKeyboard();
727 #endif 739 #endif
728 } 740 }
729 741
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 system_sounds_enabled_ = false; 847 system_sounds_enabled_ = false;
836 if (!ash::PlaySystemSoundIfSpokenFeedback(SOUND_SHUTDOWN)) 848 if (!ash::PlaySystemSoundIfSpokenFeedback(SOUND_SHUTDOWN))
837 return base::TimeDelta(); 849 return base::TimeDelta();
838 return media::SoundsManager::Get()->GetDuration(SOUND_SHUTDOWN); 850 return media::SoundsManager::Get()->GetDuration(SOUND_SHUTDOWN);
839 } 851 }
840 852
841 void AccessibilityManager::InjectChromeVox(RenderViewHost* render_view_host) { 853 void AccessibilityManager::InjectChromeVox(RenderViewHost* render_view_host) {
842 LoadChromeVoxExtension(profile_, render_view_host); 854 LoadChromeVoxExtension(profile_, render_view_host);
843 } 855 }
844 856
857 scoped_ptr<AccessibilityStatusSubscription>
858 AccessibilityManager::RegisterCallback(
859 const AccessibilityStatusCallback& cb) {
860 return callback_list_.Add(cb);
861 }
862
863 void AccessibilityManager::NotifyAccessibilityStatusChanged(
864 AccessibilityStatusEventDetails& details) {
865 callback_list_.Notify(details);
866 }
867
845 void AccessibilityManager::UpdateChromeOSAccessibilityHistograms() { 868 void AccessibilityManager::UpdateChromeOSAccessibilityHistograms() {
846 UMA_HISTOGRAM_BOOLEAN("Accessibility.CrosSpokenFeedback", 869 UMA_HISTOGRAM_BOOLEAN("Accessibility.CrosSpokenFeedback",
847 IsSpokenFeedbackEnabled()); 870 IsSpokenFeedbackEnabled());
848 UMA_HISTOGRAM_BOOLEAN("Accessibility.CrosHighContrast", 871 UMA_HISTOGRAM_BOOLEAN("Accessibility.CrosHighContrast",
849 IsHighContrastEnabled()); 872 IsHighContrastEnabled());
850 UMA_HISTOGRAM_BOOLEAN("Accessibility.CrosVirtualKeyboard", 873 UMA_HISTOGRAM_BOOLEAN("Accessibility.CrosVirtualKeyboard",
851 IsVirtualKeyboardEnabled()); 874 IsVirtualKeyboardEnabled());
852 UMA_HISTOGRAM_BOOLEAN("Accessibility.CrosStickyKeys", IsStickyKeysEnabled()); 875 UMA_HISTOGRAM_BOOLEAN("Accessibility.CrosStickyKeys", IsStickyKeysEnabled());
853 if (MagnificationManager::Get()) { 876 if (MagnificationManager::Get()) {
854 uint32 type = MagnificationManager::Get()->IsMagnifierEnabled() ? 877 uint32 type = MagnificationManager::Get()->IsMagnifierEnabled() ?
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
958 chrome_vox_loaded_on_lock_screen_; 981 chrome_vox_loaded_on_lock_screen_;
959 } 982 }
960 983
961 void AccessibilityManager::PostUnloadChromeVox(Profile* profile) { 984 void AccessibilityManager::PostUnloadChromeVox(Profile* profile) {
962 // Do any teardown work needed immediately after ChromeVox actually unloads. 985 // Do any teardown work needed immediately after ChromeVox actually unloads.
963 if (system_sounds_enabled_) 986 if (system_sounds_enabled_)
964 ash::PlaySystemSoundAlways(SOUND_SPOKEN_FEEDBACK_DISABLED); 987 ash::PlaySystemSoundAlways(SOUND_SPOKEN_FEEDBACK_DISABLED);
965 } 988 }
966 989
967 } // namespace chromeos 990 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698