/chromecast/browser/extensions/api/tts/tts_extension_api.h

https://github.com/chromium/chromium · C Header · 90 lines · 60 code · 20 blank · 10 comment · 0 complexity · 863796882318e55dbd210fcdc51d903b MD5 · raw file

  1. // Copyright (c) 2018 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. // PLEASE NOTE: this is a copy with modifications from
  5. // /chrome/browser/speech/extension_api
  6. // It is temporary until a refactoring to move the chrome TTS implementation up
  7. // into components and extensions/components can be completed.
  8. #ifndef CHROMECAST_BROWSER_EXTENSIONS_API_TTS_TTS_EXTENSION_API_H_
  9. #define CHROMECAST_BROWSER_EXTENSIONS_API_TTS_TTS_EXTENSION_API_H_
  10. #include <string>
  11. #include "content/public/browser/tts_controller.h"
  12. #include "extensions/browser/browser_context_keyed_api_factory.h"
  13. #include "extensions/browser/extension_function.h"
  14. namespace content {
  15. class BrowserContext;
  16. }
  17. const char* TtsEventTypeToString(content::TtsEventType event_type);
  18. content::TtsEventType TtsEventTypeFromString(const std::string& str);
  19. namespace extensions {
  20. class TtsSpeakFunction : public ExtensionFunction {
  21. private:
  22. ~TtsSpeakFunction() override {}
  23. // ExtensionFunction:
  24. ResponseAction Run() override;
  25. DECLARE_EXTENSION_FUNCTION("tts.speak", TTS_SPEAK)
  26. };
  27. class TtsStopSpeakingFunction : public ExtensionFunction {
  28. private:
  29. ~TtsStopSpeakingFunction() override {}
  30. ResponseAction Run() override;
  31. DECLARE_EXTENSION_FUNCTION("tts.stop", TTS_STOP)
  32. };
  33. class TtsPauseFunction : public ExtensionFunction {
  34. private:
  35. ~TtsPauseFunction() override {}
  36. ResponseAction Run() override;
  37. DECLARE_EXTENSION_FUNCTION("tts.pause", TTS_PAUSE)
  38. };
  39. class TtsResumeFunction : public ExtensionFunction {
  40. private:
  41. ~TtsResumeFunction() override {}
  42. ResponseAction Run() override;
  43. DECLARE_EXTENSION_FUNCTION("tts.resume", TTS_RESUME)
  44. };
  45. class TtsIsSpeakingFunction : public ExtensionFunction {
  46. private:
  47. ~TtsIsSpeakingFunction() override {}
  48. ResponseAction Run() override;
  49. DECLARE_EXTENSION_FUNCTION("tts.isSpeaking", TTS_ISSPEAKING)
  50. };
  51. class TtsGetVoicesFunction : public ExtensionFunction {
  52. private:
  53. ~TtsGetVoicesFunction() override {}
  54. ResponseAction Run() override;
  55. DECLARE_EXTENSION_FUNCTION("tts.getVoices", TTS_GETVOICES)
  56. };
  57. class TtsAPI : public BrowserContextKeyedAPI {
  58. public:
  59. explicit TtsAPI(content::BrowserContext* context);
  60. ~TtsAPI() override;
  61. // BrowserContextKeyedAPI implementation.
  62. static BrowserContextKeyedAPIFactory<TtsAPI>* GetFactoryInstance();
  63. private:
  64. friend class BrowserContextKeyedAPIFactory<TtsAPI>;
  65. // BrowserContextKeyedAPI implementation.
  66. static const char* service_name() { return "TtsAPI"; }
  67. static const bool kServiceIsNULLWhileTesting = true;
  68. };
  69. } // namespace extensions
  70. #endif // CHROMECAST_BROWSER_EXTENSIONS_API_TTS_TTS_EXTENSION_API_H_