#ifndef PlatformSpeechSynthesizer_h
#define PlatformSpeechSynthesizer_h
#include "platform/PlatformExport.h"
#include "platform/speech/PlatformSpeechSynthesisVoice.h"
#include "wtf/PassOwnPtr.h"
#include "wtf/Vector.h"
namespace blink {
class WebSpeechSynthesizer;
class WebSpeechSynthesizerClient;
}
namespace WebCore {
enum SpeechBoundary {
SpeechWordBoundary,
SpeechSentenceBoundary
};
class PlatformSpeechSynthesisUtterance;
class PlatformSpeechSynthesizerClient {
public:
virtual void didStartSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance>) = 0;
virtual void didFinishSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance>) = 0;
virtual void didPauseSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance>) = 0;
virtual void didResumeSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance>) = 0;
virtual void speakingErrorOccurred(PassRefPtr<PlatformSpeechSynthesisUtterance>) = 0;
virtual void boundaryEventOccurred(PassRefPtr<PlatformSpeechSynthesisUtterance>, SpeechBoundary, unsigned charIndex) = 0;
virtual void voicesDidChange() = 0;
protected:
virtual ~PlatformSpeechSynthesizerClient() { }
};
class PLATFORM_EXPORT PlatformSpeechSynthesizer {
WTF_MAKE_NONCOPYABLE(PlatformSpeechSynthesizer);
public:
static PassOwnPtr<PlatformSpeechSynthesizer> create(PlatformSpeechSynthesizerClient*);
virtual ~PlatformSpeechSynthesizer();
const Vector<RefPtr<PlatformSpeechSynthesisVoice> >& voiceList() const { return m_voiceList; }
virtual void speak(PassRefPtr<PlatformSpeechSynthesisUtterance>);
virtual void pause();
virtual void resume();
virtual void cancel();
PlatformSpeechSynthesizerClient* client() const { return m_speechSynthesizerClient; }
void setVoiceList(Vector<RefPtr<PlatformSpeechSynthesisVoice> >&);
protected:
virtual void initializeVoiceList();
explicit PlatformSpeechSynthesizer(PlatformSpeechSynthesizerClient*);
Vector<RefPtr<PlatformSpeechSynthesisVoice> > m_voiceList;
private:
PlatformSpeechSynthesizerClient* m_speechSynthesizerClient;
OwnPtr<blink::WebSpeechSynthesizer> m_webSpeechSynthesizer;
OwnPtr<blink::WebSpeechSynthesizerClient> m_webSpeechSynthesizerClient;
};
}
#endif