OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_TTS_API_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_TTS_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_TTS_API_H_ |
7 | 7 |
8 #include "chrome/browser/extensions/extension_function.h" | 8 #include "chrome/browser/extensions/extension_function.h" |
9 #include "chrome/browser/extensions/extension_tts_api_util.h" | 9 #include "chrome/browser/extensions/extension_tts_api_util.h" |
10 | 10 |
| 11 // Abstract class that defines the native platform TTS interface. |
| 12 class ExtensionTtsPlatformImpl { |
| 13 public: |
| 14 static ExtensionTtsPlatformImpl* GetInstance(); |
| 15 |
| 16 // Speak the given utterance with the given parameters if possible, |
| 17 // and return true on success. Utterance will always be nonempty. |
| 18 // If the user does not specify the other values, language and gender |
| 19 // will be empty strings, and rate, pitch, and volume will be -1.0. |
| 20 virtual bool Speak( |
| 21 const std::string& utterance, |
| 22 const std::string& language, |
| 23 const std::string& gender, |
| 24 double rate, |
| 25 double pitch, |
| 26 double volume) = 0; |
| 27 |
| 28 // Stop speaking immediately and return true on success. |
| 29 virtual bool StopSpeaking() = 0; |
| 30 |
| 31 // Return true if the synthesis engine is currently speaking. |
| 32 virtual bool IsSpeaking() = 0; |
| 33 |
| 34 virtual std::string error() { return error_; } |
| 35 virtual void clear_error() { error_ = std::string(); } |
| 36 virtual void set_error(const std::string& error) { error_ = error; } |
| 37 |
| 38 protected: |
| 39 ExtensionTtsPlatformImpl() {} |
| 40 virtual ~ExtensionTtsPlatformImpl() {} |
| 41 |
| 42 std::string error_; |
| 43 |
| 44 DISALLOW_COPY_AND_ASSIGN(ExtensionTtsPlatformImpl); |
| 45 }; |
| 46 |
| 47 // |
| 48 // Extension API function definitions |
| 49 // |
| 50 |
11 class ExtensionTtsSpeakFunction : public SyncExtensionFunction { | 51 class ExtensionTtsSpeakFunction : public SyncExtensionFunction { |
12 ~ExtensionTtsSpeakFunction() {} | 52 ~ExtensionTtsSpeakFunction() {} |
13 virtual bool RunImpl(); | 53 virtual bool RunImpl(); |
14 DECLARE_EXTENSION_FUNCTION_NAME("experimental.tts.speak") | 54 DECLARE_EXTENSION_FUNCTION_NAME("experimental.tts.speak") |
15 }; | 55 }; |
16 | 56 |
17 class ExtensionTtsStopSpeakingFunction : public SyncExtensionFunction { | 57 class ExtensionTtsStopSpeakingFunction : public SyncExtensionFunction { |
18 ~ExtensionTtsStopSpeakingFunction() {} | 58 ~ExtensionTtsStopSpeakingFunction() {} |
19 virtual bool RunImpl(); | 59 virtual bool RunImpl(); |
20 DECLARE_EXTENSION_FUNCTION_NAME("experimental.tts.stop") | 60 DECLARE_EXTENSION_FUNCTION_NAME("experimental.tts.stop") |
21 }; | 61 }; |
22 | 62 |
23 class ExtensionTtsIsSpeakingFunction : public SyncExtensionFunction { | 63 class ExtensionTtsIsSpeakingFunction : public SyncExtensionFunction { |
24 ~ExtensionTtsIsSpeakingFunction() {} | 64 ~ExtensionTtsIsSpeakingFunction() {} |
25 virtual bool RunImpl(); | 65 virtual bool RunImpl(); |
26 DECLARE_EXTENSION_FUNCTION_NAME("experimental.tts.isSpeaking") | 66 DECLARE_EXTENSION_FUNCTION_NAME("experimental.tts.isSpeaking") |
27 }; | 67 }; |
28 | 68 |
29 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TTS_API_H_ | 69 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TTS_API_H_ |
OLD | NEW |