[fuchsia] Implement no-op TtsPlatform.
This prevents a browser crash when a page attempts to use the Web
Speech API.
Bug: 1019511
Change-Id: Ie369adc51dc4fa8228bd9df5a1b102dffd44daa2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1888105
Reviewed-by: David Dorwin <[email protected]>
Reviewed-by: David Tseng <[email protected]>
Commit-Queue: Fabrice de Gans-Riberi <[email protected]>
Cr-Commit-Position: refs/heads/master@{#711528}
diff --git a/content/browser/BUILD.gn b/content/browser/BUILD.gn
index 352901c9..5d1e281 100644
--- a/content/browser/BUILD.gn
+++ b/content/browser/BUILD.gn
@@ -2035,7 +2035,10 @@
}
if (is_fuchsia) {
- sources += [ "child_process_launcher_helper_fuchsia.cc" ]
+ sources += [
+ "child_process_launcher_helper_fuchsia.cc",
+ "speech/tts_fuchsia.cc",
+ ]
deps += [ "//third_party/fuchsia-sdk/sdk:zx" ]
} else if (is_posix) {
sources += [
diff --git a/content/browser/speech/tts_fuchsia.cc b/content/browser/speech/tts_fuchsia.cc
new file mode 100644
index 0000000..930340a
--- /dev/null
+++ b/content/browser/speech/tts_fuchsia.cc
@@ -0,0 +1,46 @@
+// Copyright (c) 2019 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/browser/speech/tts_platform_impl.h"
+
+namespace content {
+
+// Dummy implementation to prevent a browser crash, see crbug.com/1019511
+// TODO(crbug.com/1019819): Provide an implementation for Fuchsia.
+class TtsPlatformImplFuchsia : public TtsPlatformImpl {
+ public:
+ TtsPlatformImplFuchsia() = default;
+ ~TtsPlatformImplFuchsia() override = default;
+
+ // TtsPlatform implementation.
+ bool PlatformImplAvailable() override { return false; }
+ void 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) override {
+ std::move(on_speak_finished).Run(false);
+ }
+ bool StopSpeaking() override { return false; }
+ bool IsSpeaking() override { return false; }
+ void GetVoices(std::vector<VoiceData>* out_voices) override {}
+ void Pause() override {}
+ void Resume() override {}
+
+ // Get the single instance of this class.
+ static TtsPlatformImplFuchsia* GetInstance() {
+ return base::Singleton<TtsPlatformImplFuchsia>::get();
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(TtsPlatformImplFuchsia);
+};
+
+// static
+TtsPlatformImpl* TtsPlatformImpl::GetInstance() {
+ return TtsPlatformImplFuchsia::GetInstance();
+}
+
+} // namespace content
diff --git a/content/browser/speech/tts_platform_impl.cc b/content/browser/speech/tts_platform_impl.cc
index f4c1a4d..2246c9f3 100644
--- a/content/browser/speech/tts_platform_impl.cc
+++ b/content/browser/speech/tts_platform_impl.cc
@@ -20,9 +20,9 @@
return result;
#endif
-#if defined(OS_FUCHSIA) || defined(OS_CHROMEOS)
- // There is no platform TTS definition for Fuchsia. On Chrome OS it's
- // provided by the content client.
+#if defined(OS_CHROMEOS)
+ // On Chrome OS, the platform TTS definition is provided by the content
+ // client.
//
// If this code is reached in production it implies that somebody is
// trying to do TTS on a platform where the content client implementation