Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(431)

Unified Diff: chrome/browser/chromeos/accessibility/speech_monitor.cc

Issue 153263006: Add test for ChromeVox injection into webview (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment fixed Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/accessibility/speech_monitor.cc
diff --git a/chrome/browser/chromeos/accessibility/speech_monitor.cc b/chrome/browser/chromeos/accessibility/speech_monitor.cc
new file mode 100644
index 0000000000000000000000000000000000000000..dabc8d74f5ea1bb65db21cb1e5652564b5e0c9e2
--- /dev/null
+++ b/chrome/browser/chromeos/accessibility/speech_monitor.cc
@@ -0,0 +1,81 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/accessibility/speech_monitor.h"
+
+namespace chromeos {
+
+namespace {
+const char kChromeVoxEnabledMessage[] = "chrome vox spoken feedback is ready";
+} // anonymous namespace
+
+SpeechMonitor::SpeechMonitor() {
+ TtsController::GetInstance()->SetPlatformImpl(this);
+}
+
+SpeechMonitor::~SpeechMonitor() {
+ TtsController::GetInstance()->SetPlatformImpl(TtsPlatformImpl::GetInstance());
+}
+
+std::string SpeechMonitor::GetNextUtterance() {
+ if (utterance_queue_.empty()) {
+ loop_runner_ = new content::MessageLoopRunner();
+ loop_runner_->Run();
+ loop_runner_ = NULL;
+ }
+ std::string result = utterance_queue_.front();
+ utterance_queue_.pop_front();
+ return result;
+}
+
+bool SpeechMonitor::SkipChromeVoxEnabledMessage() {
+ return GetNextUtterance() == kChromeVoxEnabledMessage;
+}
+
+bool SpeechMonitor::PlatformImplAvailable() {
+ return true;
+}
+
+bool SpeechMonitor::Speak(
+ int utterance_id,
+ const std::string& utterance,
+ const std::string& lang,
+ const VoiceData& voice,
+ const UtteranceContinuousParameters& params) {
+ TtsController::GetInstance()->OnTtsEvent(
+ utterance_id,
+ TTS_EVENT_END,
+ static_cast<int>(utterance.size()),
+ std::string());
+ return true;
+}
+
+bool SpeechMonitor::StopSpeaking() {
+ return true;
+}
+
+bool SpeechMonitor::IsSpeaking() {
+ return false;
+}
+
+void SpeechMonitor::GetVoices(std::vector<VoiceData>* out_voices) {
+ out_voices->push_back(VoiceData());
+ VoiceData& voice = out_voices->back();
+ voice.native = true;
+ voice.name = "SpeechMonitor";
+ voice.events.insert(TTS_EVENT_END);
+}
+
+std::string SpeechMonitor::error() {
+ return "";
+}
+
+void SpeechMonitor::WillSpeakUtteranceWithVoice(const Utterance* utterance,
+ const VoiceData& voice_data) {
+ utterance_queue_.push_back(utterance->text());
+ if (loop_runner_.get())
+ loop_runner_->Quit();
+}
+
+} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698