| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2013 Apple Computer, Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 #include "platform/exported/WebSpeechSynthesizerClientImpl.h" | 29 #include "platform/exported/WebSpeechSynthesizerClientImpl.h" |
| 30 #include "platform/speech/PlatformSpeechSynthesisUtterance.h" | 30 #include "platform/speech/PlatformSpeechSynthesisUtterance.h" |
| 31 #include "public/platform/Platform.h" | 31 #include "public/platform/Platform.h" |
| 32 #include "public/platform/WebSpeechSynthesisUtterance.h" | 32 #include "public/platform/WebSpeechSynthesisUtterance.h" |
| 33 #include "public/platform/WebSpeechSynthesizer.h" | 33 #include "public/platform/WebSpeechSynthesizer.h" |
| 34 #include "public/platform/WebSpeechSynthesizerClient.h" | 34 #include "public/platform/WebSpeechSynthesizerClient.h" |
| 35 #include "wtf/RetainPtr.h" | 35 #include "wtf/RetainPtr.h" |
| 36 | 36 |
| 37 namespace WebCore { | 37 namespace WebCore { |
| 38 | 38 |
| 39 PassOwnPtr<PlatformSpeechSynthesizer> PlatformSpeechSynthesizer::create(Platform
SpeechSynthesizerClient* client) | 39 PlatformSpeechSynthesizer* PlatformSpeechSynthesizer::create(PlatformSpeechSynth
esizerClient* client) |
| 40 { | 40 { |
| 41 OwnPtr<PlatformSpeechSynthesizer> synthesizer = adoptPtr(new PlatformSpeechS
ynthesizer(client)); | 41 PlatformSpeechSynthesizer* synthesizer = new PlatformSpeechSynthesizer(clien
t); |
| 42 synthesizer->initializeVoiceList(); | 42 synthesizer->initializeVoiceList(); |
| 43 return synthesizer.release(); | 43 return synthesizer; |
| 44 } | 44 } |
| 45 | 45 |
| 46 PlatformSpeechSynthesizer::PlatformSpeechSynthesizer(PlatformSpeechSynthesizerCl
ient* client) | 46 PlatformSpeechSynthesizer::PlatformSpeechSynthesizer(PlatformSpeechSynthesizerCl
ient* client) |
| 47 : m_speechSynthesizerClient(client) | 47 : m_speechSynthesizerClient(client) |
| 48 { | 48 { |
| 49 m_webSpeechSynthesizerClient = adoptPtr(new WebSpeechSynthesizerClientImpl(t
his, client)); | 49 m_webSpeechSynthesizerClient = new WebSpeechSynthesizerClientImpl(this, clie
nt); |
| 50 m_webSpeechSynthesizer = adoptPtr(blink::Platform::current()->createSpeechSy
nthesizer(m_webSpeechSynthesizerClient.get())); | 50 m_webSpeechSynthesizer = adoptPtr(blink::Platform::current()->createSpeechSy
nthesizer(m_webSpeechSynthesizerClient)); |
| 51 } | 51 } |
| 52 | 52 |
| 53 PlatformSpeechSynthesizer::~PlatformSpeechSynthesizer() | 53 PlatformSpeechSynthesizer::~PlatformSpeechSynthesizer() |
| 54 { | 54 { |
| 55 } | 55 } |
| 56 | 56 |
| 57 void PlatformSpeechSynthesizer::speak(PassRefPtr<PlatformSpeechSynthesisUtteranc
e> utterance) | 57 void PlatformSpeechSynthesizer::speak(PlatformSpeechSynthesisUtterance* utteranc
e) |
| 58 { | 58 { |
| 59 if (!m_webSpeechSynthesizer || !m_webSpeechSynthesizerClient) | 59 if (!m_webSpeechSynthesizer || !m_webSpeechSynthesizerClient) |
| 60 return; | 60 return; |
| 61 | 61 |
| 62 m_webSpeechSynthesizer->speak(blink::WebSpeechSynthesisUtterance(utterance))
; | 62 m_webSpeechSynthesizer->speak(blink::WebSpeechSynthesisUtterance(utterance))
; |
| 63 } | 63 } |
| 64 | 64 |
| 65 void PlatformSpeechSynthesizer::pause() | 65 void PlatformSpeechSynthesizer::pause() |
| 66 { | 66 { |
| 67 if (m_webSpeechSynthesizer.get()) | 67 if (m_webSpeechSynthesizer.get()) |
| 68 m_webSpeechSynthesizer->pause(); | 68 m_webSpeechSynthesizer->pause(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 void PlatformSpeechSynthesizer::resume() | 71 void PlatformSpeechSynthesizer::resume() |
| 72 { | 72 { |
| 73 if (m_webSpeechSynthesizer.get()) | 73 if (m_webSpeechSynthesizer.get()) |
| 74 m_webSpeechSynthesizer->resume(); | 74 m_webSpeechSynthesizer->resume(); |
| 75 } | 75 } |
| 76 | 76 |
| 77 void PlatformSpeechSynthesizer::cancel() | 77 void PlatformSpeechSynthesizer::cancel() |
| 78 { | 78 { |
| 79 if (m_webSpeechSynthesizer.get()) | 79 if (m_webSpeechSynthesizer.get()) |
| 80 m_webSpeechSynthesizer->cancel(); | 80 m_webSpeechSynthesizer->cancel(); |
| 81 } | 81 } |
| 82 | 82 |
| 83 void PlatformSpeechSynthesizer::setVoiceList(Vector<RefPtr<PlatformSpeechSynthes
isVoice> >& voices) | 83 void PlatformSpeechSynthesizer::setVoiceList(HeapVector<Member<PlatformSpeechSyn
thesisVoice> >& voices) |
| 84 { | 84 { |
| 85 m_voiceList = voices; | 85 m_voiceList = voices; |
| 86 } | 86 } |
| 87 | 87 |
| 88 void PlatformSpeechSynthesizer::initializeVoiceList() | 88 void PlatformSpeechSynthesizer::initializeVoiceList() |
| 89 { | 89 { |
| 90 if (m_webSpeechSynthesizer.get()) | 90 if (m_webSpeechSynthesizer.get()) |
| 91 m_webSpeechSynthesizer->updateVoiceList(); | 91 m_webSpeechSynthesizer->updateVoiceList(); |
| 92 } | 92 } |
| 93 | 93 |
| 94 void PlatformSpeechSynthesizer::trace(Visitor* visitor) |
| 95 { |
| 96 visitor->trace(m_speechSynthesizerClient); |
| 97 visitor->trace(m_voiceList); |
| 98 visitor->trace(m_webSpeechSynthesizerClient); |
| 99 } |
| 100 |
| 94 } // namespace WebCore | 101 } // namespace WebCore |
| OLD | NEW |