Chromium Code Reviews| Index: chrome/browser/speech/tts_chromeos.cc |
| diff --git a/chrome/browser/speech/tts_chromeos.cc b/chrome/browser/speech/tts_chromeos.cc |
| index 7d218e826bf9c086d65e241e5536dd997b740218..f0956aaad5ffe8d69f0b60ce73f24834c5443133 100644 |
| --- a/chrome/browser/speech/tts_chromeos.cc |
| +++ b/chrome/browser/speech/tts_chromeos.cc |
| @@ -4,16 +4,26 @@ |
| #include "base/macros.h" |
| #include "chrome/browser/speech/tts_platform.h" |
| +#include "components/arc/arc_bridge_service.h" |
| +#include "components/arc/common/tts.mojom.h" |
| -// Chrome OS doesn't have native TTS, instead it includes a built-in |
| -// component extension that provides speech synthesis. This class includes |
| -// an implementation of LoadBuiltInTtsExtension and dummy implementations of |
| -// everything else. |
| +namespace { |
| +// Helper returning an Arc tts instance. |
| +arc::mojom::TtsInstance* GetArcTts() { |
| + return arc::ArcBridgeService::Get() |
| + ? arc::ArcBridgeService::Get()->tts()->instance() |
| + : nullptr; |
| +} |
| + |
| +} // namespace |
| + |
| +// This class includes extension-based tts through LoadBuiltInTtsExtension and |
| +// native tts through ARC. |
| class TtsPlatformImplChromeOs : public TtsPlatformImpl { |
| public: |
| // TtsPlatformImpl overrides: |
| - bool PlatformImplAvailable() override { return false; } |
| + bool PlatformImplAvailable() override { return GetArcTts() != nullptr; } |
| bool LoadBuiltInTtsExtension( |
| content::BrowserContext* browser_context) override { |
| @@ -29,19 +39,42 @@ class TtsPlatformImplChromeOs : public TtsPlatformImpl { |
| const std::string& lang, |
| const VoiceData& voice, |
| const UtteranceContinuousParameters& params) override { |
| - return false; |
| + arc::mojom::TtsInstance* tts = GetArcTts(); |
|
Luis Héctor Chávez
2016/07/26 22:48:11
DCHECK_CURRENTLY_ON(BrowserThread::UI);
hidehiko
2016/07/29 09:25:53
ping?
David Tseng
2016/08/01 20:21:41
Done.
|
| + if (!tts) |
| + return false; |
| + |
| + arc::mojom::TtsUtterancePtr arc_utterance = arc::mojom::TtsUtterance::New(); |
| + arc_utterance->utteranceId = utterance_id; |
| + arc_utterance->text = utterance; |
| + arc_utterance->rate = params.rate; |
| + arc_utterance->pitch = params.pitch; |
| + tts->Speak(std::move(arc_utterance)); |
| + return true; |
| } |
| - bool StopSpeaking() override { return false; } |
| + bool StopSpeaking() override { |
| + arc::mojom::TtsInstance* tts = GetArcTts(); |
|
Luis Héctor Chávez
2016/07/26 22:48:11
DCHECK_CURRENTLY_ON(BrowserThread::UI);
hidehiko
2016/07/29 09:25:53
ping?
David Tseng
2016/08/01 20:21:41
Done.
|
| + if (!tts) |
| + return false; |
| - void Pause() override {} |
| + tts->Stop(); |
| + return true; |
| + } |
| - void Resume() override {} |
| + void GetVoices(std::vector<VoiceData>* out_voices) override { |
| + out_voices->push_back(VoiceData()); |
| + VoiceData& voice = out_voices->back(); |
| + voice.native = true; |
| + voice.name = "Android"; |
| + voice.events.insert(TTS_EVENT_START); |
| + voice.events.insert(TTS_EVENT_END); |
| + } |
| + // Unimplemented. |
| + void Pause() override {} |
| + void Resume() override {} |
| bool IsSpeaking() override { return false; } |
| - void GetVoices(std::vector<VoiceData>* out_voices) override {} |
| - |
| // Get the single instance of this class. |
| static TtsPlatformImplChromeOs* GetInstance(); |