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..e43c9cff24dbdd1467a02745fc76b2b50bd1c68b 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,9 @@ AccessibilityManager::AccessibilityManager() |
notification_registrar_.Add(this, |
chrome::NOTIFICATION_EXTENSION_UNLOADED, |
content::NotificationService::AllSources()); |
+ |
+ // Sent when a chromium os user logs in. |
+ // The details are a chromeos::User object. |
Peter Lundblad
2013/12/12 20:53:00
Misplaced comment?
Mr4D (OOO till 08-26)
2013/12/12 21:01:31
In deed. Done.
|
GetBrailleController()->AddObserver(this); |
ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
@@ -334,6 +339,31 @@ AccessibilityManager::~AccessibilityManager() { |
extensions::ExtensionSystem::Get(profile_)-> |
event_router()->UnregisterObserver(this); |
} |
+ |
+ if (session_state_observer_installed_) |
+ ash::Shell::GetInstance()->session_state_delegate()-> |
+ RemoveSessionStateObserver(this); |
+} |
+ |
+bool AccessibilityManager::ShouldShowAccessibilityMenu() { |
+ // If any of the loaded profiles has an accessibility feature turned on, we |
+ // should return true to show the menu. |
+ std::vector<Profile*> list = |
Peter Lundblad
2013/12/12 20:53:00
nit: slightly confusing to call a vector a list:-)
Mr4D (OOO till 08-26)
2013/12/12 21:01:31
Done.
|
+ g_browser_process->profile_manager()->GetLoadedProfiles(); |
+ for (std::vector<Profile*>::iterator it = list.begin(); |
+ it != list.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 +754,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); |
} |
@@ -792,17 +826,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. |