OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_TTS_API_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_TTS_API_CONTROLLER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_TTS_API_CONTROLLER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_TTS_API_CONTROLLER_H_ |
7 | 7 |
8 #include <queue> | 8 #include <queue> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 const std::string& error_message); | 213 const std::string& error_message); |
214 | 214 |
215 // Return a list of all available voices, including the native voice, | 215 // Return a list of all available voices, including the native voice, |
216 // if supported, and all voices registered by extensions. | 216 // if supported, and all voices registered by extensions. |
217 base::ListValue* GetVoices(Profile* profile); | 217 base::ListValue* GetVoices(Profile* profile); |
218 | 218 |
219 // For unit testing. | 219 // For unit testing. |
220 void SetPlatformImpl(ExtensionTtsPlatformImpl* platform_impl); | 220 void SetPlatformImpl(ExtensionTtsPlatformImpl* platform_impl); |
221 int QueueSize(); | 221 int QueueSize(); |
222 | 222 |
223 private: | 223 protected: |
224 ExtensionTtsController(); | 224 ExtensionTtsController(); |
225 virtual ~ExtensionTtsController(); | 225 virtual ~ExtensionTtsController(); |
226 | 226 |
| 227 private: |
227 // Get the platform TTS implementation (or injected mock). | 228 // Get the platform TTS implementation (or injected mock). |
228 ExtensionTtsPlatformImpl* GetPlatformImpl(); | 229 ExtensionTtsPlatformImpl* GetPlatformImpl(); |
229 | 230 |
230 // Start speaking the given utterance. Will either take ownership of | 231 // Start speaking the given utterance. Will either take ownership of |
231 // |utterance| or delete it if there's an error. Returns true on success. | 232 // |utterance| or delete it if there's an error. Returns true on success. |
232 void SpeakNow(Utterance* utterance); | 233 void SpeakNow(Utterance* utterance); |
233 | 234 |
234 // Clear the utterance queue. | 235 // Clear the utterance queue. If send_events is true, will send |
235 void ClearUtteranceQueue(); | 236 // TTS_EVENT_CANCELLED events on each one. |
| 237 void ClearUtteranceQueue(bool send_events); |
236 | 238 |
237 // Finalize and delete the current utterance. | 239 // Finalize and delete the current utterance. |
238 void FinishCurrentUtterance(); | 240 void FinishCurrentUtterance(); |
239 | 241 |
240 // Start speaking the next utterance in the queue. | 242 // Start speaking the next utterance in the queue. |
241 void SpeakNextUtterance(); | 243 void SpeakNextUtterance(); |
242 | 244 |
243 friend struct DefaultSingletonTraits<ExtensionTtsController>; | 245 friend struct DefaultSingletonTraits<ExtensionTtsController>; |
244 | 246 |
245 // The current utterance being spoken. | 247 // The current utterance being spoken. |
246 Utterance* current_utterance_; | 248 Utterance* current_utterance_; |
247 | 249 |
248 // A queue of utterances to speak after the current one finishes. | 250 // A queue of utterances to speak after the current one finishes. |
249 std::queue<Utterance*> utterance_queue_; | 251 std::queue<Utterance*> utterance_queue_; |
250 | 252 |
251 // A pointer to the platform implementation of text-to-speech, for | 253 // A pointer to the platform implementation of text-to-speech, for |
252 // dependency injection. | 254 // dependency injection. |
253 ExtensionTtsPlatformImpl* platform_impl_; | 255 ExtensionTtsPlatformImpl* platform_impl_; |
254 | 256 |
255 DISALLOW_COPY_AND_ASSIGN(ExtensionTtsController); | 257 DISALLOW_COPY_AND_ASSIGN(ExtensionTtsController); |
256 }; | 258 }; |
257 | 259 |
258 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TTS_API_CONTROLLER_H_ | 260 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TTS_API_CONTROLLER_H_ |
OLD | NEW |