Commit 80b2ed6a authored by zork@chromium.org's avatar zork@chromium.org

Move Speak() in accessibility_utils, speak enable and disable strings when

accessibility state changes


BUG=chromium-os:19647
TEST=Manual


Review URL: http://codereview.chromium.org/7781004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98921 0039d316-1c4b-4281-b951-d872f2087c98
parent bf531bdb
......@@ -7,6 +7,8 @@
#include "base/callback.h"
#include "base/logging.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/cros/cros_library.h"
#include "chrome/browser/chromeos/cros/speech_synthesis_library.h"
#include "chrome/browser/extensions/extension_accessibility_api.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/file_reader.h"
......@@ -19,6 +21,8 @@
#include "content/browser/tab_contents/tab_contents.h"
#include "content/browser/webui/web_ui.h"
#include "grit/browser_resources.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
namespace chromeos {
......@@ -97,6 +101,11 @@ void EnableAccessibility(bool enabled, WebUI* login_web_ui) {
ExtensionAccessibilityEventRouter::GetInstance()->
SetAccessibilityEnabled(enabled);
Speak(enabled ?
l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_ACCESS_ENABLED).c_str() :
l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_ACCESS_DISABLED).c_str(),
false, true);
// Load/Unload ChromeVox
Profile* profile = ProfileManager::GetDefaultProfile();
ExtensionService* extension_service =
......@@ -145,5 +154,22 @@ void ToggleAccessibility(WebUI* login_web_ui) {
EnableAccessibility(accessibility_enabled, login_web_ui);
};
void Speak(const char* speak_str, bool queue, bool interruptible) {
if (chromeos::CrosLibrary::Get()->EnsureLoaded()) {
if (queue || !interruptible) {
std::string props = "";
props.append("enqueue=");
props.append(queue ? "1;" : "0;");
props.append("interruptible=");
props.append(interruptible ? "1;" : "0;");
chromeos::CrosLibrary::Get()->GetSpeechSynthesisLibrary()->
SetSpeakProperties(props.c_str());
}
chromeos::CrosLibrary::Get()->GetSpeechSynthesisLibrary()->
Speak(speak_str);
}
}
} // namespace accessibility
} // namespace chromeos
......@@ -21,6 +21,9 @@ void EnableAccessibility(bool enabled, WebUI* login_web_ui);
// EnableAccessibility, above.
void ToggleAccessibility(WebUI* login_web_ui);
// Speaks the specified string.
void Speak(const char* speak_str, bool queue, bool interruptible);
} // namespace accessibility
} // namespace chromeos
......
......@@ -11,8 +11,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/string_number_conversions.h"
#include "chrome/browser/accessibility_events.h"
#include "chrome/browser/chromeos/cros/cros_library.h"
#include "chrome/browser/chromeos/cros/speech_synthesis_library.h"
#include "chrome/browser/chromeos/accessibility_util.h"
#include "chrome/browser/extensions/extension_accessibility_api.h"
#include "chrome/browser/extensions/extension_accessibility_api_constants.h"
#include "chrome/browser/profiles/profile_manager.h"
......@@ -109,25 +108,7 @@ void WizardAccessibilityHandler::Observe(
std::string description;
EarconType earcon = NO_EARCON;
DescribeAccessibilityEvent(type, control_info, &description, &earcon);
Speak(description.c_str(), false, true);
}
void WizardAccessibilityHandler::Speak(const char* speak_str,
bool queue,
bool interruptible) {
if (chromeos::CrosLibrary::Get()->EnsureLoaded()) {
if (queue || !interruptible) {
std::string props = "";
props.append("enqueue=");
props.append(queue ? "1;" : "0;");
props.append("interruptible=");
props.append(interruptible ? "1;" : "0;");
chromeos::CrosLibrary::Get()->GetSpeechSynthesisLibrary()->
SetSpeakProperties(props.c_str());
}
chromeos::CrosLibrary::Get()->GetSpeechSynthesisLibrary()->
Speak(speak_str);
}
accessibility::Speak(description.c_str(), false, true);
}
void WizardAccessibilityHandler::DescribeAccessibilityEvent(
......
......@@ -39,9 +39,6 @@ class WizardAccessibilityHandler : public NotificationObserver {
public:
WizardAccessibilityHandler() { }
// Speaks the specified string.
void Speak(const char* speak_str, bool queue, bool interruptible);
private:
// Override from NotificationObserver.
virtual void Observe(int type,
......
......@@ -92,7 +92,7 @@ bool WizardAccessibilityHelper::IsAccessibilityEnabled() {
void WizardAccessibilityHelper::MaybeSpeak(const char* str, bool queue,
bool interruptible) {
if (IsAccessibilityEnabled()) {
accessibility_handler_->Speak(str, queue, interruptible);
accessibility::Speak(str, queue, interruptible);
}
}
......@@ -110,14 +110,7 @@ void WizardAccessibilityHelper::ToggleAccessibility() {
}
void WizardAccessibilityHelper::SetAccessibilityEnabled(bool enabled) {
bool doSpeak = (IsAccessibilityEnabled() != enabled);
accessibility::EnableAccessibility(enabled, NULL);
if (doSpeak) {
accessibility_handler_->Speak(enabled ?
l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_ACCESS_ENABLED).c_str() :
l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_ACCESS_DISABLED).c_str(),
false, true);
}
}
} // namespace chromeos
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