Index: Source/modules/speech/SpeechRecognitionController.cpp |
diff --git a/Source/modules/speech/SpeechRecognitionController.cpp b/Source/modules/speech/SpeechRecognitionController.cpp |
index da0b9df469adc681ead27e1d29eeac50a137b43e..e8295803dcc9f58ba1a603d267155be3a854fe6e 100644 |
--- a/Source/modules/speech/SpeechRecognitionController.cpp |
+++ b/Source/modules/speech/SpeechRecognitionController.cpp |
@@ -33,8 +33,9 @@ const char* SpeechRecognitionController::supplementName() |
return "SpeechRecognitionController"; |
} |
-SpeechRecognitionController::SpeechRecognitionController(PassOwnPtr<SpeechRecognitionClient> client) |
- : m_client(client) |
+SpeechRecognitionController::SpeechRecognitionController(Page* page, PassOwnPtr<SpeechRecognitionClient> client) |
+ : PageLifecycleObserver(page) |
+ , m_client(client) |
{ |
} |
@@ -43,14 +44,49 @@ SpeechRecognitionController::~SpeechRecognitionController() |
// FIXME: Call m_client->pageDestroyed(); once we have implemented a client. |
} |
-PassOwnPtrWillBeRawPtr<SpeechRecognitionController> SpeechRecognitionController::create(PassOwnPtr<SpeechRecognitionClient> client) |
+DEFINE_TRACE(SpeechRecognitionController) |
{ |
- return adoptPtrWillBeNoop(new SpeechRecognitionController(client)); |
+ WillBeHeapSupplement<Page>::trace(visitor); |
+ PageLifecycleObserver::trace(visitor); |
+} |
+ |
+PassOwnPtrWillBeRawPtr<SpeechRecognitionController> SpeechRecognitionController::create(Page* page, PassOwnPtr<SpeechRecognitionClient> client) |
+{ |
+return adoptPtrWillBeNoop(new SpeechRecognitionController(page, client)); |
+} |
+ |
+SpeechRecognitionController* SpeechRecognitionController::from(Page* page) |
+{ |
+ return static_cast<SpeechRecognitionController*>(WillBeHeapSupplement<Page>::from(page, supplementName())); |
} |
void provideSpeechRecognitionTo(Page& page, PassOwnPtr<SpeechRecognitionClient> client) |
{ |
- SpeechRecognitionController::provideTo(page, SpeechRecognitionController::supplementName(), SpeechRecognitionController::create(client)); |
+ SpeechRecognitionController::provideTo(page, SpeechRecognitionController::supplementName(), SpeechRecognitionController::create(&page, client)); |
+} |
+ |
+void SpeechRecognitionController::start(SpeechRecognition* recognition, const SpeechGrammarList* grammars, const String& lang, bool continuous, bool interimResults, unsigned long maxAlternatives, MediaStreamTrack* audioTrack) |
+{ |
+ if (!page()) |
+ return; |
+ |
+ m_client->start(recognition, grammars, lang, continuous, interimResults, maxAlternatives, audioTrack); |
+} |
+ |
+void SpeechRecognitionController::stop(SpeechRecognition* recognition) |
+{ |
+ if (!page()) |
+ return; |
+ |
+ m_client->stop(recognition); |
+} |
+ |
+void SpeechRecognitionController::abort(SpeechRecognition* recognition) |
+{ |
+ if (!page()) |
+ return; |
+ |
+ m_client->abort(recognition); |
} |
} // namespace blink |