Commit 0e9504da authored by dtseng@chromium.org's avatar dtseng@chromium.org

Adjust ChromeVox (spoken feedback) strings and make it possible for announcemen

ts to occur directly in the extension.

BUG=261451
TEST=On Aura, rapidly turn ChromeVox on and off (on login/locked screen, user s
creens). Verify behaviors in above bug are true. Depends on a ChromeVox change.

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@232886 0039d316-1c4b-4281-b951-d872f2087c98
parent 10208cee
......@@ -321,7 +321,7 @@ Press any key to continue exploring.
Accessibility
</message>
<message name="IDS_OOBE_SPOKEN_FEEDBACK_OPTION" desc="Spoken feedback option shown on OOBE screens accessibility menu.">
Spoken feedback
ChromeVox (spoken feedback)
</message>
<message name="IDS_OOBE_LARGE_CURSOR_OPTION" desc="Large mouse cursor option shown on OOBE screens accessibility menu.">
Large mouse cursor
......@@ -937,7 +937,7 @@ Press any key to continue exploring.
Show large mouse cursor
</message>
<message name="IDS_OPTIONS_SETTINGS_ACCESSIBILITY_SPOKEN_FEEDBACK_DESCRIPTION" desc="In the settings tab, the text next to the checkbox for spoken feedback.">
Enable spoken feedback
Enable ChromeVox (spoken feedback)
</message>
<message name="IDS_OPTIONS_SETTINGS_ACCESSIBILITY_HIGH_CONTRAST_DESCRIPTION" desc="In the settings tab, the text next to the checkbox for high contrast mode.">
Use high contrast mode
......@@ -2406,10 +2406,10 @@ Press any key to continue exploring.
Mouse
</message>
<message name="IDS_STATUSBAR_SPOKEN_FEEDBACK_ENABLED" desc="The tooltip for the status bar button to indicate that spoken feedback has been enabled.">
Spoken feedback is enabled.
ChromeVox (spoken feedback) is enabled. Press Ctrl+Alt+Z to disable.
</message>
<message name="IDS_STATUSBAR_DISABLE_SPOKEN_FEEDBACK" desc="The menu option to disable spoken feedback accessibility feature.">
Disable spoken feedback
Disable ChromeVox (spoken feedback)
</message>
<message name="IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET" desc="The ethernet network device.">
Ethernet
......@@ -2672,12 +2672,6 @@ Battery full
<message name="IDS_CHROMEOS_ACC_TEXT_UNSELECTED" desc="A phrase to indicate to the user that text has been unselected.">
Unselected
</message>
<message name="IDS_CHROMEOS_ACC_SPOKEN_FEEDBACK_ENABLED" desc="A phrase to speak when spoken feedback is enabled.">
Enabling spoken feedback.
</message>
<message name="IDS_CHROMEOS_ACC_SPOKEN_FEEDBACK_DISABLED" desc="A phrase to speak when spoken feedback is disabled.">
Disabling spoken feedback.
</message>
<message name="IDS_CHROMEOS_ACC_USERNAME_LABEL" desc="Label for the username text field.">
Username.
</message>
......@@ -3274,7 +3268,7 @@ Battery full
Toggle speech input
</message>
<message name="IDS_KEYBOARD_OVERLAY_TOGGLE_SPOKEN_FEEDBACK" desc="The text in the keyboard overlay to explain the shortcut (enable or disable spoken feedback).">
Toggle spoken feedback
Toggle ChromeVox (spoken feedback)
</message>
<message name="IDS_KEYBOARD_OVERLAY_UNDO" desc="The text in the keyboard overlay to explain the shortcut.">
Undo
......
......@@ -10,6 +10,8 @@
#include "chrome/browser/accessibility/accessibility_extension_api_constants.h"
#include "chrome/browser/extensions/api/tabs/tabs_constants.h"
#include "chrome/browser/extensions/event_router.h"
#include "chrome/browser/extensions/extension_host.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/extensions/extension_tab_util.h"
#include "chrome/browser/infobars/confirm_infobar_delegate.h"
......@@ -17,7 +19,9 @@
#include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/extensions/api/experimental_accessibility.h"
#include "chrome/common/extensions/background_info.h"
#include "content/public/browser/browser_accessibility_state.h"
#include "extensions/browser/lazy_background_task_queue.h"
#include "extensions/common/error_utils.h"
namespace keys = extension_accessibility_api_constants;
......@@ -164,6 +168,33 @@ void ExtensionAccessibilityEventRouter::OnMenuClosed(
args.Pass());
}
void ExtensionAccessibilityEventRouter::OnChromeVoxLoadStateChanged(
Profile* profile,
bool loading,
bool make_announcements) {
scoped_ptr<base::ListValue> event_args(new base::ListValue());
event_args->Append(base::Value::CreateBooleanValue(loading));
event_args->Append(base::Value::CreateBooleanValue(make_announcements));
ExtensionAccessibilityEventRouter::DispatchEventToChromeVox(profile,
experimental_accessibility::OnChromeVoxLoadStateChanged::kEventName,
event_args.Pass());
}
// Static.
void ExtensionAccessibilityEventRouter::DispatchEventToChromeVox(
Profile* profile,
const char* event_name,
scoped_ptr<base::ListValue> event_args) {
extensions::ExtensionSystem* system =
extensions::ExtensionSystem::Get(profile);
if (!system)
return;
scoped_ptr<extensions::Event> event(new extensions::Event(event_name,
event_args.Pass()));
system->event_router()->DispatchEventToExtension(
extension_misc::kChromeVoxExtensionId, event.Pass());
}
void ExtensionAccessibilityEventRouter::DispatchEvent(
Profile* profile,
const char* event_name,
......
......@@ -14,6 +14,10 @@
#include "chrome/browser/extensions/chrome_extension_function.h"
#include "ui/base/accessibility/accessibility_types.h"
namespace extensions {
class ExtensionHost;
} // namespace extensions
// Observes the profile and routes accessibility notifications as events
// to the extension system.
class ExtensionAccessibilityEventRouter {
......@@ -54,6 +58,16 @@ class ExtensionAccessibilityEventRouter {
void HandleControlEvent(ui::AccessibilityTypes::Event event,
const AccessibilityControlInfo* info);
void OnChromeVoxLoadStateChanged(
Profile* profile,
bool loading,
bool make_announcements);
static void DispatchEventToChromeVox(
Profile* profile,
const char* event_name,
scoped_ptr<base::ListValue> event_args);
private:
friend struct DefaultSingletonTraits<ExtensionAccessibilityEventRouter>;
......
......@@ -32,6 +32,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/speech/tts_controller.h"
#include "chrome/common/extensions/api/experimental_accessibility.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_messages.h"
#include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h"
......@@ -287,8 +288,8 @@ AccessibilityManager::AccessibilityManager()
high_contrast_enabled_(false),
autoclick_delay_ms_(ash::AutoclickController::kDefaultAutoclickDelayMs),
spoken_feedback_notification_(ash::A11Y_NOTIFICATION_NONE),
weak_ptr_factory_(this) {
weak_ptr_factory_(this),
should_speak_chrome_vox_announcements_on_user_screen_(true) {
notification_registrar_.Add(this,
chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE,
content::NotificationService::AllSources());
......@@ -409,10 +410,6 @@ void AccessibilityManager::UpdateSpokenFeedbackFromPref() {
spoken_feedback_enabled_ = enabled;
Speak(l10n_util::GetStringUTF8(
enabled ? IDS_CHROMEOS_ACC_SPOKEN_FEEDBACK_ENABLED :
IDS_CHROMEOS_ACC_SPOKEN_FEEDBACK_DISABLED).c_str());
ExtensionAccessibilityEventRouter::GetInstance()->
SetAccessibilityEnabled(enabled);
......@@ -423,10 +420,20 @@ void AccessibilityManager::UpdateSpokenFeedbackFromPref() {
content::NotificationService::AllSources(),
content::Details<AccessibilityStatusEventDetails>(&details));
if (enabled)
if (enabled) {
LoadChromeVox();
else
UnloadChromeVox();
ExtensionAccessibilityEventRouter::GetInstance()->
OnChromeVoxLoadStateChanged(profile_,
true,
chrome_vox_loaded_on_lock_screen_ ||
should_speak_chrome_vox_announcements_on_user_screen_);
should_speak_chrome_vox_announcements_on_user_screen_ =
chrome_vox_loaded_on_lock_screen_;
} else {
ExtensionAccessibilityEventRouter::GetInstance()->
OnChromeVoxLoadStateChanged(profile_, false, false);
}
}
void AccessibilityManager::LoadChromeVox() {
......@@ -686,6 +693,10 @@ void AccessibilityManager::SetProfile(Profile* profile) {
base::Bind(
&AccessibilityManager::UpdateChromeOSAccessibilityHistograms,
base::Unretained(this)));
extensions::ExtensionSystem::Get(profile)->event_router()->RegisterObserver(
this, extensions::api::experimental_accessibility::
OnChromeVoxLoadStateChanged::kEventName);
}
large_cursor_pref_handler_.HandleProfileChanged(profile_, profile);
......@@ -769,6 +780,9 @@ void AccessibilityManager::Observe(
case chrome::NOTIFICATION_SESSION_STARTED:
// Update |profile_| when entering a session.
SetProfile(ProfileManager::GetDefaultProfile());
// Ensure ChromeVox makes announcements at the start of new sessions.
should_speak_chrome_vox_announcements_on_user_screen_ = true;
break;
case chrome::NOTIFICATION_PROFILE_DESTROYED: {
// Update |profile_| when exiting a session or shutting down.
......@@ -797,4 +811,28 @@ void AccessibilityManager::OnDisplayStateChanged(
if (display_state.available)
EnableSpokenFeedback(true, ash::A11Y_NOTIFICATION_SHOW);
}
void AccessibilityManager::OnListenerAdded(
const extensions::EventListenerInfo& details) {
if (details.extension_id != extension_misc::kChromeVoxExtensionId)
return;
ExtensionAccessibilityEventRouter::GetInstance()->
OnChromeVoxLoadStateChanged(profile_,
IsSpokenFeedbackEnabled(),
chrome_vox_loaded_on_lock_screen_ ||
should_speak_chrome_vox_announcements_on_user_screen_);
should_speak_chrome_vox_announcements_on_user_screen_ =
chrome_vox_loaded_on_lock_screen_;
}
void AccessibilityManager::OnListenerRemoved(
const extensions::EventListenerInfo& details) {
if (details.extension_id != extension_misc::kChromeVoxExtensionId)
return;
UnloadChromeVox();
}
} // namespace chromeos
......@@ -10,6 +10,8 @@
#include "base/prefs/pref_change_registrar.h"
#include "chrome/browser/chromeos/accessibility/accessibility_util.h"
#include "chrome/browser/extensions/api/braille_display_private/braille_controller.h"
#include "chrome/browser/extensions/event_router.h"
#include "chrome/browser/extensions/extension_system.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
......@@ -36,6 +38,7 @@ struct AccessibilityStatusEventDetails {
// watching profile notifications and pref-changes.
// TODO(yoshiki): merge MagnificationManager with AccessibilityManager.
class AccessibilityManager : public content::NotificationObserver,
public extensions::EventRouter::Observer,
extensions::api::braille_display_private::BrailleObserver {
public:
// Creates an instance of AccessibilityManager, this should be called once,
......@@ -156,6 +159,12 @@ class AccessibilityManager : public content::NotificationObserver,
const extensions::api::braille_display_private::DisplayState&
display_state) OVERRIDE;
// EventRouter::Observer implementation.
virtual void OnListenerAdded(
const extensions::EventListenerInfo& details) OVERRIDE;
virtual void OnListenerRemoved(
const extensions::EventListenerInfo& details) OVERRIDE;
// Profile which has the current a11y context.
Profile* profile_;
......@@ -185,6 +194,8 @@ class AccessibilityManager : public content::NotificationObserver,
base::WeakPtrFactory<AccessibilityManager> weak_ptr_factory_;
bool should_speak_chrome_vox_announcements_on_user_screen_;
DISALLOW_COPY_AND_ASSIGN(AccessibilityManager);
};
......
......@@ -293,6 +293,23 @@
"description": "Information about the menu that was closed."
}
]
},
{
"name": "onChromeVoxLoadStateChanged",
"type": "function",
"description": "Fired ChromeVox load state changes.",
"parameters": [
{
"type": "boolean",
"name": "loading",
"description": "True if ChromeVox is loading; false if ChromeVox is unloading."
},
{
"type": "boolean",
"name": "makeAnnouncements",
"description": "Whether to make introductory announcements."
}
]
}
]
}
......
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