OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/speech/extension_api/tts_extension_api_controller.h" | 5 #include "chrome/browser/speech/extension_api/tts_extension_api_controller.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/float_util.h" | 10 #include "base/float_util.h" |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 void ExtensionTtsController::SpeakOrEnqueue(Utterance* utterance) { | 165 void ExtensionTtsController::SpeakOrEnqueue(Utterance* utterance) { |
166 if (IsSpeaking() && utterance->can_enqueue()) { | 166 if (IsSpeaking() && utterance->can_enqueue()) { |
167 utterance_queue_.push(utterance); | 167 utterance_queue_.push(utterance); |
168 } else { | 168 } else { |
169 Stop(); | 169 Stop(); |
170 SpeakNow(utterance); | 170 SpeakNow(utterance); |
171 } | 171 } |
172 } | 172 } |
173 | 173 |
174 void ExtensionTtsController::SpeakNow(Utterance* utterance) { | 174 void ExtensionTtsController::SpeakNow(Utterance* utterance) { |
175 const Extension* extension; | 175 const extensions::Extension* extension; |
176 size_t voice_index; | 176 size_t voice_index; |
177 if (GetMatchingExtensionVoice(utterance, &extension, &voice_index)) { | 177 if (GetMatchingExtensionVoice(utterance, &extension, &voice_index)) { |
178 current_utterance_ = utterance; | 178 current_utterance_ = utterance; |
179 utterance->set_extension_id(extension->id()); | 179 utterance->set_extension_id(extension->id()); |
180 | 180 |
181 ExtensionTtsEngineSpeak(utterance, extension, voice_index); | 181 ExtensionTtsEngineSpeak(utterance, extension, voice_index); |
182 | 182 |
183 const std::set<std::string> event_types = | 183 const std::set<std::string> event_types = |
184 extension->tts_voices()[voice_index].event_types; | 184 extension->tts_voices()[voice_index].event_types; |
185 bool sends_end_event = | 185 bool sends_end_event = |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 | 327 |
328 int ExtensionTtsController::QueueSize() { | 328 int ExtensionTtsController::QueueSize() { |
329 return static_cast<int>(utterance_queue_.size()); | 329 return static_cast<int>(utterance_queue_.size()); |
330 } | 330 } |
331 | 331 |
332 ExtensionTtsPlatformImpl* ExtensionTtsController::GetPlatformImpl() { | 332 ExtensionTtsPlatformImpl* ExtensionTtsController::GetPlatformImpl() { |
333 if (!platform_impl_) | 333 if (!platform_impl_) |
334 platform_impl_ = ExtensionTtsPlatformImpl::GetInstance(); | 334 platform_impl_ = ExtensionTtsPlatformImpl::GetInstance(); |
335 return platform_impl_; | 335 return platform_impl_; |
336 } | 336 } |
OLD | NEW |