speech_synthesis_library.cc revision 3345a6884c488ff3a535c2c9acdd33d74b37e311
1// Copyright (c) 2010 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 "chrome/browser/chromeos/cros/speech_synthesis_library.h" 6 7#include "base/message_loop.h" 8#include "chrome/browser/chrome_thread.h" 9#include "chrome/browser/chromeos/cros/cros_library.h" 10#include "cros/chromeos_speech_synthesis.h" 11 12namespace chromeos { 13 14class SpeechSynthesisLibraryImpl : public SpeechSynthesisLibrary { 15 public: 16 SpeechSynthesisLibraryImpl() {} 17 virtual ~SpeechSynthesisLibraryImpl() {} 18 19 bool Speak(const char* text) { 20 return chromeos::Speak(text); 21 } 22 23 bool SetSpeakProperties(const char* props) { 24 return chromeos::SetSpeakProperties(props); 25 } 26 27 bool StopSpeaking() { 28 return chromeos::StopSpeaking(); 29 } 30 31 bool IsSpeaking() { 32 return chromeos::IsSpeaking(); 33 } 34 35 void InitTts(InitStatusCallback callback) { 36 chromeos::InitTts(callback); 37 } 38 39 private: 40 DISALLOW_COPY_AND_ASSIGN(SpeechSynthesisLibraryImpl); 41}; 42 43class SpeechSynthesisLibraryStubImpl : public SpeechSynthesisLibrary { 44 public: 45 SpeechSynthesisLibraryStubImpl() {} 46 virtual ~SpeechSynthesisLibraryStubImpl() {} 47 bool Speak(const char* text) { return true; } 48 bool SetSpeakProperties(const char* props) { return true; } 49 bool StopSpeaking() { return true; } 50 bool IsSpeaking() { return false; } 51 void InitTts(InitStatusCallback callback) {} 52 53 private: 54 DISALLOW_COPY_AND_ASSIGN(SpeechSynthesisLibraryStubImpl); 55}; 56 57// static 58SpeechSynthesisLibrary* SpeechSynthesisLibrary::GetImpl(bool stub) { 59 if (stub) 60 return new SpeechSynthesisLibraryStubImpl(); 61 else 62 return new SpeechSynthesisLibraryImpl(); 63} 64 65} // namespace chromeos 66