WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-81667-20120330151143.patch (text/plain), 54.12 KB, created by
Hans Wennborg
on 2012-03-30 07:11:44 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Hans Wennborg
Created:
2012-03-30 07:11:44 PDT
Size:
54.12 KB
patch
obsolete
>diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 816ba6aff05f99ba087a27eb9923e98b5efd91c1..764182c40bca6bfdd69fe6281c9a5387061077de 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,47 @@ >+2012-03-30 Hans Wennborg <hwennborg@google.com> >+ >+ Speech JavaScript API: Plumbing for Chromium >+ https://bugs.webkit.org/show_bug.cgi?id=81667 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ SpeechGrammar::src() is called with a ScriptExecutionContext, because >+ the attribute setter needs it. Provide a src() method that doesn't >+ take a ScriptExecutionContext that can be used internally. >+ >+ Rename SpeechRecognition::audioStartCallback(), etc. to use event style >+ names, i.e. didStartAudio(), etc. >+ >+ Remove SpeechRecognitionClient::notifyVisibilityHidden(). The embedder >+ can keep track of the visibility. >+ >+ Remove SpeechRecognitionClient::unregisterSpeechRecognition, >+ it is not needed. >+ >+ No new tests, just minor tweaks. >+ >+ * Modules/speech/SpeechGrammar.h: >+ (WebCore::SpeechGrammar::src): >+ * Modules/speech/SpeechRecognition.cpp: >+ (WebCore::SpeechRecognition::didStartAudio): >+ (WebCore::SpeechRecognition::didStartSound): >+ (WebCore::SpeechRecognition::didStartSpeech): >+ (WebCore::SpeechRecognition::didEndSpeech): >+ (WebCore::SpeechRecognition::didEndSound): >+ (WebCore): >+ (WebCore::SpeechRecognition::didEndAudio): >+ (WebCore::SpeechRecognition::didReceiveResult): >+ (WebCore::SpeechRecognition::didReceiveNoMatch): >+ (WebCore::SpeechRecognition::didDeleteResult): >+ (WebCore::SpeechRecognition::didReceiveError): >+ (WebCore::SpeechRecognition::didStart): >+ (WebCore::SpeechRecognition::didEnd): >+ * Modules/speech/SpeechRecognition.h: >+ (SpeechRecognition): >+ * Modules/speech/SpeechRecognitionClient.h: >+ (SpeechRecognitionClient): >+ * Modules/speech/SpeechRecognitionController.h: >+ > 2012-03-30 Philippe Normand <pnormand@igalia.com> > > [GTK] WebAudio channelSize issue >diff --git a/Source/WebKit/chromium/ChangeLog b/Source/WebKit/chromium/ChangeLog >index d642553ec4b1704cb88b14ffe21902e7a986e8d4..76996cfc3537b264caeacfebb08febcf09b48259 100644 >--- a/Source/WebKit/chromium/ChangeLog >+++ b/Source/WebKit/chromium/ChangeLog >@@ -1,3 +1,112 @@ >+2012-03-30 Hans Wennborg <hwennborg@google.com> >+ >+ Speech JavaScript API: Plumbing for Chromium >+ https://bugs.webkit.org/show_bug.cgi?id=81667 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add plumbing for speech recognition. >+ >+ SpeechRecognitionClientProxy implements the SpeechRecognitionClient >+ interface, proxying calls through to WebSpeechRecognizer, which >+ will be implemented in Chromium. >+ >+ WebSpeechRecognizer's start(), stop() and abort() methods take a >+ WebSpeechRecognizerClient object that is used by the embedder >+ to report on progress, results, etc. >+ >+ * WebKit.gyp: >+ * public/WebSpeechGrammar.h: Added. >+ (WebCore): >+ (WebKit): >+ (WebSpeechGrammar): >+ (WebKit::WebSpeechGrammar::WebSpeechGrammar): >+ (WebKit::WebSpeechGrammar::~WebSpeechGrammar): >+ * public/WebSpeechRecognizerClient.h: Added. >+ (WebCore): >+ (WebKit): >+ (WebSpeechRecognizerClient): >+ (WebKit::WebSpeechRecognizerClient::~WebSpeechRecognizerClient): >+ (WebKit::WebSpeechRecognizerClient::WebSpeechRecognizerClient): >+ (WebKit::WebSpeechRecognizerClient::operator=): >+ (WebKit::operator==): >+ (WebKit::operator!=): >+ (WebKit::operator<): >+ * public/WebSpeechRecognitionParameters.h: >+ (WebKit): >+ (WebSpeechRecognitionParameters): >+ * public/WebSpeechRecognitionResult.h: Added. >+ (WebCore): >+ (WebKit): >+ (WebSpeechRecognitionResult): >+ (WebKit::WebSpeechRecognitionResult::WebSpeechRecognitionResult): >+ (WebKit::WebSpeechRecognitionResult::~WebSpeechRecognitionResult): >+ * public/WebSpeechRecognizer.h: >+ (WebKit): >+ (WebSpeechRecognizer): >+ (WebKit::WebSpeechRecognizer::start): >+ (WebKit::WebSpeechRecognizer::stop): >+ (WebKit::WebSpeechRecognizer::abort): >+ (WebKit::WebSpeechRecognizer::~WebSpeechRecognizer): >+ * public/WebViewClient.h: >+ (WebKit): >+ (WebViewClient): >+ (WebKit::WebViewClient::speechRecognizer): >+ * src/SpeechRecognitionClientProxy.cpp: Added. >+ (WebKit): >+ (WebKit::SpeechRecognitionClientProxy::~SpeechRecognitionClientProxy): >+ (WebKit::SpeechRecognitionClientProxy::create): >+ (WebKit::SpeechRecognitionClientProxy::start): >+ (WebKit::SpeechRecognitionClientProxy::stop): >+ (WebKit::SpeechRecognitionClientProxy::abort): >+ (WebKit::SpeechRecognitionClientProxy::SpeechRecognitionClientProxy): >+ * src/SpeechRecognitionClientProxy.h: >+ (WebKit): >+ (SpeechRecognitionClientProxy): >+ * src/WebSpeechGrammar.cpp: Added. >+ (WebKit): >+ (WebKit::WebSpeechGrammar::reset): >+ (WebKit::WebSpeechGrammar::WebSpeechGrammar): >+ (WebKit::WebSpeechGrammar::operator=): >+ (WebKit::WebSpeechGrammar::src): >+ (WebKit::WebSpeechGrammar::weight): >+ * src/WebSpeechRecognizerClient.cpp: Added. >+ (WebKit): >+ (WebKit::WebSpeechRecognizerClient::reset): >+ (WebKit::WebSpeechRecognizerClient::assign): >+ (WebKit::WebSpeechRecognizerClient::equals): >+ (WebKit::WebSpeechRecognizerClient::lessThan): >+ (WebKit::WebSpeechRecognizerClient::didStartAudio): >+ (WebKit::WebSpeechRecognizerClient::didStartSound): >+ (WebKit::WebSpeechRecognizerClient::didStartSpeech): >+ (WebKit::WebSpeechRecognizerClient::didEndSpeech): >+ (WebKit::WebSpeechRecognizerClient::didEndSound): >+ (WebKit::WebSpeechRecognizerClient::didEndAudio): >+ (WebKit::WebSpeechRecognizerClient::didReceiveResult): >+ (WebKit::WebSpeechRecognizerClient::didReceiveNoMatch): >+ (WebKit::WebSpeechRecognizerClient::didDeleteResult): >+ (WebKit::WebSpeechRecognizerClient::didReceiveError): >+ (WebKit::WebSpeechRecognizerClient::didStart): >+ (WebKit::WebSpeechRecognizerClient::didEnd): >+ (WebKit::WebSpeechRecognizerClient::WebSpeechRecognizerClient): >+ (WebKit::WebSpeechRecognizerClient::operator=): >+ (WebKit::WebSpeechRecognizerClient::operator PassRefPtr<SpeechRecognition>): >+ * src/WebSpeechRecognitionParameters.cpp: Added. >+ (WebKit): >+ (WebKit::WebSpeechRecognitionParameters::WebSpeechRecognitionParameters): >+ (WebKit::WebSpeechRecognitionParameters::grammars): >+ (WebKit::WebSpeechRecognitionParameters::language): >+ (WebKit::WebSpeechRecognitionParameters::continuous): >+ * src/WebSpeechRecognitionResult.cpp: Added. >+ (WebKit): >+ (WebKit::WebSpeechRecognitionResult::assign): >+ (WebKit::WebSpeechRecognitionResult::reset): >+ (WebKit::WebSpeechRecognitionResult::operator PassRefPtr<WebCore::SpeechRecognitionResult>): >+ * src/WebViewImpl.cpp: >+ (WebKit::WebViewImpl::WebViewImpl): >+ * src/WebViewImpl.h: >+ (WebKit): >+ > 2012-03-29 Adam Barth <abarth@webkit.org> > > Unreviewed, rolling out r112572. >diff --git a/Source/WebCore/Modules/speech/SpeechGrammar.h b/Source/WebCore/Modules/speech/SpeechGrammar.h >index 62088c18b0c8cb01d3407d1d266b82cb6dd2f2f9..e08358bbf13ed2ffec4ce66622669feb9a14a0bd 100644 >--- a/Source/WebCore/Modules/speech/SpeechGrammar.h >+++ b/Source/WebCore/Modules/speech/SpeechGrammar.h >@@ -42,6 +42,7 @@ public: > static PassRefPtr<SpeechGrammar> create(const KURL& src, double weight); > > const KURL& src(ScriptExecutionContext*) const { return m_src; } >+ const KURL& src() const { return m_src; } > void setSrc(ScriptExecutionContext*, const String& src); > > double weight() const { return m_weight; } >diff --git a/Source/WebCore/Modules/speech/SpeechRecognition.cpp b/Source/WebCore/Modules/speech/SpeechRecognition.cpp >index 1b3ab3254857201a64e4b83a53b7bc15c169ae00..2a7669e96d31d743bf1eea7db10f9553a326438f 100644 >--- a/Source/WebCore/Modules/speech/SpeechRecognition.cpp >+++ b/Source/WebCore/Modules/speech/SpeechRecognition.cpp >@@ -62,58 +62,63 @@ void SpeechRecognition::abort() > m_controller->abort(this); // FIXME: Spec should say what to do if we are not started. > } > >-void SpeechRecognition::audioStartCallback() >+void SpeechRecognition::didStartAudio() > { > // FIXME: The spec should specify whether these events can bubble and are cancelable. > dispatchEvent(Event::create(eventNames().audiostartEvent, /*canBubble=*/false, /*cancelable=*/false)); > } > >-void SpeechRecognition::soundStartCallback() >+void SpeechRecognition::didStartSound() > { > dispatchEvent(Event::create(eventNames().soundstartEvent, /*canBubble=*/false, /*cancelable=*/false)); > } > >-void SpeechRecognition::speechStartCallback() >+void SpeechRecognition::didStartSpeech() > { > dispatchEvent(Event::create(eventNames().speechstartEvent, /*canBubble=*/false, /*cancelable=*/false)); > } > >-void SpeechRecognition::speechEndCallback() >+void SpeechRecognition::didEndSpeech() > { > dispatchEvent(Event::create(eventNames().speechendEvent, /*canBubble=*/false, /*cancelable=*/false)); > } > >-void SpeechRecognition::audioEndCallback() >+void SpeechRecognition::didEndSound() >+{ >+ dispatchEvent(Event::create(eventNames().soundendEvent, /*canBubble=*/false, /*cancelable=*/false)); >+} >+ >+void SpeechRecognition::didEndAudio() > { > dispatchEvent(Event::create(eventNames().audioendEvent, /*canBubble=*/false, /*cancelable=*/false)); > } > >-void SpeechRecognition::resultCallback(PassRefPtr<SpeechRecognitionResult> result, unsigned long resultIndex, PassRefPtr<SpeechRecognitionResultList> resultHistory) >+void SpeechRecognition::didReceiveResult(PassRefPtr<SpeechRecognitionResult> result, unsigned long resultIndex, PassRefPtr<SpeechRecognitionResultList> resultHistory) > { > dispatchEvent(SpeechRecognitionEvent::createResult(result, resultIndex, resultHistory)); > } > >-void SpeechRecognition::noMatchCallback(PassRefPtr<SpeechRecognitionResult> result) >+void SpeechRecognition::didReceiveNoMatch(PassRefPtr<SpeechRecognitionResult> result) > { > dispatchEvent(SpeechRecognitionEvent::createNoMatch(result)); > } > >-void SpeechRecognition::resultDeletedCallback(unsigned resultIndex, PassRefPtr<SpeechRecognitionResultList> resultHistory) >+void SpeechRecognition::didDeleteResult(unsigned resultIndex, PassRefPtr<SpeechRecognitionResultList> resultHistory) > { > dispatchEvent(SpeechRecognitionEvent::createResultDeleted(resultIndex, resultHistory)); > } > >-void SpeechRecognition::errorCallback(PassRefPtr<SpeechRecognitionError> error) >+void SpeechRecognition::didReceiveError(PassRefPtr<SpeechRecognitionError> error) > { > dispatchEvent(SpeechRecognitionEvent::createError(error)); > } > >-void SpeechRecognition::startCallback() >+void SpeechRecognition::didStart() > { > dispatchEvent(Event::create(eventNames().startEvent, /*canBubble=*/false, /*cancelable=*/false)); > } > >-void SpeechRecognition::endCallback() >+void SpeechRecognition::didEnd() > { > dispatchEvent(Event::create(eventNames().endEvent, /*canBubble=*/false, /*cancelable=*/false)); > } >diff --git a/Source/WebCore/Modules/speech/SpeechRecognition.h b/Source/WebCore/Modules/speech/SpeechRecognition.h >index 39e0086f0d94cd38f7a12804bb57f3de775f203c..3fc244166e338c3b0f62cfcf02f08b85a5d55703 100644 >--- a/Source/WebCore/Modules/speech/SpeechRecognition.h >+++ b/Source/WebCore/Modules/speech/SpeechRecognition.h >@@ -64,17 +64,18 @@ public: > void abort(); > > // Called by the SpeechRecognitionClient. >- void audioStartCallback(); >- void soundStartCallback(); >- void speechStartCallback(); >- void speechEndCallback(); >- void audioEndCallback(); >- void resultCallback(PassRefPtr<SpeechRecognitionResult>, unsigned long resultIndex, PassRefPtr<SpeechRecognitionResultList> resultHistory); >- void noMatchCallback(PassRefPtr<SpeechRecognitionResult>); >- void resultDeletedCallback(unsigned resultIndex, PassRefPtr<SpeechRecognitionResultList> resultHistory); >- void errorCallback(PassRefPtr<SpeechRecognitionError>); >- void startCallback(); >- void endCallback(); >+ void didStartAudio(); >+ void didStartSound(); >+ void didStartSpeech(); >+ void didEndSpeech(); >+ void didEndSound(); >+ void didEndAudio(); >+ void didReceiveResult(PassRefPtr<SpeechRecognitionResult>, unsigned long resultIndex, PassRefPtr<SpeechRecognitionResultList> resultHistory); >+ void didReceiveNoMatch(PassRefPtr<SpeechRecognitionResult>); >+ void didDeleteResult(unsigned resultIndex, PassRefPtr<SpeechRecognitionResultList> resultHistory); >+ void didReceiveError(PassRefPtr<SpeechRecognitionError>); >+ void didStart(); >+ void didEnd(); > > // EventTarget > virtual const AtomicString& interfaceName() const OVERRIDE; >diff --git a/Source/WebCore/Modules/speech/SpeechRecognitionClient.h b/Source/WebCore/Modules/speech/SpeechRecognitionClient.h >index 46255807f1c168634c9c40b6fe117f68b0f1bbd4..29bb9f66b2c16480499a220565099260ddec3384 100644 >--- a/Source/WebCore/Modules/speech/SpeechRecognitionClient.h >+++ b/Source/WebCore/Modules/speech/SpeechRecognitionClient.h >@@ -41,8 +41,6 @@ public: > virtual void start(SpeechRecognition*, const SpeechGrammarList*, const String& lang, bool continuous) = 0; > virtual void stop(SpeechRecognition*) = 0; > virtual void abort(SpeechRecognition*) = 0; >- virtual void visibilityHidden() = 0; >- virtual void unregisterSpeechRecognition(SpeechRecognition*) = 0; > > virtual ~SpeechRecognitionClient() { } > }; >diff --git a/Source/WebCore/Modules/speech/SpeechRecognitionController.h b/Source/WebCore/Modules/speech/SpeechRecognitionController.h >index ef5c190750e85e39e5b1cc256813da185b68871b..50bc5a42fecf483b076619cf41adc38514d76e87 100644 >--- a/Source/WebCore/Modules/speech/SpeechRecognitionController.h >+++ b/Source/WebCore/Modules/speech/SpeechRecognitionController.h >@@ -41,8 +41,6 @@ public: > void start(SpeechRecognition* recognition, const SpeechGrammarList* grammars, const String& lang, bool continuous) { m_client->start(recognition, grammars, lang, continuous); } > void stop(SpeechRecognition* recognition) { m_client->stop(recognition); } > void abort(SpeechRecognition* recognition) { m_client->abort(recognition); } >- void visibilityHidden() { m_client->visibilityHidden(); } >- void unregisterSpeechRecognition(SpeechRecognition* recognition) { m_client->unregisterSpeechRecognition(recognition); } > > static PassOwnPtr<SpeechRecognitionController> create(SpeechRecognitionClient*); > static const AtomicString& supplementName(); >diff --git a/Source/WebKit/chromium/WebKit.gyp b/Source/WebKit/chromium/WebKit.gyp >index b035c70ebc75f205b6303ae7ce6142de4e8bde8f..71ce0792d3d6f41005ded6779d3dffd13a338eba 100644 >--- a/Source/WebKit/chromium/WebKit.gyp >+++ b/Source/WebKit/chromium/WebKit.gyp >@@ -257,9 +257,14 @@ > 'public/WebSharedWorkerRepository.h', > 'public/WebSocket.h', > 'public/WebSocketClient.h', >+ 'public/WebSpeechGrammar.h', > 'public/WebSpeechInputController.h', > 'public/WebSpeechInputListener.h', > 'public/WebSpeechInputResult.h', >+ 'public/WebSpeechRecognitionParams.h', >+ 'public/WebSpeechRecognitionResult.h', >+ 'public/WebSpeechRecognizerClient.h', >+ 'public/WebSpeechRecognizer.h', > 'public/WebSpellCheckClient.h', > 'public/WebStorageArea.h', > 'public/WebStorageEventDispatcher.h', >@@ -478,6 +483,8 @@ > 'src/SocketStreamHandleInternal.h', > 'src/SpeechInputClientImpl.cpp', > 'src/SpeechInputClientImpl.h', >+ 'src/SpeechRecognitionClientProxy.cpp', >+ 'src/SpeechRecognitionClientProxy.h', > 'src/StorageAreaProxy.cpp', > 'src/StorageAreaProxy.h', > 'src/StorageEventDispatcherChromium.cpp', >@@ -666,7 +673,11 @@ > 'src/WebSocketImpl.h', > 'src/WebSolidColorLayer.cpp', > 'src/WebSolidColorLayerImpl.cpp', >+ 'src/WebSpeechGrammar.cpp', > 'src/WebSpeechInputResult.cpp', >+ 'src/WebSpeechRecognitionParams.cpp', >+ 'src/WebSpeechRecognitionResult.cpp', >+ 'src/WebSpeechRecognizerClient.cpp', > 'src/WebStorageAreaImpl.cpp', > 'src/WebStorageAreaImpl.h', > 'src/WebStorageEventDispatcherImpl.cpp', >diff --git a/Source/WebKit/chromium/public/WebSpeechGrammar.h b/Source/WebKit/chromium/public/WebSpeechGrammar.h >new file mode 100644 >index 0000000000000000000000000000000000000000..726e96c58f53d5ab1b3bff51e44704631edd850d >--- /dev/null >+++ b/Source/WebKit/chromium/public/WebSpeechGrammar.h >@@ -0,0 +1,61 @@ >+/* >+ * Copyright (C) 2012 Google 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: >+ * * Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * * 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 THE COPYRIGHT HOLDERS ``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 THE COPYRIGHT OWNER 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. >+ */ >+ >+#ifndef WebSpeechGrammar_h >+#define WebSpeechGrammar_h >+ >+#include "platform/WebCommon.h" >+#include "platform/WebPrivatePtr.h" >+#include "platform/WebString.h" >+#include "platform/WebURL.h" >+ >+namespace WebCore { >+class SpeechGrammar; >+} >+ >+namespace WebKit { >+ >+class WebSpeechGrammar { >+public: >+ WebSpeechGrammar() { } >+ ~WebSpeechGrammar() { reset(); } >+ >+ WEBKIT_EXPORT WebURL src() const; >+ WEBKIT_EXPORT float weight() const; >+ >+ WEBKIT_EXPORT void reset(); >+ >+#if WEBKIT_IMPLEMENTATION >+ WebSpeechGrammar(const WTF::PassRefPtr<WebCore::SpeechGrammar>&); >+ WebSpeechGrammar& operator=(const WTF::PassRefPtr<WebCore::SpeechGrammar>&); >+#endif >+ >+private: >+ WebPrivatePtr<WebCore::SpeechGrammar> m_private; >+}; >+ >+} // namespace WebKit >+ >+#endif // WebSpeechGrammar_h >diff --git a/Source/WebKit/chromium/public/WebSpeechRecognitionParams.h b/Source/WebKit/chromium/public/WebSpeechRecognitionParams.h >new file mode 100644 >index 0000000000000000000000000000000000000000..0b2d6557247f734f1cb21281846a9141cd44d4d8 >--- /dev/null >+++ b/Source/WebKit/chromium/public/WebSpeechRecognitionParams.h >@@ -0,0 +1,53 @@ >+/* >+ * Copyright (C) 2012 Google 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: >+ * * Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * * 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 THE COPYRIGHT HOLDERS ``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 THE COPYRIGHT OWNER 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. >+ */ >+ >+#ifndef WebSpeechRecognitionParams_h >+#define WebSpeechRecognitionParams_h >+ >+#include "WebSpeechGrammar.h" >+#include "platform/WebString.h" >+#include "platform/WebVector.h" >+ >+namespace WebKit { >+ >+class WebSpeechGrammar; >+ >+class WebSpeechRecognitionParams { >+public: >+ WebSpeechRecognitionParams(const WebVector<WebSpeechGrammar>&, const WebString& language, bool continuous); >+ >+ const WebVector<WebSpeechGrammar>& grammars() const { return m_grammars; } >+ const WebString& language() const { return m_language; } >+ bool continuous() const { return m_continuous; } >+ >+private: >+ WebVector<WebSpeechGrammar> m_grammars; >+ WebString m_language; >+ bool m_continuous; >+}; >+ >+} // namespace WebKit >+ >+#endif // WebSpeechRecognitionParams_h >diff --git a/Source/WebKit/chromium/public/WebSpeechRecognitionResult.h b/Source/WebKit/chromium/public/WebSpeechRecognitionResult.h >new file mode 100644 >index 0000000000000000000000000000000000000000..0e3f543119c61a6b3dd1e53cefd058e0593698d5 >--- /dev/null >+++ b/Source/WebKit/chromium/public/WebSpeechRecognitionResult.h >@@ -0,0 +1,59 @@ >+/* >+ * Copyright (C) 2012 Google 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 AND ITS CONTRIBUTORS "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 OR ITS 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. >+ */ >+ >+#ifndef WebSpeechRecognitionResult_h >+#define WebSpeechRecognitionResult_h >+ >+#include "platform/WebCommon.h" >+#include "platform/WebPrivatePtr.h" >+#include "platform/WebString.h" >+#include "platform/WebVector.h" >+ >+namespace WebCore { >+class SpeechRecognitionResult; >+} >+ >+namespace WebKit { >+ >+class WebSpeechRecognitionResult { >+public: >+ WebSpeechRecognitionResult() { } >+ ~WebSpeechRecognitionResult() { reset(); } >+ >+ WEBKIT_EXPORT void assign(const WebVector<WebString>& transcripts, const WebVector<float>& confidences, bool final); >+ WEBKIT_EXPORT void assign(const WebSpeechRecognitionResult&); >+ WEBKIT_EXPORT void reset(); >+ >+#if WEBKIT_IMPLEMENTATION >+ operator WTF::PassRefPtr<WebCore::SpeechRecognitionResult>() const; >+#endif >+ >+private: >+ WebPrivatePtr<WebCore::SpeechRecognitionResult> m_private; >+}; >+ >+} // namespace WebKit >+ >+#endif // WebSpeechRecognitionResult_h >diff --git a/Source/WebKit/chromium/public/WebSpeechRecognizer.h b/Source/WebKit/chromium/public/WebSpeechRecognizer.h >new file mode 100644 >index 0000000000000000000000000000000000000000..d1b6da50e7f2979a987b030df38afb2d4461f79a >--- /dev/null >+++ b/Source/WebKit/chromium/public/WebSpeechRecognizer.h >@@ -0,0 +1,56 @@ >+/* >+ * Copyright (C) 2012 Google 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: >+ * * Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * * 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 THE COPYRIGHT HOLDERS ``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 THE COPYRIGHT OWNER 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. >+ */ >+ >+#ifndef WebSpeechRecognizer_h >+#define WebSpeechRecognizer_h >+ >+#include "platform/WebCommon.h" >+#include "platform/WebString.h" >+#include "platform/WebVector.h" >+ >+namespace WebKit { >+ >+class WebSpeechGrammar; >+class WebSpeechRecognizerClient; >+ >+// Interface for speech recognition, to be implemented by the embedder. >+class WebSpeechRecognizer { >+public: >+ // Start speech recognition using the specified parameters. Notifications on progress, results, and errors will be sent to the client. >+ virtual void start(const WebSpeechRecognitionParams&, const WebSpeechRecognizerClient&) { WEBKIT_ASSERT_NOT_REACHED(); } >+ >+ // Stop speech recognition, returning any results for the audio recorded so far. Notifications and errors are sent to the client. >+ virtual void stop(const WebSpeechRecognizerClient&) { WEBKIT_ASSERT_NOT_REACHED(); } >+ >+ // Abort speech recognition, discarding any recorded audio. Notifications and errors are sent to the client. >+ virtual void abort(const WebSpeechRecognizerClient&) { WEBKIT_ASSERT_NOT_REACHED(); } >+ >+protected: >+ virtual ~WebSpeechRecognizer() { } >+}; >+ >+} // namespace WebKit >+ >+#endif // WebSpeechRecognizer_h >diff --git a/Source/WebKit/chromium/public/WebSpeechRecognizerClient.h b/Source/WebKit/chromium/public/WebSpeechRecognizerClient.h >new file mode 100644 >index 0000000000000000000000000000000000000000..76dae52a70caa503e34bb2bcd9844d33a43c4aa7 >--- /dev/null >+++ b/Source/WebKit/chromium/public/WebSpeechRecognizerClient.h >@@ -0,0 +1,138 @@ >+/* >+ * Copyright (C) 2012 Google 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: >+ * * Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * * 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 THE COPYRIGHT HOLDERS ``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 THE COPYRIGHT OWNER 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. >+ */ >+ >+#ifndef WebSpeechRecognizerClient_h >+#define WebSpeechRecognizerClient_h >+ >+#include "platform/WebCommon.h" >+#include "platform/WebPrivatePtr.h" >+#include "platform/WebVector.h" >+ >+namespace WebCore { >+class SpeechRecognition; >+} >+ >+namespace WebKit { >+ >+class WebSpeechRecognitionResult; >+class WebString; >+ >+// A client for reporting progress on speech recognition. >+class WebSpeechRecognizerClient { >+public: >+ ~WebSpeechRecognizerClient() { reset(); } >+ WebSpeechRecognizerClient() { } >+ >+ WebSpeechRecognizerClient(const WebSpeechRecognizerClient& other) { assign(other); } >+ WebSpeechRecognizerClient& operator=(const WebSpeechRecognizerClient& other) >+ { >+ assign(other); >+ return *this; >+ } >+ >+ WEBKIT_EXPORT void reset(); >+ WEBKIT_EXPORT void assign(const WebSpeechRecognizerClient&); >+ >+ // Comparison functions are provided so that WebSpeechRecognizerClient objects >+ // can be stored in a hash map. >+ WEBKIT_EXPORT bool equals(const WebSpeechRecognizerClient&) const; >+ WEBKIT_EXPORT bool lessThan(const WebSpeechRecognizerClient&) const; >+ >+ // These methods correspond to the events described in the spec: >+ // http://speech-javascript-api-spec.googlecode.com/git/speechapi.html#speechreco-events >+ >+ // To be called when the embedder has started to capture audio. >+ WEBKIT_EXPORT void didStartAudio(); >+ >+ // To be called when some sound, possibly speech, has been detected. >+ // This is expected to be called after didStartAudio. >+ WEBKIT_EXPORT void didStartSound(); >+ >+ // To be called when speech has been detected. >+ // This is expected to be called after didStartSound. >+ WEBKIT_EXPORT void didStartSpeech(); >+ >+ // To be called when speech is no longer detected. >+ WEBKIT_EXPORT void didEndSpeech(); >+ >+ // To be called when sound is no longer detected. >+ // This is expected to be called after didEndSpeech. >+ WEBKIT_EXPORT void didEndSound(); >+ >+ // To be called when audio capture has stopped. >+ // This is expected to be called after didEndSound. >+ WEBKIT_EXPORT void didEndAudio(); >+ >+ // To be called when the speech recognizer returns a result. >+ WEBKIT_EXPORT void didReceiveResult(const WebSpeechRecognitionResult&, unsigned long resultIndex, const WebVector<WebSpeechRecognitionResult>& resultHistory); >+ >+ // To be called when the speech recognizer returns a final result with no >+ // recognizion hypothesis. >+ WEBKIT_EXPORT void didReceiveNoMatch(const WebSpeechRecognitionResult&); >+ >+ // To be called when the recognizer needs to delete one of the previously >+ // returned interim results. >+ WEBKIT_EXPORT void didDeleteResult(unsigned resultIndex, const WebVector<WebSpeechRecognitionResult>& resultHistory); >+ >+ // To be called when a speech recognition error occurs. >+ // FIXME: Introduce an enum for the error code. >+ WEBKIT_EXPORT void didReceiveError(const WebString& message, unsigned short code); >+ >+ // To be called when the recognizer has begun to listen to the audio with >+ // the intention of recognizing. >+ WEBKIT_EXPORT void didStart(); >+ >+ // To be called when the recognition session has ended. This must always be >+ // called, no matter the reason for the end. >+ WEBKIT_EXPORT void didEnd(); >+ >+#if WEBKIT_IMPLEMENTATION >+ WebSpeechRecognizerClient(const WTF::PassRefPtr<WebCore::SpeechRecognition>&); >+ WebSpeechRecognizerClient& operator=(const WTF::PassRefPtr<WebCore::SpeechRecognition>&); >+ operator WTF::PassRefPtr<WebCore::SpeechRecognition>() const; >+#endif >+ >+private: >+ WebPrivatePtr<WebCore::SpeechRecognition> m_private; >+}; >+ >+inline bool operator==(const WebSpeechRecognizerClient& a, const WebSpeechRecognizerClient& b) >+{ >+ return a.equals(b); >+} >+ >+inline bool operator!=(const WebSpeechRecognizerClient& a, const WebSpeechRecognizerClient& b) >+{ >+ return !(a == b); >+} >+ >+inline bool operator<(const WebSpeechRecognizerClient& a, const WebSpeechRecognizerClient& b) >+{ >+ return a.lessThan(b); >+} >+ >+} // namespace WebKit >+ >+#endif // SpeechRecognizerClient_h >diff --git a/Source/WebKit/chromium/public/WebViewClient.h b/Source/WebKit/chromium/public/WebViewClient.h >index f29033c7238005c5ed72dac31b8189aad4833817..b8fe9d0c5f615361921c7105aa0e00509d2c66b9 100644 >--- a/Source/WebKit/chromium/public/WebViewClient.h >+++ b/Source/WebKit/chromium/public/WebViewClient.h >@@ -68,6 +68,7 @@ class WebNotificationPresenter; > class WebRange; > class WebSpeechInputController; > class WebSpeechInputListener; >+class WebSpeechRecognizer; > class WebStorageNamespace; > class WebURL; > class WebURLRequest; >@@ -316,6 +317,9 @@ public: > virtual WebSpeechInputController* speechInputController( > WebSpeechInputListener*) { return 0; } > >+ // Access the embedder API for speech recognition services. >+ virtual WebSpeechRecognizer* speechRecognizer() { return 0; } >+ > // Device Orientation -------------------------------------------------- > > // Access the embedder API for device orientation services. >diff --git a/Source/WebKit/chromium/src/SpeechRecognitionClientProxy.cpp b/Source/WebKit/chromium/src/SpeechRecognitionClientProxy.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..1c58187cb823790ed55c1e75076bc0c15d8f6e37 >--- /dev/null >+++ b/Source/WebKit/chromium/src/SpeechRecognitionClientProxy.cpp >@@ -0,0 +1,75 @@ >+/* >+ * Copyright (C) 2012 Google 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: >+ * * Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * * 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 THE COPYRIGHT HOLDERS ``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 THE COPYRIGHT OWNER 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 "SpeechRecognitionClientProxy.h" >+ >+#include "SpeechGrammarList.h" >+#include "SpeechRecognition.h" >+#include "WebSpeechGrammar.h" >+#include "WebSpeechRecognitionParams.h" >+#include "WebSpeechRecognizer.h" >+#include "WebSpeechRecognizerClient.h" >+#include <wtf/PassOwnPtr.h> >+#include <wtf/PassRefPtr.h> >+ >+using namespace WebCore; >+ >+namespace WebKit { >+ >+SpeechRecognitionClientProxy::~SpeechRecognitionClientProxy() >+{ >+} >+ >+PassOwnPtr<SpeechRecognitionClientProxy> SpeechRecognitionClientProxy::create(WebSpeechRecognizer* recognizer) >+{ >+ return adoptPtr(new SpeechRecognitionClientProxy(recognizer)); >+} >+ >+void SpeechRecognitionClientProxy::start(SpeechRecognition* recognition, const SpeechGrammarList* grammarList, const String& lang, bool continuous) >+{ >+ WebVector<WebSpeechGrammar> webSpeechGrammars(grammarList->length()); >+ for (unsigned long i = 0; i < grammarList->length(); ++i) >+ webSpeechGrammars[i] = grammarList->item(i); >+ >+ m_recognizer->start(WebSpeechRecognitionParams(webSpeechGrammars, lang, continuous), WebSpeechRecognizerClient(recognition)); >+} >+ >+void SpeechRecognitionClientProxy::stop(SpeechRecognition* recognition) >+{ >+ m_recognizer->stop(WebSpeechRecognizerClient(recognition)); >+} >+ >+void SpeechRecognitionClientProxy::abort(SpeechRecognition* recognition) >+{ >+ m_recognizer->abort(WebSpeechRecognizerClient(recognition)); >+} >+ >+SpeechRecognitionClientProxy::SpeechRecognitionClientProxy(WebSpeechRecognizer* recognizer) >+ : m_recognizer(recognizer) >+{ >+} >+ >+} // namespace WebKit >diff --git a/Source/WebKit/chromium/src/SpeechRecognitionClientProxy.h b/Source/WebKit/chromium/src/SpeechRecognitionClientProxy.h >new file mode 100644 >index 0000000000000000000000000000000000000000..cfb3a1055328fcb98166bcdad88a5b6b905fb273 >--- /dev/null >+++ b/Source/WebKit/chromium/src/SpeechRecognitionClientProxy.h >@@ -0,0 +1,60 @@ >+/* >+ * Copyright (C) 2012 Google 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: >+ * * Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * * 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 THE COPYRIGHT HOLDERS ``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 THE COPYRIGHT OWNER 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. >+ */ >+ >+#ifndef SpeechRecognitionClientProxy_h >+#define SpeechRecognitionClientProxy_h >+ >+#include "PlatformString.h" >+#include "SpeechRecognitionClient.h" >+#include <wtf/Compiler.h> >+#include <wtf/PassOwnPtr.h> >+ >+namespace WebKit { >+ >+class WebSpeechRecognizer; >+class WebString; >+ >+class SpeechRecognitionClientProxy : public WebCore::SpeechRecognitionClient { >+public: >+ ~SpeechRecognitionClientProxy(); >+ >+ // Constructing a proxy object with a 0 WebSpeechRecognizer is safe in >+ // itself, but attempting to call start/stop/abort on it will crash. >+ static PassOwnPtr<SpeechRecognitionClientProxy> create(WebSpeechRecognizer*); >+ >+ // WebCore::SpeechRecognitionClient: >+ virtual void start(WebCore::SpeechRecognition*, const WebCore::SpeechGrammarList*, const String& lang, bool continuous) OVERRIDE; >+ virtual void stop(WebCore::SpeechRecognition*) OVERRIDE; >+ virtual void abort(WebCore::SpeechRecognition*) OVERRIDE; >+ >+private: >+ SpeechRecognitionClientProxy(WebSpeechRecognizer*); >+ >+ WebSpeechRecognizer* m_recognizer; >+}; >+ >+}; // namespace WebKit >+ >+#endif // SpeechRecognitionClientProxy_h >diff --git a/Source/WebKit/chromium/src/WebSpeechGrammar.cpp b/Source/WebKit/chromium/src/WebSpeechGrammar.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..2fccd40cbc1b4581d1ac664e0df430ad000935a6 >--- /dev/null >+++ b/Source/WebKit/chromium/src/WebSpeechGrammar.cpp >@@ -0,0 +1,62 @@ >+/* >+ * Copyright (C) 2012 Google 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 AND ITS CONTRIBUTORS "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 OR ITS 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 "WebSpeechGrammar.h" >+ >+#include "SpeechGrammar.h" >+#include <wtf/PassRefPtr.h> >+ >+namespace WebKit { >+ >+void WebSpeechGrammar::reset() >+{ >+ m_private.reset(); >+} >+ >+WebSpeechGrammar::WebSpeechGrammar(const PassRefPtr<WebCore::SpeechGrammar>& value) >+ : m_private(value) >+{ >+} >+ >+WebSpeechGrammar& WebSpeechGrammar::operator=(const WTF::PassRefPtr<WebCore::SpeechGrammar>& value) >+{ >+ m_private = value; >+ return *this; >+} >+ >+WebURL WebSpeechGrammar::src() const >+{ >+ WEBKIT_ASSERT(m_private.get()); >+ return m_private->src(); >+} >+ >+float WebSpeechGrammar::weight() const >+{ >+ WEBKIT_ASSERT(m_private.get()); >+ return m_private->weight(); >+} >+ >+} // namespace WebKit >diff --git a/Source/WebKit/chromium/src/WebSpeechRecognitionParams.cpp b/Source/WebKit/chromium/src/WebSpeechRecognitionParams.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..c9dd4586f4ad65756051afa15e84c58f55ff1eec >--- /dev/null >+++ b/Source/WebKit/chromium/src/WebSpeechRecognitionParams.cpp >@@ -0,0 +1,38 @@ >+/* >+ * Copyright (C) 2012 Google 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 AND ITS CONTRIBUTORS "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 OR ITS 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 "WebSpeechRecognitionParams.h" >+ >+namespace WebKit { >+ >+WebSpeechRecognitionParams::WebSpeechRecognitionParams(const WebVector<WebSpeechGrammar>& grammars, const WebString& language, bool continuous) >+ : m_grammars(grammars) >+ , m_language(language) >+ , m_continuous(continuous) >+{ >+} >+ >+} // namespace WebKit >diff --git a/Source/WebKit/chromium/src/WebSpeechRecognitionResult.cpp b/Source/WebKit/chromium/src/WebSpeechRecognitionResult.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..807f9563662684fc6319cfe220821d3c63ea8bc9 >--- /dev/null >+++ b/Source/WebKit/chromium/src/WebSpeechRecognitionResult.cpp >@@ -0,0 +1,62 @@ >+/* >+ * Copyright (C) 2012 Google 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 AND ITS CONTRIBUTORS "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 OR ITS 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 "WebSpeechRecognitionResult.h" >+ >+#include "SpeechRecognitionAlternative.h" >+#include "SpeechRecognitionResult.h" >+#include <wtf/PassRefPtr.h> >+#include <wtf/Vector.h> >+ >+namespace WebKit { >+ >+void WebSpeechRecognitionResult::assign(const WebSpeechRecognitionResult& other) >+{ >+ m_private = other.m_private; >+} >+ >+void WebSpeechRecognitionResult::assign(const WebVector<WebString>& transcripts, const WebVector<float>& confidences, bool final) >+{ >+ ASSERT(transcripts.size() == confidences.size()); >+ >+ Vector<RefPtr<WebCore::SpeechRecognitionAlternative> > alternatives(transcripts.size()); >+ for (size_t i = 0; i < transcripts.size(); ++i) >+ alternatives.append(WebCore::SpeechRecognitionAlternative::create(transcripts[i], confidences[i])); >+ >+ m_private = WebCore::SpeechRecognitionResult::create(alternatives, final); >+} >+ >+void WebSpeechRecognitionResult::reset() >+{ >+ m_private.reset(); >+} >+ >+WebSpeechRecognitionResult::operator PassRefPtr<WebCore::SpeechRecognitionResult>() const >+{ >+ return m_private.get(); >+} >+ >+} // namespace WebKit >diff --git a/Source/WebKit/chromium/src/WebSpeechRecognizerClient.cpp b/Source/WebKit/chromium/src/WebSpeechRecognizerClient.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..295f45ec54c3ae08870aedf22ec83f613806760c >--- /dev/null >+++ b/Source/WebKit/chromium/src/WebSpeechRecognizerClient.cpp >@@ -0,0 +1,144 @@ >+/* >+ * Copyright (C) 2012 Google 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 AND ITS CONTRIBUTORS "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 OR ITS 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 "WebSpeechRecognizerClient.h" >+ >+#include "SpeechRecognition.h" >+#include "SpeechRecognitionError.h" >+#include "SpeechRecognitionResult.h" >+#include "SpeechRecognitionResultList.h" >+#include "WebSpeechRecognitionResult.h" >+ >+using namespace WebCore; >+ >+namespace WebKit { >+ >+void WebSpeechRecognizerClient::reset() >+{ >+ m_private.reset(); >+} >+ >+void WebSpeechRecognizerClient::assign(const WebSpeechRecognizerClient& other) >+{ >+ m_private = other.m_private; >+} >+ >+bool WebSpeechRecognizerClient::equals(const WebSpeechRecognizerClient& other) const >+{ >+ return (m_private.get() == other.m_private.get()); >+} >+ >+bool WebSpeechRecognizerClient::lessThan(const WebSpeechRecognizerClient& other) const >+{ >+ return (m_private.get() < other.m_private.get()); >+} >+ >+void WebSpeechRecognizerClient::didStartAudio() >+{ >+ m_private->didStartAudio(); >+} >+ >+void WebSpeechRecognizerClient::didStartSound() >+{ >+ m_private->didStartSound(); >+} >+ >+void WebSpeechRecognizerClient::didStartSpeech() >+{ >+ m_private->didStartSpeech(); >+} >+ >+void WebSpeechRecognizerClient::didEndSpeech() >+{ >+ m_private->didEndSpeech(); >+} >+ >+void WebSpeechRecognizerClient::didEndSound() >+{ >+ m_private->didEndSound(); >+} >+ >+void WebSpeechRecognizerClient::didEndAudio() >+{ >+ m_private->didEndAudio(); >+} >+ >+void WebSpeechRecognizerClient::didReceiveResult(const WebSpeechRecognitionResult& result, unsigned long resultIndex, const WebVector<WebSpeechRecognitionResult>& resultHistory) >+{ >+ Vector<RefPtr<SpeechRecognitionResult> > resultHistoryVector(resultHistory.size()); >+ for (size_t i = 0; i < resultHistory.size(); ++i) >+ resultHistoryVector.append(static_cast<PassRefPtr<SpeechRecognitionResult> >(resultHistory[i])); >+ >+ m_private->didReceiveResult(result, resultIndex, SpeechRecognitionResultList::create(resultHistoryVector)); >+} >+ >+void WebSpeechRecognizerClient::didReceiveNoMatch(const WebSpeechRecognitionResult& result) >+{ >+ m_private->didReceiveNoMatch(result); >+} >+ >+void WebSpeechRecognizerClient::didDeleteResult(unsigned resultIndex, const WebVector<WebSpeechRecognitionResult>& resultHistory) >+{ >+ Vector<RefPtr<SpeechRecognitionResult> > resultHistoryVector(resultHistory.size()); >+ for (size_t i = 0; i < resultHistory.size(); ++i) >+ resultHistoryVector.append(static_cast<PassRefPtr<SpeechRecognitionResult> >(resultHistory[i])); >+ >+ m_private->didDeleteResult(resultIndex, SpeechRecognitionResultList::create(resultHistoryVector)); >+} >+ >+void WebSpeechRecognizerClient::didReceiveError(const WebString& message, unsigned short code) >+{ >+ SpeechRecognitionError::Code errorCode = static_cast<SpeechRecognitionError::Code>(code); >+ m_private->didReceiveError(SpeechRecognitionError::create(errorCode, message)); >+} >+ >+void WebSpeechRecognizerClient::didStart() >+{ >+ m_private->didStart(); >+} >+ >+void WebSpeechRecognizerClient::didEnd() >+{ >+ m_private->didEnd(); >+} >+ >+WebSpeechRecognizerClient::WebSpeechRecognizerClient(const PassRefPtr<SpeechRecognition>& speechRecognition) >+ : m_private(speechRecognition) >+{ >+} >+ >+WebSpeechRecognizerClient& WebSpeechRecognizerClient::operator=(const PassRefPtr<SpeechRecognition>& speechRecognition) >+{ >+ m_private = speechRecognition; >+ return *this; >+} >+ >+WebSpeechRecognizerClient::operator PassRefPtr<SpeechRecognition>() const >+{ >+ return m_private.get(); >+} >+ >+} // namespace WebKit >diff --git a/Source/WebKit/chromium/src/WebViewImpl.cpp b/Source/WebKit/chromium/src/WebViewImpl.cpp >index 1b3ab589d6f7c4e7abdc111449d27a81bef23125..d59393b39c32dd8c39dd1793f3c0dffd5a9d89de 100644 >--- a/Source/WebKit/chromium/src/WebViewImpl.cpp >+++ b/Source/WebKit/chromium/src/WebViewImpl.cpp >@@ -106,7 +106,7 @@ > #include "Settings.h" > #include "SharedGraphicsContext3D.h" > #include "SpeechInputClientImpl.h" >-#include "SpeechRecognitionClient.h" >+#include "SpeechRecognitionClientProxy.h" > #include "TextIterator.h" > #include "Timer.h" > #include "TouchpadFlingPlatformGestureCurve.h" >@@ -363,6 +363,9 @@ WebViewImpl::WebViewImpl(WebViewClient* client) > #if ENABLE(INPUT_SPEECH) > , m_speechInputClient(SpeechInputClientImpl::create(client)) > #endif >+#if ENABLE(SCRIPTED_SPEECH) >+ , m_speechRecognitionClient(SpeechRecognitionClientProxy::create(client ? client->speechRecognizer() : 0)) >+#endif > , m_deviceOrientationClientProxy(adoptPtr(new DeviceOrientationClientProxy(client ? client->deviceOrientationClient() : 0))) > , m_geolocationClientProxy(adoptPtr(new GeolocationClientProxy(client ? client->geolocationClient() : 0))) > #if ENABLE(MEDIA_STREAM) >@@ -396,7 +399,7 @@ WebViewImpl::WebViewImpl(WebViewClient* client) > provideSpeechInputTo(m_page.get(), m_speechInputClient.get()); > #endif > #if ENABLE(SCRIPTED_SPEECH) >- provideSpeechRecognitionTo(m_page.get(), 0); // FIXME: Provide a real implementation. >+ provideSpeechRecognitionTo(m_page.get(), m_speechRecognitionClient.get()); > #endif > #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) > provideNotification(m_page.get(), notificationPresenterImpl()); >diff --git a/Source/WebKit/chromium/src/WebViewImpl.h b/Source/WebKit/chromium/src/WebViewImpl.h >index 3082d4e0135afedba2530894ce6003be42b851ad..5323c317015ca047af54e8b4caf54a1f59955bf9 100644 >--- a/Source/WebKit/chromium/src/WebViewImpl.h >+++ b/Source/WebKit/chromium/src/WebViewImpl.h >@@ -85,6 +85,7 @@ class DragScrollTimer; > class GeolocationClientProxy; > class NonCompositedContentHost; > class SpeechInputClientImpl; >+class SpeechRecognitionClientProxy; > class UserMediaClientImpl; > class WebAccessibilityObject; > class WebCompositorImpl; >@@ -718,6 +719,10 @@ private: > #if ENABLE(INPUT_SPEECH) > OwnPtr<SpeechInputClientImpl> m_speechInputClient; > #endif >+#if ENABLE(SCRIPTED_SPEECH) >+ OwnPtr<SpeechRecognitionClientProxy> m_speechRecognitionClient; >+#endif >+ > // If we attempt to fetch the on-screen GraphicsContext3D before > // the compositor has been turned on, we need to instantiate it > // early. This member holds on to the GC3D in this case.
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 81667
:
132832
|
133043
|
133484
|
133811
|
134578
|
134803
|
135084
|
135316