Commit 54d1dce5 authored by dtseng@chromium.org's avatar dtseng@chromium.org

Track all profiles ChromeVox loads to.

- keeps track of all profile event routers ChromeVox registers observers on.
- ensures AccessibilityManager unregisters observers on all profile event routers when Shutdown occurs.
- always plays startup/shutdown sounds regardless of system preference. (This is the only accessible notification that ChromeVox has started/shutdown when toggling).

BUG=323030,322793
TEST=Manual.

Review URL: https://codereview.chromium.org/123443002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243249 0039d316-1c4b-4281-b951-d872f2087c98
parent 04bf8703
...@@ -343,8 +343,10 @@ AccessibilityManager::~AccessibilityManager() { ...@@ -343,8 +343,10 @@ AccessibilityManager::~AccessibilityManager() {
// Component extensions don't always notify us when they're unloaded. Ensure // Component extensions don't always notify us when they're unloaded. Ensure
// we clean up ChromeVox observers here. // we clean up ChromeVox observers here.
if (profile_) { for (std::set<Profile*>::iterator it = chromevox_profiles_.begin();
extensions::ExtensionSystem::Get(profile_)-> it != chromevox_profiles_.end();
it++) {
extensions::ExtensionSystem::Get(*it)->
event_router()->UnregisterObserver(this); event_router()->UnregisterObserver(this);
} }
} }
...@@ -742,11 +744,6 @@ void AccessibilityManager::SetProfile(Profile* profile) { ...@@ -742,11 +744,6 @@ void AccessibilityManager::SetProfile(Profile* profile) {
autoclick_pref_handler_.HandleProfileChanged(profile_, profile); autoclick_pref_handler_.HandleProfileChanged(profile_, profile);
autoclick_delay_pref_handler_.HandleProfileChanged(profile_, profile); autoclick_delay_pref_handler_.HandleProfileChanged(profile_, profile);
if (!profile && profile_) {
extensions::ExtensionSystem::Get(profile_)->
event_router()->UnregisterObserver(this);
}
if (profile && spoken_feedback_enabled_) if (profile && spoken_feedback_enabled_)
SetUpPreLoadChromeVox(profile); SetUpPreLoadChromeVox(profile);
...@@ -856,6 +853,9 @@ void AccessibilityManager::Observe( ...@@ -856,6 +853,9 @@ void AccessibilityManager::Observe(
Profile* profile = content::Source<Profile>(source).ptr(); Profile* profile = content::Source<Profile>(source).ptr();
if (profile_ == profile) if (profile_ == profile)
SetProfile(NULL); SetProfile(NULL);
if (IsSpokenFeedbackEnabled())
TearDownPostUnloadChromeVox(profile);
break; break;
} }
case chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED: { case chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED: {
...@@ -944,6 +944,7 @@ void AccessibilityManager::SetUpPreLoadChromeVox(Profile* profile) { ...@@ -944,6 +944,7 @@ void AccessibilityManager::SetUpPreLoadChromeVox(Profile* profile) {
event_router()->RegisterObserver(this, event_router()->RegisterObserver(this,
extensions::api::experimental_accessibility:: extensions::api::experimental_accessibility::
OnChromeVoxLoadStateChanged::kEventName); OnChromeVoxLoadStateChanged::kEventName);
chromevox_profiles_.insert(profile);
} }
} }
...@@ -952,12 +953,12 @@ void AccessibilityManager::TearDownPostUnloadChromeVox(Profile* profile) { ...@@ -952,12 +953,12 @@ void AccessibilityManager::TearDownPostUnloadChromeVox(Profile* profile) {
if (profile) { if (profile) {
extensions::ExtensionSystem::Get(profile)-> extensions::ExtensionSystem::Get(profile)->
event_router()->UnregisterObserver(this); event_router()->UnregisterObserver(this);
chromevox_profiles_.erase(profile);
} }
} }
void AccessibilityManager::PlaySound(int sound_key) const { void AccessibilityManager::PlaySound(int sound_key) const {
if (system_sounds_enabled_) media::SoundsManager::Get()->Play(sound_key);
media::SoundsManager::Get()->Play(sound_key);
} }
} // namespace chromeos } // namespace chromeos
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#ifndef CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_ACCESSIBILITY_MANAGER_H_ #ifndef CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_ACCESSIBILITY_MANAGER_H_
#define CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_ACCESSIBILITY_MANAGER_H_ #define CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_ACCESSIBILITY_MANAGER_H_
#include <set>
#include "ash/accessibility_delegate.h" #include "ash/accessibility_delegate.h"
#include "ash/session_state_observer.h" #include "ash/session_state_observer.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
...@@ -176,10 +178,9 @@ class AccessibilityManager : public content::NotificationObserver, ...@@ -176,10 +178,9 @@ class AccessibilityManager : public content::NotificationObserver,
virtual void OnListenerRemoved( virtual void OnListenerRemoved(
const extensions::EventListenerInfo& details) OVERRIDE; const extensions::EventListenerInfo& details) OVERRIDE;
// Plays sound identified by |sound_key| if |system_sounds_enabled_|. // Plays sound identified by |sound_key|. |sound_key| must be an ID for sound
// |sound_key| must be an ID for sound registered by // registered by AccessibilityManager. If there is no such sound, sound isn't
// AccessibilityManager. If there is no such sound or // played.
// !|system_sounds_enabled_|, sound isn't played.
void PlaySound(int sound_key) const; void PlaySound(int sound_key) const;
// Profile which has the current a11y context. // Profile which has the current a11y context.
...@@ -190,6 +191,9 @@ class AccessibilityManager : public content::NotificationObserver, ...@@ -190,6 +191,9 @@ class AccessibilityManager : public content::NotificationObserver,
bool chrome_vox_loaded_on_lock_screen_; bool chrome_vox_loaded_on_lock_screen_;
bool chrome_vox_loaded_on_user_screen_; bool chrome_vox_loaded_on_user_screen_;
// Set of profiles ChromeVox is loaded to.
std::set<Profile*> chromevox_profiles_;
content::NotificationRegistrar notification_registrar_; content::NotificationRegistrar notification_registrar_;
scoped_ptr<PrefChangeRegistrar> pref_change_registrar_; scoped_ptr<PrefChangeRegistrar> pref_change_registrar_;
scoped_ptr<PrefChangeRegistrar> local_state_pref_change_registrar_; scoped_ptr<PrefChangeRegistrar> local_state_pref_change_registrar_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment