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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_SPEECH_EXTENSION_API_TTS_EXTENSION_API_H_
6 #define CHROME_BROWSER_SPEECH_EXTENSION_API_TTS_EXTENSION_API_H_
10 #include "chrome/browser/extensions/chrome_extension_function.h"
11 #include "chrome/browser/speech/tts_controller.h"
12 #include "extensions/browser/browser_context_keyed_api_factory.h"
18 const char *TtsEventTypeToString(TtsEventType event_type);
19 TtsEventType TtsEventTypeFromString(const std::string& str);
21 namespace extensions {
23 class TtsSpeakFunction : public ChromeAsyncExtensionFunction {
25 ~TtsSpeakFunction() override {}
26 bool RunAsync() override;
27 DECLARE_EXTENSION_FUNCTION("tts.speak", TTS_SPEAK)
30 class TtsStopSpeakingFunction : public ChromeSyncExtensionFunction {
32 ~TtsStopSpeakingFunction() override {}
33 bool RunSync() override;
34 DECLARE_EXTENSION_FUNCTION("tts.stop", TTS_STOP)
37 class TtsPauseFunction : public ChromeSyncExtensionFunction {
39 ~TtsPauseFunction() override {}
40 bool RunSync() override;
41 DECLARE_EXTENSION_FUNCTION("tts.pause", TTS_PAUSE)
44 class TtsResumeFunction : public ChromeSyncExtensionFunction {
46 ~TtsResumeFunction() override {}
47 bool RunSync() override;
48 DECLARE_EXTENSION_FUNCTION("tts.resume", TTS_RESUME)
51 class TtsIsSpeakingFunction : public ChromeSyncExtensionFunction {
53 ~TtsIsSpeakingFunction() override {}
54 bool RunSync() override;
55 DECLARE_EXTENSION_FUNCTION("tts.isSpeaking", TTS_ISSPEAKING)
58 class TtsGetVoicesFunction : public ChromeSyncExtensionFunction {
60 ~TtsGetVoicesFunction() override {}
61 bool RunSync() override;
62 DECLARE_EXTENSION_FUNCTION("tts.getVoices", TTS_GETVOICES)
65 class TtsAPI : public BrowserContextKeyedAPI {
67 explicit TtsAPI(content::BrowserContext* context);
70 // BrowserContextKeyedAPI implementation.
71 static BrowserContextKeyedAPIFactory<TtsAPI>* GetFactoryInstance();
74 friend class BrowserContextKeyedAPIFactory<TtsAPI>;
76 // BrowserContextKeyedAPI implementation.
77 static const char* service_name() {
80 static const bool kServiceIsNULLWhileTesting = true;
83 } // namespace extensions
85 #endif // CHROME_BROWSER_SPEECH_EXTENSION_API_TTS_EXTENSION_API_H_