Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / chrome / browser / chromeos / accessibility / speech_monitor.cc
blobcff49c64aaa25c05166a0a5299a54306d6eeca5b
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/chromeos/accessibility/speech_monitor.h"
7 namespace chromeos {
9 namespace {
10 const char kChromeVoxEnabledMessage[] = "chrome vox spoken feedback is ready";
11 } // anonymous namespace
13 SpeechMonitor::SpeechMonitor() {
14 TtsController::GetInstance()->SetPlatformImpl(this);
17 SpeechMonitor::~SpeechMonitor() {
18 TtsController::GetInstance()->SetPlatformImpl(TtsPlatformImpl::GetInstance());
21 std::string SpeechMonitor::GetNextUtterance() {
22 if (utterance_queue_.empty()) {
23 loop_runner_ = new content::MessageLoopRunner();
24 loop_runner_->Run();
25 loop_runner_ = NULL;
27 std::string result = utterance_queue_.front();
28 utterance_queue_.pop_front();
29 return result;
32 bool SpeechMonitor::SkipChromeVoxEnabledMessage() {
33 while (true) {
34 if (utterance_queue_.empty()) {
35 loop_runner_ = new content::MessageLoopRunner();
36 loop_runner_->Run();
37 loop_runner_ = NULL;
39 std::string result = utterance_queue_.front();
40 utterance_queue_.pop_front();
41 if (result == kChromeVoxEnabledMessage)
42 return true;
44 return false;
47 bool SpeechMonitor::PlatformImplAvailable() {
48 return true;
51 bool SpeechMonitor::Speak(
52 int utterance_id,
53 const std::string& utterance,
54 const std::string& lang,
55 const VoiceData& voice,
56 const UtteranceContinuousParameters& params) {
57 TtsController::GetInstance()->OnTtsEvent(
58 utterance_id,
59 TTS_EVENT_END,
60 static_cast<int>(utterance.size()),
61 std::string());
62 return true;
65 bool SpeechMonitor::StopSpeaking() {
66 return true;
69 bool SpeechMonitor::IsSpeaking() {
70 return false;
73 void SpeechMonitor::GetVoices(std::vector<VoiceData>* out_voices) {
74 out_voices->push_back(VoiceData());
75 VoiceData& voice = out_voices->back();
76 voice.native = true;
77 voice.name = "SpeechMonitor";
78 voice.events.insert(TTS_EVENT_END);
81 std::string SpeechMonitor::error() {
82 return "";
85 void SpeechMonitor::WillSpeakUtteranceWithVoice(const Utterance* utterance,
86 const VoiceData& voice_data) {
87 VLOG(0) << "Speaking " << utterance->text();
88 utterance_queue_.push_back(utterance->text());
89 if (loop_runner_.get())
90 loop_runner_->Quit();
93 } // namespace chromeos