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 #ifndef CHROME_BROWSER_SPEECH_EXTENSION_API_TTS_ENGINE_EXTENSION_API_H_ | 5 #ifndef CHROME_BROWSER_SPEECH_EXTENSION_API_TTS_ENGINE_EXTENSION_API_H_ |
6 #define CHROME_BROWSER_SPEECH_EXTENSION_API_TTS_ENGINE_EXTENSION_API_H_ | 6 #define CHROME_BROWSER_SPEECH_EXTENSION_API_TTS_ENGINE_EXTENSION_API_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
11 #include "chrome/browser/extensions/extension_function.h" | 11 #include "chrome/browser/extensions/extension_function.h" |
12 #include "chrome/browser/speech/tts_controller.h" | 12 #include "chrome/browser/speech/tts_controller.h" |
13 | 13 |
14 class Utterance; | 14 class Utterance; |
15 | 15 |
16 namespace base { | 16 namespace base { |
17 class ListValue; | 17 class ListValue; |
18 } | 18 } |
19 | 19 |
20 namespace extensions { | 20 namespace extensions { |
21 class Extension; | 21 class Extension; |
22 } | 22 } |
23 | 23 |
24 namespace tts_engine_events { | 24 namespace tts_engine_events { |
25 extern const char kOnSpeak[]; | 25 extern const char kOnSpeak[]; |
26 extern const char kOnStop[]; | 26 extern const char kOnStop[]; |
| 27 extern const char kOnPause[]; |
| 28 extern const char kOnResume[]; |
27 } | 29 } |
28 | 30 |
29 // Return a list of all available voices registered by extensions. | 31 // Return a list of all available voices registered by extensions. |
30 void GetExtensionVoices(Profile* profile, std::vector<VoiceData>* out_voices); | 32 void GetExtensionVoices(Profile* profile, std::vector<VoiceData>* out_voices); |
31 | 33 |
32 // Find the first extension with a tts_voices in its | 34 // Find the first extension with a tts_voices in its |
33 // manifest that matches the speech parameters of this utterance. | 35 // manifest that matches the speech parameters of this utterance. |
34 // If found, store a pointer to the extension in |matching_extension| and | 36 // If found, store a pointer to the extension in |matching_extension| and |
35 // the index of the voice within the extension in |voice_index| and | 37 // the index of the voice within the extension in |voice_index| and |
36 // return true. | 38 // return true. |
37 bool GetMatchingExtensionVoice(Utterance* utterance, | 39 bool GetMatchingExtensionVoice(Utterance* utterance, |
38 const extensions::Extension** matching_extension, | 40 const extensions::Extension** matching_extension, |
39 size_t* voice_index); | 41 size_t* voice_index); |
40 | 42 |
41 // Speak the given utterance by sending an event to the given TTS engine | 43 // Speak the given utterance by sending an event to the given TTS engine |
42 // extension voice. | 44 // extension voice. |
43 void ExtensionTtsEngineSpeak(Utterance* utterance, | 45 void ExtensionTtsEngineSpeak(Utterance* utterance, |
44 const VoiceData& voice); | 46 const VoiceData& voice); |
45 | 47 |
46 // Stop speaking the given utterance by sending an event to the extension | 48 // Stop speaking the given utterance by sending an event to the extension |
47 // associated with this utterance. | 49 // associated with this utterance. |
48 void ExtensionTtsEngineStop(Utterance* utterance); | 50 void ExtensionTtsEngineStop(Utterance* utterance); |
49 | 51 |
| 52 // Pause in the middle of speaking this utterance. |
| 53 void ExtensionTtsEnginePause(Utterance* utterance); |
| 54 |
| 55 // Resume speaking this utterance. |
| 56 void ExtensionTtsEngineResume(Utterance* utterance); |
| 57 |
50 // Hidden/internal extension function used to allow TTS engine extensions | 58 // Hidden/internal extension function used to allow TTS engine extensions |
51 // to send events back to the client that's calling tts.speak(). | 59 // to send events back to the client that's calling tts.speak(). |
52 class ExtensionTtsEngineSendTtsEventFunction : public SyncExtensionFunction { | 60 class ExtensionTtsEngineSendTtsEventFunction : public SyncExtensionFunction { |
53 private: | 61 private: |
54 virtual ~ExtensionTtsEngineSendTtsEventFunction() {} | 62 virtual ~ExtensionTtsEngineSendTtsEventFunction() {} |
55 virtual bool RunImpl() OVERRIDE; | 63 virtual bool RunImpl() OVERRIDE; |
56 DECLARE_EXTENSION_FUNCTION("ttsEngine.sendTtsEvent", TTSENGINE_SENDTTSEVENT) | 64 DECLARE_EXTENSION_FUNCTION("ttsEngine.sendTtsEvent", TTSENGINE_SENDTTSEVENT) |
57 }; | 65 }; |
58 | 66 |
59 #endif // CHROME_BROWSER_SPEECH_EXTENSION_API_TTS_ENGINE_EXTENSION_API_H_ | 67 #endif // CHROME_BROWSER_SPEECH_EXTENSION_API_TTS_ENGINE_EXTENSION_API_H_ |
OLD | NEW |