Refactor platform-specific code in SpeechSynthesis
https://bugs.webkit.org/show_bug.cgi?id=107414

Reviewed by Sam Weinig.

Refactor WebSpeech code to use a platform mechanism to provide access to platform resources.

* Modules/speech/DOMWindowSpeechSynthesis.cpp:
(WebCore::DOMWindowSpeechSynthesis::from):
* Modules/speech/SpeechSynthesis.cpp:
(WebCore::SpeechSynthesis::SpeechSynthesis):
(WebCore):
(WebCore::SpeechSynthesis::voicesDidChange):
(WebCore::SpeechSynthesis::getVoices):
(WebCore::SpeechSynthesis::pending):
(WebCore::SpeechSynthesis::speaking):
(WebCore::SpeechSynthesis::paused):
(WebCore::SpeechSynthesis::speak):
(WebCore::SpeechSynthesis::cancel):
(WebCore::SpeechSynthesis::pause):
(WebCore::SpeechSynthesis::resume):
* Modules/speech/SpeechSynthesis.h:
(WebCore):
(SpeechSynthesis):
(WebCore::SpeechSynthesis::didStartSpeaking):
(WebCore::SpeechSynthesis::didFinishSpeaking):
(WebCore::SpeechSynthesis::speakingErrorOccurred):
* Modules/speech/SpeechSynthesisUtterance.cpp:
(WebCore::SpeechSynthesisUtterance::SpeechSynthesisUtterance):
* Modules/speech/SpeechSynthesisUtterance.h:
(WebCore::SpeechSynthesisUtterance::text):
(WebCore::SpeechSynthesisUtterance::setText):
(WebCore::SpeechSynthesisUtterance::lang):
(WebCore::SpeechSynthesisUtterance::setLang):
(WebCore::SpeechSynthesisUtterance::voiceURI):
(WebCore::SpeechSynthesisUtterance::setVoiceURI):
(WebCore::SpeechSynthesisUtterance::volume):
(WebCore::SpeechSynthesisUtterance::setVolume):
(WebCore::SpeechSynthesisUtterance::rate):
(WebCore::SpeechSynthesisUtterance::setRate):
(WebCore::SpeechSynthesisUtterance::pitch):
(WebCore::SpeechSynthesisUtterance::setPitch):
(SpeechSynthesisUtterance):
(WebCore::SpeechSynthesisUtterance::platformUtterance):
* Modules/speech/SpeechSynthesisVoice.cpp:
(WebCore::SpeechSynthesisVoice::create):
(WebCore::SpeechSynthesisVoice::SpeechSynthesisVoice):
* Modules/speech/SpeechSynthesisVoice.h:
(SpeechSynthesisVoice):
(WebCore::SpeechSynthesisVoice::voiceURI):
(WebCore::SpeechSynthesisVoice::name):
(WebCore::SpeechSynthesisVoice::lang):
(WebCore::SpeechSynthesisVoice::localService):
(WebCore::SpeechSynthesisVoice::isDefault):
* Modules/speech/mac/SpeechSynthesisMac.mm:
* WebCore.xcodeproj/project.pbxproj:
* platform/PlatformSpeechSynthesis.h: Added.
(WebCore):
(PlatformSpeechSynthesis):
* platform/PlatformSpeechSynthesisUtterance.cpp: Added.
(WebCore):
(WebCore::PlatformSpeechSynthesisUtterance::PlatformSpeechSynthesisUtterance):
* platform/PlatformSpeechSynthesisUtterance.h: Added.
(WebCore):
(PlatformSpeechSynthesisUtteranceClient):
(WebCore::PlatformSpeechSynthesisUtteranceClient::~PlatformSpeechSynthesisUtteranceClient):
(PlatformSpeechSynthesisUtterance):
(WebCore::PlatformSpeechSynthesisUtterance::text):
(WebCore::PlatformSpeechSynthesisUtterance::setText):
(WebCore::PlatformSpeechSynthesisUtterance::lang):
(WebCore::PlatformSpeechSynthesisUtterance::setLang):
(WebCore::PlatformSpeechSynthesisUtterance::voiceURI):
(WebCore::PlatformSpeechSynthesisUtterance::setVoiceURI):
(WebCore::PlatformSpeechSynthesisUtterance::volume):
(WebCore::PlatformSpeechSynthesisUtterance::setVolume):
(WebCore::PlatformSpeechSynthesisUtterance::rate):
(WebCore::PlatformSpeechSynthesisUtterance::setRate):
(WebCore::PlatformSpeechSynthesisUtterance::pitch):
(WebCore::PlatformSpeechSynthesisUtterance::setPitch):
* platform/PlatformSpeechSynthesisVoice.cpp: Added.
(WebCore):
(WebCore::PlatformSpeechSynthesisVoice::create):
(WebCore::PlatformSpeechSynthesisVoice::PlatformSpeechSynthesisVoice):
* platform/PlatformSpeechSynthesisVoice.h: Added.
(WebCore):
(PlatformSpeechSynthesisVoice):
(WebCore::PlatformSpeechSynthesisVoice::voiceURI):
(WebCore::PlatformSpeechSynthesisVoice::name):
(WebCore::PlatformSpeechSynthesisVoice::lang):
(WebCore::PlatformSpeechSynthesisVoice::localService):
(WebCore::PlatformSpeechSynthesisVoice::isDefault):
* platform/PlatformSpeechSynthesizer.cpp: Added.
(WebCore):
(WebCore::PlatformSpeechSynthesizer::PlatformSpeechSynthesizer):
* platform/PlatformSpeechSynthesizer.h: Added.
(WebCore):
(PlatformSpeechSynthesizerClient):
(WebCore::PlatformSpeechSynthesizerClient::~PlatformSpeechSynthesizerClient):
(PlatformSpeechSynthesizer):
(WebCore::PlatformSpeechSynthesizer::voiceList):
* platform/mac/PlatformSpeechSynthesisMac.mm: Added.
(WebCore):
(WebCore::PlatformSpeechSynthesis::create):
(WebCore::PlatformSpeechSynthesis::PlatformSpeechSynthesis):
(WebCore::PlatformSpeechSynthesis::platformSpeak):
* platform/mac/PlatformSpeechSynthesizerMac.mm: Added.
(WebCore):
(WebCore::PlatformSpeechSynthesizer::initializeVoiceList):
(WebCore::PlatformSpeechSynthesizer::speak):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@142320 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/platform/PlatformSpeechSynthesisVoice.cpp b/Source/WebCore/platform/PlatformSpeechSynthesisVoice.cpp
new file mode 100644
index 0000000..82eef2e
--- /dev/null
+++ b/Source/WebCore/platform/PlatformSpeechSynthesisVoice.cpp
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2013 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "PlatformSpeechSynthesisVoice.h"
+
+#if ENABLE(SPEECH_SYNTHESIS)
+
+namespace WebCore {
+
+PassRefPtr<PlatformSpeechSynthesisVoice> PlatformSpeechSynthesisVoice::create(const String& voiceURI, const String& name, const String& lang, bool localService, bool isDefault)
+{
+    return adoptRef(new PlatformSpeechSynthesisVoice(voiceURI, name, lang, localService, isDefault));
+}
+    
+PlatformSpeechSynthesisVoice::PlatformSpeechSynthesisVoice(const String& voiceURI, const String& name, const String& lang, bool localService, bool isDefault)
+    : m_voiceURI(voiceURI)
+    , m_name(name)
+    , m_lang(lang)
+    , m_localService(localService)
+    , m_default(isDefault)
+{
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SPEECH_SYNTHESIS)