1 // Copyright (c) 2019 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 
5 #include "content/browser/speech/tts_platform_impl.h"
6 
7 #include "base/no_destructor.h"
8 
9 namespace content {
10 
11 // Dummy implementation to prevent a browser crash, see crbug.com/1019511
12 // TODO(crbug.com/1019819): Provide an implementation for Fuchsia.
13 class TtsPlatformImplFuchsia : public TtsPlatformImpl {
14  public:
15   TtsPlatformImplFuchsia() = default;
16   TtsPlatformImplFuchsia(const TtsPlatformImplFuchsia&) = delete;
17   TtsPlatformImplFuchsia& operator=(const TtsPlatformImplFuchsia&) = delete;
18 
19   // TtsPlatform implementation.
PlatformImplSupported()20   bool PlatformImplSupported() override { return false; }
PlatformImplInitialized()21   bool PlatformImplInitialized() override { return false; }
Speak(int utterance_id,const std::string & utterance,const std::string & lang,const VoiceData & voice,const UtteranceContinuousParameters & params,base::OnceCallback<void (bool)> on_speak_finished)22   void Speak(int utterance_id,
23              const std::string& utterance,
24              const std::string& lang,
25              const VoiceData& voice,
26              const UtteranceContinuousParameters& params,
27              base::OnceCallback<void(bool)> on_speak_finished) override {
28     std::move(on_speak_finished).Run(false);
29   }
StopSpeaking()30   bool StopSpeaking() override { return false; }
IsSpeaking()31   bool IsSpeaking() override { return false; }
GetVoices(std::vector<VoiceData> * out_voices)32   void GetVoices(std::vector<VoiceData>* out_voices) override {}
Pause()33   void Pause() override {}
Resume()34   void Resume() override {}
35 
36   // Get the single instance of this class.
GetInstance()37   static TtsPlatformImplFuchsia* GetInstance() {
38     static base::NoDestructor<TtsPlatformImplFuchsia> tts_platform;
39     return tts_platform.get();
40   }
41 };
42 
43 // static
GetInstance()44 TtsPlatformImpl* TtsPlatformImpl::GetInstance() {
45   return TtsPlatformImplFuchsia::GetInstance();
46 }
47 
48 }  // namespace content
49