Chromium Code Reviews| Index: chrome/browser/chromeos/accessibility/accessibility_manager.cc |
| diff --git a/chrome/browser/chromeos/accessibility/accessibility_manager.cc b/chrome/browser/chromeos/accessibility/accessibility_manager.cc |
| index b981919f6f7e07256621da6bf59ac452b2b8fc2b..c27092c1700941c3e30893d103eb715a12641c34 100644 |
| --- a/chrome/browser/chromeos/accessibility/accessibility_manager.cc |
| +++ b/chrome/browser/chromeos/accessibility/accessibility_manager.cc |
| @@ -6,6 +6,7 @@ |
| #include "ash/autoclick/autoclick_controller.h" |
| #include "ash/high_contrast/high_contrast_controller.h" |
| +#include "ash/session_state_delegate.h" |
| #include "ash/shell.h" |
| #include "ash/system/tray/system_tray_notifier.h" |
| #include "ash/wm/event_rewriter_event_filter.h" |
| @@ -292,6 +293,7 @@ AccessibilityManager::AccessibilityManager() |
| spoken_feedback_notification_(ash::A11Y_NOTIFICATION_NONE), |
| weak_ptr_factory_(this), |
| should_speak_chrome_vox_announcements_on_user_screen_(true), |
| + session_state_observer_installed_(false), |
| system_sounds_enabled_(false) { |
| notification_registrar_.Add(this, |
| chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, |
| @@ -311,6 +313,7 @@ AccessibilityManager::AccessibilityManager() |
| notification_registrar_.Add(this, |
| chrome::NOTIFICATION_EXTENSION_UNLOADED, |
| content::NotificationService::AllSources()); |
| + |
| GetBrailleController()->AddObserver(this); |
| ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
| @@ -334,6 +337,31 @@ AccessibilityManager::~AccessibilityManager() { |
| extensions::ExtensionSystem::Get(profile_)-> |
| event_router()->UnregisterObserver(this); |
| } |
| + |
| + if (session_state_observer_installed_) |
| + ash::Shell::GetInstance()->session_state_delegate()-> |
| + RemoveSessionStateObserver(this); |
|
dmazzoni
2013/12/13 16:15:07
I think we should have a ScopedSessionStateObserve
Mr4D (OOO till 08-26)
2013/12/13 17:21:13
Done.
|
| +} |
| + |
| +bool AccessibilityManager::ShouldShowAccessibilityMenu() { |
| + // If any of the loaded profiles has an accessibility feature turned on, we |
|
dmazzoni
2013/12/13 16:15:07
If they have an accessibility feature turned on, *
Mr4D (OOO till 08-26)
2013/12/13 17:21:13
Done.
|
| + // should return true to show the menu. |
| + std::vector<Profile*> profiles = |
| + g_browser_process->profile_manager()->GetLoadedProfiles(); |
| + for (std::vector<Profile*>::iterator it = profiles.begin(); |
| + it != profiles.end(); |
| + ++it) { |
| + PrefService* pref_service = (*it)->GetPrefs(); |
| + if (pref_service->GetBoolean(prefs::kStickyKeysEnabled) || |
| + pref_service->GetBoolean(prefs::kLargeCursorEnabled) || |
| + pref_service->GetBoolean(prefs::kSpokenFeedbackEnabled) || |
| + pref_service->GetBoolean(prefs::kHighContrastEnabled) || |
| + pref_service->GetBoolean(prefs::kAutoclickEnabled) || |
| + pref_service->GetBoolean(prefs::kShouldAlwaysShowAccessibilityMenu) || |
| + pref_service->GetBoolean(prefs::kScreenMagnifierEnabled)) |
| + return true; |
| + } |
| + return false; |
| } |
| void AccessibilityManager::EnableLargeCursor(bool enabled) { |
| @@ -724,6 +752,10 @@ void AccessibilityManager::SetProfile(Profile* profile) { |
| UpdateAutoclickDelayFromPref(); |
| } |
| +void AccessibilityManager::ActiveUserChanged(const std::string& user_id) { |
| + SetProfile(ProfileManager::GetActiveUserProfile()); |
|
dmazzoni
2013/12/13 16:15:07
Does this need to take login / lock screen into ac
Mr4D (OOO till 08-26)
2013/12/13 17:21:13
This only gets called when a user switches activel
|
| +} |
| + |
| void AccessibilityManager::SetProfileForTest(Profile* profile) { |
| SetProfile(profile); |
| } |
| @@ -792,17 +824,24 @@ void AccessibilityManager::Observe( |
| switch (type) { |
| case chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE: { |
| // Update |profile_| when entering the login screen. |
| - Profile* profile = ProfileManager::GetDefaultProfile(); |
| + Profile* profile = ProfileManager::GetActiveUserProfile(); |
| if (ProfileHelper::IsSigninProfile(profile)) |
| SetProfile(profile); |
| break; |
| } |
| case chrome::NOTIFICATION_SESSION_STARTED: |
| // Update |profile_| when entering a session. |
| - SetProfile(ProfileManager::GetDefaultProfile()); |
| + SetProfile(ProfileManager::GetActiveUserProfile()); |
| // Ensure ChromeVox makes announcements at the start of new sessions. |
| should_speak_chrome_vox_announcements_on_user_screen_ = true; |
| + |
| + // Add a session state observer to be able to monitor session changes. |
| + if (!session_state_observer_installed_ && ash::Shell::HasInstance()) { |
| + session_state_observer_installed_ = true; |
| + ash::Shell::GetInstance()->session_state_delegate()-> |
| + AddSessionStateObserver(this); |
| + } |
| break; |
| case chrome::NOTIFICATION_PROFILE_DESTROYED: { |
| // Update |profile_| when exiting a session or shutting down. |