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 const char kChromeVoxUpdateNotificationMessage[] = |
| 12 "n to learn more about chrome vox Next."; |
11 } // anonymous namespace | 13 } // anonymous namespace |
12 | 14 |
13 SpeechMonitor::SpeechMonitor() { | 15 SpeechMonitor::SpeechMonitor() { |
14 TtsController::GetInstance()->SetPlatformImpl(this); | 16 TtsController::GetInstance()->SetPlatformImpl(this); |
15 } | 17 } |
16 | 18 |
17 SpeechMonitor::~SpeechMonitor() { | 19 SpeechMonitor::~SpeechMonitor() { |
18 TtsController::GetInstance()->SetPlatformImpl(TtsPlatformImpl::GetInstance()); | 20 TtsController::GetInstance()->SetPlatformImpl(TtsPlatformImpl::GetInstance()); |
19 } | 21 } |
20 | 22 |
21 std::string SpeechMonitor::GetNextUtterance() { | 23 std::string SpeechMonitor::GetNextUtterance() { |
22 if (utterance_queue_.empty()) { | 24 if (utterance_queue_.empty()) { |
23 loop_runner_ = new content::MessageLoopRunner(); | 25 loop_runner_ = new content::MessageLoopRunner(); |
24 loop_runner_->Run(); | 26 loop_runner_->Run(); |
25 loop_runner_ = NULL; | 27 loop_runner_ = NULL; |
26 } | 28 } |
27 std::string result = utterance_queue_.front(); | 29 std::string result = utterance_queue_.front(); |
28 utterance_queue_.pop_front(); | 30 utterance_queue_.pop_front(); |
29 return result; | 31 return result; |
30 } | 32 } |
31 | 33 |
32 bool SpeechMonitor::SkipChromeVoxEnabledMessage() { | 34 bool SpeechMonitor::SkipChromeVoxEnabledMessage() { |
| 35 bool saw_enabled_message = false; |
| 36 bool saw_update_message = false; |
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 saw_enabled_message |= result == kChromeVoxEnabledMessage; |
| 46 saw_update_message |= result == kChromeVoxUpdateNotificationMessage; |
| 47 if (saw_enabled_message && saw_update_message) |
42 return true; | 48 return true; |
43 } | 49 } |
44 return false; | 50 return false; |
45 } | 51 } |
46 | 52 |
47 bool SpeechMonitor::PlatformImplAvailable() { | 53 bool SpeechMonitor::PlatformImplAvailable() { |
48 return true; | 54 return true; |
49 } | 55 } |
50 | 56 |
51 bool SpeechMonitor::Speak( | 57 bool SpeechMonitor::Speak( |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 if (utterance->text() == "") | 95 if (utterance->text() == "") |
90 return; | 96 return; |
91 | 97 |
92 VLOG(0) << "Speaking " << utterance->text(); | 98 VLOG(0) << "Speaking " << utterance->text(); |
93 utterance_queue_.push_back(utterance->text()); | 99 utterance_queue_.push_back(utterance->text()); |
94 if (loop_runner_.get()) | 100 if (loop_runner_.get()) |
95 loop_runner_->Quit(); | 101 loop_runner_->Quit(); |
96 } | 102 } |
97 | 103 |
98 } // namespace chromeos | 104 } // namespace chromeos |
OLD | NEW |