summaryrefslogtreecommitdiff
path: root/Source/WebCore/Modules/speech
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-05-07 11:21:11 +0200
committerSimon Hausmann <simon.hausmann@nokia.com>2012-05-07 11:21:11 +0200
commit2cf6c8816a73e0132bd8fa3b509d62d7c51b6e47 (patch)
tree988e8c5b116dd0466244ae2fe5af8ee9be926d76 /Source/WebCore/Modules/speech
parentdd91e772430dc294e3bf478c119ef8d43c0a3358 (diff)
downloadqtwebkit-2cf6c8816a73e0132bd8fa3b509d62d7c51b6e47.tar.gz
Imported WebKit commit 7e538425aa020340619e927792f3d895061fb54b (http://svn.webkit.org/repository/webkit/trunk@116286)
Diffstat (limited to 'Source/WebCore/Modules/speech')
-rw-r--r--Source/WebCore/Modules/speech/DOMWindowSpeech.idl1
-rw-r--r--Source/WebCore/Modules/speech/SpeechGrammar.h1
-rw-r--r--Source/WebCore/Modules/speech/SpeechRecognition.cpp160
-rw-r--r--Source/WebCore/Modules/speech/SpeechRecognition.h125
-rw-r--r--Source/WebCore/Modules/speech/SpeechRecognition.idl65
-rw-r--r--Source/WebCore/Modules/speech/SpeechRecognitionClient.h54
-rw-r--r--Source/WebCore/Modules/speech/SpeechRecognitionController.cpp61
-rw-r--r--Source/WebCore/Modules/speech/SpeechRecognitionController.h59
8 files changed, 526 insertions, 0 deletions
diff --git a/Source/WebCore/Modules/speech/DOMWindowSpeech.idl b/Source/WebCore/Modules/speech/DOMWindowSpeech.idl
index 70200b1be..0c26f03d7 100644
--- a/Source/WebCore/Modules/speech/DOMWindowSpeech.idl
+++ b/Source/WebCore/Modules/speech/DOMWindowSpeech.idl
@@ -28,6 +28,7 @@ module window {
Conditional=SCRIPTED_SPEECH,
Supplemental=DOMWindow
] DOMWindowSpeech {
+ attribute [V8EnabledAtRuntime] SpeechRecognitionConstructor webkitSpeechRecognition;
attribute [V8EnabledAtRuntime] SpeechRecognitionErrorConstructor webkitSpeechRecognitionError;
attribute [V8EnabledAtRuntime] SpeechRecognitionEventConstructor webkitSpeechRecognitionEvent;
attribute [V8EnabledAtRuntime] SpeechGrammarConstructor webkitSpeechGrammar;
diff --git a/Source/WebCore/Modules/speech/SpeechGrammar.h b/Source/WebCore/Modules/speech/SpeechGrammar.h
index 62088c18b..e08358bbf 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
new file mode 100644
index 000000000..2a7669e96
--- /dev/null
+++ b/Source/WebCore/Modules/speech/SpeechRecognition.cpp
@@ -0,0 +1,160 @@
+/*
+ * 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"
+
+#if ENABLE(SCRIPTED_SPEECH)
+
+#include "SpeechRecognition.h"
+
+#include "Document.h"
+#include "Page.h"
+#include "SpeechRecognitionController.h"
+#include "SpeechRecognitionError.h"
+#include "SpeechRecognitionEvent.h"
+
+namespace WebCore {
+
+PassRefPtr<SpeechRecognition> SpeechRecognition::create(ScriptExecutionContext* context)
+{
+ RefPtr<SpeechRecognition> speechRecognition(adoptRef(new SpeechRecognition(context)));
+ speechRecognition->suspendIfNeeded();
+ return speechRecognition.release();
+}
+
+void SpeechRecognition::start()
+{
+ ASSERT(m_controller); // FIXME: Spec should say what to do if we are already started.
+ m_controller->start(this, m_grammars.get(), m_lang, m_continuous);
+}
+
+void SpeechRecognition::stopFunction()
+{
+ ASSERT(m_controller);
+ m_controller->stop(this); // FIXME: Spec should say what to do if we are not started.
+}
+
+void SpeechRecognition::abort()
+{
+ ASSERT(m_controller);
+ m_controller->abort(this); // FIXME: Spec should say what to do if we are not started.
+}
+
+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::didStartSound()
+{
+ dispatchEvent(Event::create(eventNames().soundstartEvent, /*canBubble=*/false, /*cancelable=*/false));
+}
+
+void SpeechRecognition::didStartSpeech()
+{
+ dispatchEvent(Event::create(eventNames().speechstartEvent, /*canBubble=*/false, /*cancelable=*/false));
+}
+
+void SpeechRecognition::didEndSpeech()
+{
+ dispatchEvent(Event::create(eventNames().speechendEvent, /*canBubble=*/false, /*cancelable=*/false));
+}
+
+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::didReceiveResult(PassRefPtr<SpeechRecognitionResult> result, unsigned long resultIndex, PassRefPtr<SpeechRecognitionResultList> resultHistory)
+{
+ dispatchEvent(SpeechRecognitionEvent::createResult(result, resultIndex, resultHistory));
+}
+
+void SpeechRecognition::didReceiveNoMatch(PassRefPtr<SpeechRecognitionResult> result)
+{
+ dispatchEvent(SpeechRecognitionEvent::createNoMatch(result));
+}
+
+void SpeechRecognition::didDeleteResult(unsigned resultIndex, PassRefPtr<SpeechRecognitionResultList> resultHistory)
+{
+ dispatchEvent(SpeechRecognitionEvent::createResultDeleted(resultIndex, resultHistory));
+}
+
+void SpeechRecognition::didReceiveError(PassRefPtr<SpeechRecognitionError> error)
+{
+ dispatchEvent(SpeechRecognitionEvent::createError(error));
+}
+
+void SpeechRecognition::didStart()
+{
+ dispatchEvent(Event::create(eventNames().startEvent, /*canBubble=*/false, /*cancelable=*/false));
+}
+
+void SpeechRecognition::didEnd()
+{
+ dispatchEvent(Event::create(eventNames().endEvent, /*canBubble=*/false, /*cancelable=*/false));
+}
+
+const AtomicString& SpeechRecognition::interfaceName() const
+{
+ return eventNames().interfaceForSpeechRecognition;
+}
+
+ScriptExecutionContext* SpeechRecognition::scriptExecutionContext() const
+{
+ return ActiveDOMObject::scriptExecutionContext();
+}
+
+SpeechRecognition::SpeechRecognition(ScriptExecutionContext* context)
+ : ActiveDOMObject(context, this)
+ , m_grammars(SpeechGrammarList::create()) // FIXME: The spec is not clear on the default value for the grammars attribute.
+ , m_continuous(false)
+ , m_controller(0)
+{
+ ASSERT(scriptExecutionContext()->isDocument());
+ Document* document = static_cast<Document*>(scriptExecutionContext());
+
+ Page* page = document->page();
+ ASSERT(page);
+
+ m_controller = SpeechRecognitionController::from(page);
+ ASSERT(m_controller);
+
+ // FIXME: Need to hook up with Page to get notified when the visibility changes.
+}
+
+SpeechRecognition::~SpeechRecognition()
+{
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SCRIPTED_SPEECH)
diff --git a/Source/WebCore/Modules/speech/SpeechRecognition.h b/Source/WebCore/Modules/speech/SpeechRecognition.h
new file mode 100644
index 000000000..3fc244166
--- /dev/null
+++ b/Source/WebCore/Modules/speech/SpeechRecognition.h
@@ -0,0 +1,125 @@
+/*
+ * 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 SpeechRecognition_h
+#define SpeechRecognition_h
+
+#if ENABLE(SCRIPTED_SPEECH)
+
+#include "ActiveDOMObject.h"
+#include "EventTarget.h"
+#include "PlatformString.h"
+#include "SpeechGrammarList.h"
+#include <wtf/Compiler.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+class ScriptExecutionContext;
+class SpeechRecognitionController;
+class SpeechRecognitionError;
+class SpeechRecognitionResult;
+class SpeechRecognitionResultList;
+
+class SpeechRecognition : public RefCounted<SpeechRecognition>, public ActiveDOMObject, public EventTarget {
+public:
+ static PassRefPtr<SpeechRecognition> create(ScriptExecutionContext*);
+ ~SpeechRecognition();
+
+ PassRefPtr<SpeechGrammarList> grammars() { return m_grammars; }
+ void setGrammars(PassRefPtr<SpeechGrammarList> grammars) { m_grammars = grammars; }
+
+ String lang() { return m_lang; }
+ void setLang(const String& lang) { m_lang = lang; }
+
+ bool continuous() { return m_continuous; }
+ void setContinuous(bool continuous) { m_continuous = continuous; }
+
+ // Callable by the user.
+ void start();
+ void stopFunction();
+ void abort();
+
+ // Called by the SpeechRecognitionClient.
+ 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;
+ virtual ScriptExecutionContext* scriptExecutionContext() const OVERRIDE;
+
+ using RefCounted<SpeechRecognition>::ref;
+ using RefCounted<SpeechRecognition>::deref;
+
+ DEFINE_ATTRIBUTE_EVENT_LISTENER(audiostart);
+ DEFINE_ATTRIBUTE_EVENT_LISTENER(soundstart);
+ DEFINE_ATTRIBUTE_EVENT_LISTENER(speechstart);
+ DEFINE_ATTRIBUTE_EVENT_LISTENER(speechend);
+ DEFINE_ATTRIBUTE_EVENT_LISTENER(soundend);
+ DEFINE_ATTRIBUTE_EVENT_LISTENER(audioend);
+ DEFINE_ATTRIBUTE_EVENT_LISTENER(result);
+ DEFINE_ATTRIBUTE_EVENT_LISTENER(nomatch);
+ DEFINE_ATTRIBUTE_EVENT_LISTENER(resultdeleted);
+ DEFINE_ATTRIBUTE_EVENT_LISTENER(error);
+ DEFINE_ATTRIBUTE_EVENT_LISTENER(start);
+ DEFINE_ATTRIBUTE_EVENT_LISTENER(end);
+
+private:
+ friend class RefCounted<SpeechRecognition>;
+
+ SpeechRecognition(ScriptExecutionContext*);
+
+
+ // EventTarget
+ virtual void refEventTarget() OVERRIDE { ref(); }
+ virtual void derefEventTarget() OVERRIDE { deref(); }
+ virtual EventTargetData* eventTargetData() OVERRIDE { return &m_eventTargetData; }
+ virtual EventTargetData* ensureEventTargetData() OVERRIDE { return &m_eventTargetData; }
+
+ RefPtr<SpeechGrammarList> m_grammars;
+ String m_lang;
+ bool m_continuous;
+
+ EventTargetData m_eventTargetData;
+
+ SpeechRecognitionController* m_controller;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(SCRIPTED_SPEECH)
+
+#endif // SpeechRecognition_h
diff --git a/Source/WebCore/Modules/speech/SpeechRecognition.idl b/Source/WebCore/Modules/speech/SpeechRecognition.idl
new file mode 100644
index 000000000..5fea70d27
--- /dev/null
+++ b/Source/WebCore/Modules/speech/SpeechRecognition.idl
@@ -0,0 +1,65 @@
+/*
+ * 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.
+ */
+
+module core {
+ interface [
+ Conditional=SCRIPTED_SPEECH,
+ ActiveDOMObject,
+ Constructor,
+ CallWith=ScriptExecutionContext,
+ EventTarget,
+ ] SpeechRecognition {
+ attribute SpeechGrammarList grammars;
+ attribute DOMString lang;
+ attribute boolean continuous;
+
+ void start();
+ [ImplementedAs=stopFunction] void stop();
+ void abort();
+
+ attribute EventListener onaudiostart;
+ attribute EventListener onsoundstart;
+ attribute EventListener onspeechstart;
+ attribute EventListener onspeechend;
+ attribute EventListener onsoundend;
+ attribute EventListener onaudioend;
+ attribute EventListener onresult;
+ attribute EventListener onnomatch;
+ attribute EventListener onresultdeleted;
+ attribute EventListener onerror;
+ attribute EventListener onstart;
+ attribute EventListener onend;
+
+ // EventTarget interface
+ void addEventListener(in DOMString type,
+ in EventListener listener,
+ in [Optional] boolean useCapture);
+ void removeEventListener(in DOMString type,
+ in EventListener listener,
+ in [Optional] boolean useCapture);
+ boolean dispatchEvent(in Event evt)
+ raises(EventException);
+ };
+}
diff --git a/Source/WebCore/Modules/speech/SpeechRecognitionClient.h b/Source/WebCore/Modules/speech/SpeechRecognitionClient.h
new file mode 100644
index 000000000..29bb9f66b
--- /dev/null
+++ b/Source/WebCore/Modules/speech/SpeechRecognitionClient.h
@@ -0,0 +1,54 @@
+/*
+ * 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 SpeechRecognitionClient_h
+#define SpeechRecognitionClient_h
+
+#if ENABLE(SCRIPTED_SPEECH)
+
+#include "PlatformString.h"
+
+namespace WebCore {
+
+class Page;
+class SpeechGrammarList;
+class SpeechRecognition;
+
+class SpeechRecognitionClient {
+public:
+ virtual void start(SpeechRecognition*, const SpeechGrammarList*, const String& lang, bool continuous) = 0;
+ virtual void stop(SpeechRecognition*) = 0;
+ virtual void abort(SpeechRecognition*) = 0;
+
+ virtual ~SpeechRecognitionClient() { }
+};
+
+void provideSpeechRecognitionTo(Page*, SpeechRecognitionClient*);
+
+} // namespace WebCore
+
+#endif // ENABLE(SCRIPTED_SPEECH)
+
+#endif // SpeechRecognitionClient_h
diff --git a/Source/WebCore/Modules/speech/SpeechRecognitionController.cpp b/Source/WebCore/Modules/speech/SpeechRecognitionController.cpp
new file mode 100644
index 000000000..d4bcc85fe
--- /dev/null
+++ b/Source/WebCore/Modules/speech/SpeechRecognitionController.cpp
@@ -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.
+ */
+
+#include "config.h"
+#include "SpeechRecognitionController.h"
+
+#if ENABLE(SCRIPTED_SPEECH)
+
+namespace WebCore {
+
+const AtomicString& SpeechRecognitionController::supplementName()
+{
+ DEFINE_STATIC_LOCAL(AtomicString, name, ("SpeechRecognitionController"));
+ return name;
+}
+
+SpeechRecognitionController::SpeechRecognitionController(SpeechRecognitionClient* client)
+ : m_client(client)
+{
+}
+
+SpeechRecognitionController::~SpeechRecognitionController()
+{
+ // FIXME: Call m_client->pageDestroyed(); once we have implemented a client.
+}
+
+PassOwnPtr<SpeechRecognitionController> SpeechRecognitionController::create(SpeechRecognitionClient* client)
+{
+ return adoptPtr(new SpeechRecognitionController(client));
+}
+
+void provideSpeechRecognitionTo(Page* page, SpeechRecognitionClient* client)
+{
+ SpeechRecognitionController::provideTo(page, SpeechRecognitionController::supplementName(), SpeechRecognitionController::create(client));
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SCRIPTED_SPEECH)
diff --git a/Source/WebCore/Modules/speech/SpeechRecognitionController.h b/Source/WebCore/Modules/speech/SpeechRecognitionController.h
new file mode 100644
index 000000000..50bc5a42f
--- /dev/null
+++ b/Source/WebCore/Modules/speech/SpeechRecognitionController.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:
+ * * 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 SpeechRecognitionController_h
+#define SpeechRecognitionController_h
+
+#if ENABLE(SCRIPTED_SPEECH)
+
+#include "Page.h"
+#include "SpeechRecognitionClient.h"
+#include <wtf/PassOwnPtr.h>
+
+namespace WebCore {
+
+class SpeechRecognitionController : public Supplement<Page> {
+public:
+ virtual ~SpeechRecognitionController();
+
+ 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); }
+
+ static PassOwnPtr<SpeechRecognitionController> create(SpeechRecognitionClient*);
+ static const AtomicString& supplementName();
+ static SpeechRecognitionController* from(Page* page) { return static_cast<SpeechRecognitionController*>(Supplement<Page>::from(page, supplementName())); }
+
+private:
+ SpeechRecognitionController(SpeechRecognitionClient*);
+
+ SpeechRecognitionClient* m_client;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(SCRIPTED_SPEECH)
+
+#endif // SpeechRecognitionController_h