OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/chromeos/accessibility/speech_monitor.h" | 5 #include "chrome/browser/chromeos/accessibility/speech_monitor.h" |
6 | 6 |
7 namespace chromeos { | 7 namespace chromeos { |
8 | 8 |
9 namespace { | 9 namespace { |
10 const char kChromeVoxEnabledMessage[] = "chrome vox spoken feedback is ready"; | 10 const char kChromeVoxEnabledMessage[] = "chrome vox spoken feedback is ready"; |
11 } // anonymous namespace | 11 } // namespace |
12 | 12 |
13 SpeechMonitor::SpeechMonitor() { | 13 SpeechMonitor::SpeechMonitor() { |
14 TtsController::GetInstance()->SetPlatformImpl(this); | 14 TtsController::GetInstance()->SetPlatformImpl(this); |
15 } | 15 } |
16 | 16 |
17 SpeechMonitor::~SpeechMonitor() { | 17 SpeechMonitor::~SpeechMonitor() { |
18 TtsController::GetInstance()->SetPlatformImpl(TtsPlatformImpl::GetInstance()); | 18 TtsController::GetInstance()->SetPlatformImpl(TtsPlatformImpl::GetInstance()); |
19 } | 19 } |
20 | 20 |
21 std::string SpeechMonitor::GetNextUtterance() { | 21 std::string SpeechMonitor::GetNextUtterance() { |
22 if (utterance_queue_.empty()) { | 22 if (utterance_queue_.empty()) { |
23 loop_runner_ = new content::MessageLoopRunner(); | 23 loop_runner_ = new content::MessageLoopRunner(); |
24 loop_runner_->Run(); | 24 loop_runner_->Run(); |
25 loop_runner_ = NULL; | 25 loop_runner_ = NULL; |
26 } | 26 } |
27 std::string result = utterance_queue_.front(); | 27 std::string result = utterance_queue_.front(); |
28 utterance_queue_.pop_front(); | 28 utterance_queue_.pop_front(); |
29 return result; | 29 return result; |
30 } | 30 } |
31 | 31 |
32 bool SpeechMonitor::SkipChromeVoxEnabledMessage() { | 32 bool SpeechMonitor::SkipChromeVoxEnabledMessage() { |
| 33 return SkipChromeVoxMessage(kChromeVoxEnabledMessage); |
| 34 } |
| 35 |
| 36 bool SpeechMonitor::SkipChromeVoxMessage(const std::string& message) { |
33 while (true) { | 37 while (true) { |
34 if (utterance_queue_.empty()) { | 38 if (utterance_queue_.empty()) { |
35 loop_runner_ = new content::MessageLoopRunner(); | 39 loop_runner_ = new content::MessageLoopRunner(); |
36 loop_runner_->Run(); | 40 loop_runner_->Run(); |
37 loop_runner_ = NULL; | 41 loop_runner_ = NULL; |
38 } | 42 } |
39 std::string result = utterance_queue_.front(); | 43 std::string result = utterance_queue_.front(); |
40 utterance_queue_.pop_front(); | 44 utterance_queue_.pop_front(); |
41 if (result == kChromeVoxEnabledMessage) | 45 if (result == message) |
42 return true; | 46 return true; |
43 } | 47 } |
44 return false; | 48 return false; |
45 } | 49 } |
46 | 50 |
47 bool SpeechMonitor::PlatformImplAvailable() { | 51 bool SpeechMonitor::PlatformImplAvailable() { |
48 return true; | 52 return true; |
49 } | 53 } |
50 | 54 |
51 bool SpeechMonitor::Speak( | 55 bool SpeechMonitor::Speak( |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 if (utterance->text() == "") | 93 if (utterance->text() == "") |
90 return; | 94 return; |
91 | 95 |
92 VLOG(0) << "Speaking " << utterance->text(); | 96 VLOG(0) << "Speaking " << utterance->text(); |
93 utterance_queue_.push_back(utterance->text()); | 97 utterance_queue_.push_back(utterance->text()); |
94 if (loop_runner_.get()) | 98 if (loop_runner_.get()) |
95 loop_runner_->Quit(); | 99 loop_runner_->Quit(); |
96 } | 100 } |
97 | 101 |
98 } // namespace chromeos | 102 } // namespace chromeos |
OLD | NEW |