1926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)/*
2926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * Copyright (C) 2013 Google Inc. All rights reserved.
3926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) *
4926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * Redistribution and use in source and binary forms, with or without
5926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * modification, are permitted provided that the following conditions
6926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * are met:
7926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) *  * Redistributions of source code must retain the above copyright
8926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) *    notice, this list of conditions and the following disclaimer.
9926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) *  * Redistributions in binary form must reproduce the above copyright
10926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) *    notice, this list of conditions and the following disclaimer in the
11926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) *    documentation and/or other materials provided with the distribution.
12926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) *
13926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) */
25926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
26926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)#include "config.h"
27a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)#include "platform/exported/WebSpeechSynthesizerClientImpl.h"
28926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
29a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)#include "platform/speech/PlatformSpeechSynthesisUtterance.h"
30926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
31926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)namespace WebCore {
32926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
33926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)WebSpeechSynthesizerClientImpl::WebSpeechSynthesizerClientImpl(PlatformSpeechSynthesizer* synthesizer, PlatformSpeechSynthesizerClient* client)
34926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    : m_synthesizer(synthesizer)
35926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    , m_client(client)
36926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
37926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
38926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
39926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)WebSpeechSynthesizerClientImpl::~WebSpeechSynthesizerClientImpl()
40926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
41926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
42926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
4351b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)void WebSpeechSynthesizerClientImpl::setVoiceList(const blink::WebVector<blink::WebSpeechSynthesisVoice>& voices)
44926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
455d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)    HeapVector<Member<PlatformSpeechSynthesisVoice> > outVoices;
46926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    for (size_t i = 0; i < voices.size(); i++)
475d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)        outVoices.append(voices[i]);
48926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    m_synthesizer->setVoiceList(outVoices);
49926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    m_client->voicesDidChange();
50926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
51926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
5251b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)void WebSpeechSynthesizerClientImpl::didStartSpeaking(const blink::WebSpeechSynthesisUtterance& utterance)
53926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
54926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    m_client->didStartSpeaking(utterance);
55926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
56926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
5751b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)void WebSpeechSynthesizerClientImpl::didFinishSpeaking(const blink::WebSpeechSynthesisUtterance& utterance)
58926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
59926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    m_client->didFinishSpeaking(utterance);
60926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
61926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
6251b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)void WebSpeechSynthesizerClientImpl::didPauseSpeaking(const blink::WebSpeechSynthesisUtterance& utterance)
63926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
64926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    m_client->didPauseSpeaking(utterance);
65926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
66926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
6751b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)void WebSpeechSynthesizerClientImpl::didResumeSpeaking(const blink::WebSpeechSynthesisUtterance& utterance)
68926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
69926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    m_client->didResumeSpeaking(utterance);
70926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
71926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
7251b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)void WebSpeechSynthesizerClientImpl::speakingErrorOccurred(const blink::WebSpeechSynthesisUtterance& utterance)
73926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
74926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    m_client->speakingErrorOccurred(utterance);
75926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
76926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
7751b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)void WebSpeechSynthesizerClientImpl::wordBoundaryEventOccurred(const blink::WebSpeechSynthesisUtterance& utterance, unsigned charIndex)
78926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
79926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    m_client->boundaryEventOccurred(utterance, SpeechWordBoundary, charIndex);
80926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
81926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
8251b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)void WebSpeechSynthesizerClientImpl::sentenceBoundaryEventOccurred(const blink::WebSpeechSynthesisUtterance& utterance, unsigned charIndex)
83926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
84926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    m_client->boundaryEventOccurred(utterance, SpeechSentenceBoundary, charIndex);
85926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
86926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
875d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)void WebSpeechSynthesizerClientImpl::trace(Visitor* visitor)
885d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles){
895d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)    visitor->trace(m_synthesizer);
905d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)    visitor->trace(m_client);
915d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)}
925d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)
93926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)} // namespace WebCore
94