/chrome/browser/speech/extension_api/tts_extension_api.h

https://gitlab.com/0072016/Facebook-SDK- · C Header · 85 lines · 62 code · 18 blank · 5 comment · 0 complexity · 1c85f92fd816bc74f1d997eff2fefc11 MD5 · raw file

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