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

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

Issue 213233003: Show a notification when a braille display is connected. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Style and const correctness fixes. Created 6 years, 9 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
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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 large_cursor_enabled_(false), 301 large_cursor_enabled_(false),
302 sticky_keys_enabled_(false), 302 sticky_keys_enabled_(false),
303 spoken_feedback_enabled_(false), 303 spoken_feedback_enabled_(false),
304 high_contrast_enabled_(false), 304 high_contrast_enabled_(false),
305 autoclick_enabled_(false), 305 autoclick_enabled_(false),
306 autoclick_delay_ms_(ash::AutoclickController::kDefaultAutoclickDelayMs), 306 autoclick_delay_ms_(ash::AutoclickController::kDefaultAutoclickDelayMs),
307 virtual_keyboard_enabled_(false), 307 virtual_keyboard_enabled_(false),
308 spoken_feedback_notification_(ash::A11Y_NOTIFICATION_NONE), 308 spoken_feedback_notification_(ash::A11Y_NOTIFICATION_NONE),
309 weak_ptr_factory_(this), 309 weak_ptr_factory_(this),
310 should_speak_chrome_vox_announcements_on_user_screen_(true), 310 should_speak_chrome_vox_announcements_on_user_screen_(true),
311 system_sounds_enabled_(false) { 311 system_sounds_enabled_(false),
312 braille_display_connected_(false),
313 scoped_braille_observer_(this) {
312 notification_registrar_.Add(this, 314 notification_registrar_.Add(this,
313 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, 315 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE,
314 content::NotificationService::AllSources()); 316 content::NotificationService::AllSources());
315 notification_registrar_.Add(this, 317 notification_registrar_.Add(this,
316 chrome::NOTIFICATION_SESSION_STARTED, 318 chrome::NOTIFICATION_SESSION_STARTED,
317 content::NotificationService::AllSources()); 319 content::NotificationService::AllSources());
318 notification_registrar_.Add(this, 320 notification_registrar_.Add(this,
319 chrome::NOTIFICATION_PROFILE_DESTROYED, 321 chrome::NOTIFICATION_PROFILE_DESTROYED,
320 content::NotificationService::AllSources()); 322 content::NotificationService::AllSources());
321 notification_registrar_.Add(this, 323 notification_registrar_.Add(this,
322 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, 324 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED,
323 content::NotificationService::AllSources()); 325 content::NotificationService::AllSources());
324 326
325 GetBrailleController()->AddObserver(this);
326
327 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); 327 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
328 media::SoundsManager* manager = media::SoundsManager::Get(); 328 media::SoundsManager* manager = media::SoundsManager::Get();
329 manager->Initialize(SOUND_SHUTDOWN, 329 manager->Initialize(SOUND_SHUTDOWN,
330 bundle.GetRawDataResource(IDR_SOUND_SHUTDOWN_WAV)); 330 bundle.GetRawDataResource(IDR_SOUND_SHUTDOWN_WAV));
331 manager->Initialize( 331 manager->Initialize(
332 SOUND_SPOKEN_FEEDBACK_ENABLED, 332 SOUND_SPOKEN_FEEDBACK_ENABLED,
333 bundle.GetRawDataResource(IDR_SOUND_SPOKEN_FEEDBACK_ENABLED_WAV)); 333 bundle.GetRawDataResource(IDR_SOUND_SPOKEN_FEEDBACK_ENABLED_WAV));
334 manager->Initialize( 334 manager->Initialize(
335 SOUND_SPOKEN_FEEDBACK_DISABLED, 335 SOUND_SPOKEN_FEEDBACK_DISABLED,
336 bundle.GetRawDataResource(IDR_SOUND_SPOKEN_FEEDBACK_DISABLED_WAV)); 336 bundle.GetRawDataResource(IDR_SOUND_SPOKEN_FEEDBACK_DISABLED_WAV));
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 732
733 #if defined(USE_ASH) 733 #if defined(USE_ASH)
734 keyboard::SetAccessibilityKeyboardEnabled(enabled); 734 keyboard::SetAccessibilityKeyboardEnabled(enabled);
735 if (enabled) 735 if (enabled)
736 ash::Shell::GetInstance()->CreateKeyboard(); 736 ash::Shell::GetInstance()->CreateKeyboard();
737 else if (!keyboard::IsKeyboardEnabled()) 737 else if (!keyboard::IsKeyboardEnabled())
738 ash::Shell::GetInstance()->DeactivateKeyboard(); 738 ash::Shell::GetInstance()->DeactivateKeyboard();
739 #endif 739 #endif
740 } 740 }
741 741
742 bool AccessibilityManager::IsBrailleDisplayConnected() const {
743 return braille_display_connected_;
744 }
745
742 void AccessibilityManager::CheckBrailleState() { 746 void AccessibilityManager::CheckBrailleState() {
747 BrailleController* braille_controller = GetBrailleController();
748 if (!scoped_braille_observer_.IsObserving(braille_controller))
749 scoped_braille_observer_.Add(braille_controller);
743 BrowserThread::PostTaskAndReplyWithResult( 750 BrowserThread::PostTaskAndReplyWithResult(
744 BrowserThread::IO, FROM_HERE, base::Bind( 751 BrowserThread::IO,
745 &BrailleController::GetDisplayState, 752 FROM_HERE,
746 base::Unretained(GetBrailleController())), 753 base::Bind(&BrailleController::GetDisplayState,
754 base::Unretained(braille_controller)),
747 base::Bind(&AccessibilityManager::ReceiveBrailleDisplayState, 755 base::Bind(&AccessibilityManager::ReceiveBrailleDisplayState,
748 weak_ptr_factory_.GetWeakPtr())); 756 weak_ptr_factory_.GetWeakPtr()));
749 } 757 }
750 758
751 void AccessibilityManager::ReceiveBrailleDisplayState( 759 void AccessibilityManager::ReceiveBrailleDisplayState(
752 scoped_ptr<extensions::api::braille_display_private::DisplayState> state) { 760 scoped_ptr<extensions::api::braille_display_private::DisplayState> state) {
753 OnDisplayStateChanged(*state); 761 OnDisplayStateChanged(*state);
754 } 762 }
755 763
756 764
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 base::Unretained(this))); 812 base::Unretained(this)));
805 } 813 }
806 814
807 large_cursor_pref_handler_.HandleProfileChanged(profile_, profile); 815 large_cursor_pref_handler_.HandleProfileChanged(profile_, profile);
808 spoken_feedback_pref_handler_.HandleProfileChanged(profile_, profile); 816 spoken_feedback_pref_handler_.HandleProfileChanged(profile_, profile);
809 high_contrast_pref_handler_.HandleProfileChanged(profile_, profile); 817 high_contrast_pref_handler_.HandleProfileChanged(profile_, profile);
810 autoclick_pref_handler_.HandleProfileChanged(profile_, profile); 818 autoclick_pref_handler_.HandleProfileChanged(profile_, profile);
811 autoclick_delay_pref_handler_.HandleProfileChanged(profile_, profile); 819 autoclick_delay_pref_handler_.HandleProfileChanged(profile_, profile);
812 virtual_keyboard_pref_handler_.HandleProfileChanged(profile_, profile); 820 virtual_keyboard_pref_handler_.HandleProfileChanged(profile_, profile);
813 821
814 if (!profile_ && profile) 822 bool had_profile = (profile_ != NULL);
823 profile_ = profile;
824
825 if (!had_profile && profile)
815 CheckBrailleState(); 826 CheckBrailleState();
816 827
817 profile_ = profile;
818 UpdateLargeCursorFromPref(); 828 UpdateLargeCursorFromPref();
819 UpdateStickyKeysFromPref(); 829 UpdateStickyKeysFromPref();
820 UpdateSpokenFeedbackFromPref(); 830 UpdateSpokenFeedbackFromPref();
821 UpdateHighContrastFromPref(); 831 UpdateHighContrastFromPref();
822 UpdateAutoclickFromPref(); 832 UpdateAutoclickFromPref();
823 UpdateAutoclickDelayFromPref(); 833 UpdateAutoclickDelayFromPref();
824 UpdateVirtualKeyboardFromPref(); 834 UpdateVirtualKeyboardFromPref();
825 } 835 }
826 836
827 void AccessibilityManager::ActiveUserChanged(const std::string& user_id) { 837 void AccessibilityManager::ActiveUserChanged(const std::string& user_id) {
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
955 LoadChromeVoxToUserScreen(); 965 LoadChromeVoxToUserScreen();
956 } 966 }
957 } 967 }
958 break; 968 break;
959 } 969 }
960 } 970 }
961 } 971 }
962 972
963 void AccessibilityManager::OnDisplayStateChanged( 973 void AccessibilityManager::OnDisplayStateChanged(
964 const DisplayState& display_state) { 974 const DisplayState& display_state) {
965 if (display_state.available) 975 braille_display_connected_ = display_state.available;
976 if (braille_display_connected_)
966 EnableSpokenFeedback(true, ash::A11Y_NOTIFICATION_SHOW); 977 EnableSpokenFeedback(true, ash::A11Y_NOTIFICATION_SHOW);
978
979 AccessibilityStatusEventDetails details(
980 ACCESSIBILITY_BRAILLE_DISPLAY_CONNECTION_STATE_CHANGED,
981 braille_display_connected_,
982 ash::A11Y_NOTIFICATION_SHOW);
983 NotifyAccessibilityStatusChanged(details);
967 } 984 }
968 985
969 void AccessibilityManager::PostLoadChromeVox(Profile* profile) { 986 void AccessibilityManager::PostLoadChromeVox(Profile* profile) {
970 // Do any setup work needed immediately after ChromeVox actually loads. 987 // Do any setup work needed immediately after ChromeVox actually loads.
971 if (system_sounds_enabled_) 988 if (system_sounds_enabled_)
972 ash::PlaySystemSoundAlways(SOUND_SPOKEN_FEEDBACK_ENABLED); 989 ash::PlaySystemSoundAlways(SOUND_SPOKEN_FEEDBACK_ENABLED);
973 990
974 ExtensionAccessibilityEventRouter::GetInstance()-> 991 ExtensionAccessibilityEventRouter::GetInstance()->
975 OnChromeVoxLoadStateChanged(profile_, 992 OnChromeVoxLoadStateChanged(profile_,
976 IsSpokenFeedbackEnabled(), 993 IsSpokenFeedbackEnabled(),
977 chrome_vox_loaded_on_lock_screen_ || 994 chrome_vox_loaded_on_lock_screen_ ||
978 should_speak_chrome_vox_announcements_on_user_screen_); 995 should_speak_chrome_vox_announcements_on_user_screen_);
979 996
980 should_speak_chrome_vox_announcements_on_user_screen_ = 997 should_speak_chrome_vox_announcements_on_user_screen_ =
981 chrome_vox_loaded_on_lock_screen_; 998 chrome_vox_loaded_on_lock_screen_;
982 } 999 }
983 1000
984 void AccessibilityManager::PostUnloadChromeVox(Profile* profile) { 1001 void AccessibilityManager::PostUnloadChromeVox(Profile* profile) {
985 // Do any teardown work needed immediately after ChromeVox actually unloads. 1002 // Do any teardown work needed immediately after ChromeVox actually unloads.
986 if (system_sounds_enabled_) 1003 if (system_sounds_enabled_)
987 ash::PlaySystemSoundAlways(SOUND_SPOKEN_FEEDBACK_DISABLED); 1004 ash::PlaySystemSoundAlways(SOUND_SPOKEN_FEEDBACK_DISABLED);
988 } 1005 }
989 1006
990 } // namespace chromeos 1007 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698