| 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_EXTENSION_API_H_ | 5 #ifndef CHROME_BROWSER_SPEECH_EXTENSION_API_TTS_EXTENSION_API_H_ |
| 6 #define CHROME_BROWSER_SPEECH_EXTENSION_API_TTS_EXTENSION_API_H_ | 6 #define CHROME_BROWSER_SPEECH_EXTENSION_API_TTS_EXTENSION_API_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "chrome/browser/extensions/chrome_extension_function.h" | 10 #include "chrome/browser/extensions/chrome_extension_function.h" |
| 11 #include "chrome/browser/speech/tts_controller.h" | 11 #include "chrome/browser/speech/tts_controller.h" |
| 12 #include "extensions/browser/browser_context_keyed_api_factory.h" | 12 #include "extensions/browser/browser_context_keyed_api_factory.h" |
| 13 | 13 |
| 14 namespace content { | 14 namespace content { |
| 15 class BrowserContext; | 15 class BrowserContext; |
| 16 } | 16 } |
| 17 | 17 |
| 18 const char *TtsEventTypeToString(TtsEventType event_type); | 18 const char *TtsEventTypeToString(TtsEventType event_type); |
| 19 TtsEventType TtsEventTypeFromString(const std::string& str); | 19 TtsEventType TtsEventTypeFromString(const std::string& str); |
| 20 | 20 |
| 21 namespace extensions { | 21 namespace extensions { |
| 22 | 22 |
| 23 class TtsSpeakFunction : public ChromeAsyncExtensionFunction { | 23 class TtsSpeakFunction : public ChromeAsyncExtensionFunction { |
| 24 private: | 24 private: |
| 25 ~TtsSpeakFunction() override {} | 25 ~TtsSpeakFunction() override {} |
| 26 bool RunAsync() override; | 26 bool RunAsync() override; |
| 27 DECLARE_EXTENSION_FUNCTION("tts.speak", TTS_SPEAK) | 27 DECLARE_EXTENSION_FUNCTION("tts.speak", TTS_SPEAK) |
| 28 }; | 28 }; |
| 29 | 29 |
| 30 class TtsStopSpeakingFunction : public ChromeSyncExtensionFunction { | 30 class TtsStopSpeakingFunction : public UIThreadExtensionFunction { |
| 31 private: | 31 private: |
| 32 ~TtsStopSpeakingFunction() override {} | 32 ~TtsStopSpeakingFunction() override {} |
| 33 bool RunSync() override; | 33 ResponseAction Run() override; |
| 34 DECLARE_EXTENSION_FUNCTION("tts.stop", TTS_STOP) | 34 DECLARE_EXTENSION_FUNCTION("tts.stop", TTS_STOP) |
| 35 }; | 35 }; |
| 36 | 36 |
| 37 class TtsPauseFunction : public ChromeSyncExtensionFunction { | 37 class TtsPauseFunction : public UIThreadExtensionFunction { |
| 38 private: | 38 private: |
| 39 ~TtsPauseFunction() override {} | 39 ~TtsPauseFunction() override {} |
| 40 bool RunSync() override; | 40 ResponseAction Run() override; |
| 41 DECLARE_EXTENSION_FUNCTION("tts.pause", TTS_PAUSE) | 41 DECLARE_EXTENSION_FUNCTION("tts.pause", TTS_PAUSE) |
| 42 }; | 42 }; |
| 43 | 43 |
| 44 class TtsResumeFunction : public ChromeSyncExtensionFunction { | 44 class TtsResumeFunction : public UIThreadExtensionFunction { |
| 45 private: | 45 private: |
| 46 ~TtsResumeFunction() override {} | 46 ~TtsResumeFunction() override {} |
| 47 bool RunSync() override; | 47 ResponseAction Run() override; |
| 48 DECLARE_EXTENSION_FUNCTION("tts.resume", TTS_RESUME) | 48 DECLARE_EXTENSION_FUNCTION("tts.resume", TTS_RESUME) |
| 49 }; | 49 }; |
| 50 | 50 |
| 51 class TtsIsSpeakingFunction : public ChromeSyncExtensionFunction { | 51 class TtsIsSpeakingFunction : public UIThreadExtensionFunction { |
| 52 private: | 52 private: |
| 53 ~TtsIsSpeakingFunction() override {} | 53 ~TtsIsSpeakingFunction() override {} |
| 54 bool RunSync() override; | 54 ResponseAction Run() override; |
| 55 DECLARE_EXTENSION_FUNCTION("tts.isSpeaking", TTS_ISSPEAKING) | 55 DECLARE_EXTENSION_FUNCTION("tts.isSpeaking", TTS_ISSPEAKING) |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 class TtsGetVoicesFunction : public ChromeSyncExtensionFunction { | 58 class TtsGetVoicesFunction : public UIThreadExtensionFunction { |
| 59 private: | 59 private: |
| 60 ~TtsGetVoicesFunction() override {} | 60 ~TtsGetVoicesFunction() override {} |
| 61 bool RunSync() override; | 61 ResponseAction Run() override; |
| 62 DECLARE_EXTENSION_FUNCTION("tts.getVoices", TTS_GETVOICES) | 62 DECLARE_EXTENSION_FUNCTION("tts.getVoices", TTS_GETVOICES) |
| 63 }; | 63 }; |
| 64 | 64 |
| 65 class TtsAPI : public BrowserContextKeyedAPI { | 65 class TtsAPI : public BrowserContextKeyedAPI { |
| 66 public: | 66 public: |
| 67 explicit TtsAPI(content::BrowserContext* context); | 67 explicit TtsAPI(content::BrowserContext* context); |
| 68 ~TtsAPI() override; | 68 ~TtsAPI() override; |
| 69 | 69 |
| 70 // BrowserContextKeyedAPI implementation. | 70 // BrowserContextKeyedAPI implementation. |
| 71 static BrowserContextKeyedAPIFactory<TtsAPI>* GetFactoryInstance(); | 71 static BrowserContextKeyedAPIFactory<TtsAPI>* GetFactoryInstance(); |
| 72 | 72 |
| 73 private: | 73 private: |
| 74 friend class BrowserContextKeyedAPIFactory<TtsAPI>; | 74 friend class BrowserContextKeyedAPIFactory<TtsAPI>; |
| 75 | 75 |
| 76 // BrowserContextKeyedAPI implementation. | 76 // BrowserContextKeyedAPI implementation. |
| 77 static const char* service_name() { | 77 static const char* service_name() { |
| 78 return "TtsAPI"; | 78 return "TtsAPI"; |
| 79 } | 79 } |
| 80 static const bool kServiceIsNULLWhileTesting = true; | 80 static const bool kServiceIsNULLWhileTesting = true; |
| 81 }; | 81 }; |
| 82 | 82 |
| 83 } // namespace extensions | 83 } // namespace extensions |
| 84 | 84 |
| 85 #endif // CHROME_BROWSER_SPEECH_EXTENSION_API_TTS_EXTENSION_API_H_ | 85 #endif // CHROME_BROWSER_SPEECH_EXTENSION_API_TTS_EXTENSION_API_H_ |
| OLD | NEW |