| 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 54c37516bd8542d473636b74df43f88f433965d7..c03ddf44d194619a38a5dc4e5c57d6842db9b93b 100644
|
| --- a/chrome/browser/chromeos/accessibility/accessibility_manager.cc
|
| +++ b/chrome/browser/chromeos/accessibility/accessibility_manager.cc
|
| @@ -7,6 +7,7 @@
|
| #include "ash/autoclick/autoclick_controller.h"
|
| #include "ash/high_contrast/high_contrast_controller.h"
|
| #include "ash/metrics/user_metrics_recorder.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"
|
| @@ -207,6 +208,20 @@ void UnloadChromeVoxExtension(Profile* profile) {
|
| } // namespace
|
|
|
| ///////////////////////////////////////////////////////////////////////////////
|
| +// ScopedSessionStateObserver
|
| +
|
| +ScopedSessionStateObserver::ScopedSessionStateObserver(
|
| + ash::SessionStateObserver* observer) : observer_(observer) {
|
| + ash::Shell::GetInstance()->session_state_delegate()->
|
| + AddSessionStateObserver(observer_);
|
| +}
|
| +
|
| +ScopedSessionStateObserver::~ScopedSessionStateObserver() {
|
| + ash::Shell::GetInstance()->session_state_delegate()->
|
| + RemoveSessionStateObserver(observer_);
|
| +}
|
| +
|
| +///////////////////////////////////////////////////////////////////////////////
|
| // AccessibilityStatusEventDetails
|
|
|
| AccessibilityStatusEventDetails::AccessibilityStatusEventDetails(
|
| @@ -322,6 +337,7 @@ AccessibilityManager::AccessibilityManager()
|
| notification_registrar_.Add(this,
|
| chrome::NOTIFICATION_EXTENSION_UNLOADED,
|
| content::NotificationService::AllSources());
|
| +
|
| GetBrailleController()->AddObserver(this);
|
|
|
| ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
|
| @@ -347,6 +363,27 @@ AccessibilityManager::~AccessibilityManager() {
|
| }
|
| }
|
|
|
| +bool AccessibilityManager::ShouldShowAccessibilityMenu() {
|
| + // If any of the loaded profiles has an accessibility feature turned on - or
|
| + // enforced to always show the menu - we 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) {
|
| if (!profile_)
|
| return;
|
| @@ -739,6 +776,10 @@ void AccessibilityManager::SetProfile(Profile* profile) {
|
| UpdateAutoclickDelayFromPref();
|
| }
|
|
|
| +void AccessibilityManager::ActiveUserChanged(const std::string& user_id) {
|
| + SetProfile(ProfileManager::GetActiveUserProfile());
|
| +}
|
| +
|
| void AccessibilityManager::SetProfileForTest(Profile* profile) {
|
| SetProfile(profile);
|
| }
|
| @@ -807,17 +848,21 @@ 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_.get() && ash::Shell::HasInstance())
|
| + session_state_observer_.reset(new ScopedSessionStateObserver(this));
|
| break;
|
| case chrome::NOTIFICATION_PROFILE_DESTROYED: {
|
| // Update |profile_| when exiting a session or shutting down.
|
|
|