| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google 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 * * Redistributions of source code must retain the above copyright | 7 * * 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 * * Redistributions in binary form must reproduce the above copyright | 9 * * 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 16 matching lines...) Expand all Loading... |
| 27 #include "web/SpeechRecognitionClientProxy.h" | 27 #include "web/SpeechRecognitionClientProxy.h" |
| 28 | 28 |
| 29 #include "core/dom/ExecutionContext.h" | 29 #include "core/dom/ExecutionContext.h" |
| 30 #include "modules/mediastream/MediaStreamTrack.h" | 30 #include "modules/mediastream/MediaStreamTrack.h" |
| 31 #include "modules/speech/SpeechGrammarList.h" | 31 #include "modules/speech/SpeechGrammarList.h" |
| 32 #include "modules/speech/SpeechRecognition.h" | 32 #include "modules/speech/SpeechRecognition.h" |
| 33 #include "modules/speech/SpeechRecognitionError.h" | 33 #include "modules/speech/SpeechRecognitionError.h" |
| 34 #include "modules/speech/SpeechRecognitionResult.h" | 34 #include "modules/speech/SpeechRecognitionResult.h" |
| 35 #include "modules/speech/SpeechRecognitionResultList.h" | 35 #include "modules/speech/SpeechRecognitionResultList.h" |
| 36 #include "platform/RuntimeEnabledFeatures.h" | 36 #include "platform/RuntimeEnabledFeatures.h" |
| 37 #include "platform/weborigin/KURL.h" | |
| 38 #include "platform/weborigin/SecurityOrigin.h" | 37 #include "platform/weborigin/SecurityOrigin.h" |
| 39 #include "public/platform/WebMediaStreamTrack.h" | 38 #include "public/platform/WebMediaStreamTrack.h" |
| 40 #include "public/web/WebSecurityOrigin.h" | 39 #include "public/web/WebSecurityOrigin.h" |
| 41 #include "public/web/WebSpeechGrammar.h" | 40 #include "public/web/WebSpeechGrammar.h" |
| 42 #include "public/web/WebSpeechRecognitionHandle.h" | 41 #include "public/web/WebSpeechRecognitionHandle.h" |
| 43 #include "public/web/WebSpeechRecognitionParams.h" | 42 #include "public/web/WebSpeechRecognitionParams.h" |
| 44 #include "public/web/WebSpeechRecognitionResult.h" | 43 #include "public/web/WebSpeechRecognitionResult.h" |
| 45 #include "public/web/WebSpeechRecognizer.h" | 44 #include "public/web/WebSpeechRecognizer.h" |
| 46 #include "wtf/PassRefPtr.h" | 45 #include "wtf/PassRefPtr.h" |
| 47 | 46 |
| 48 namespace blink { | 47 namespace blink { |
| 49 | 48 |
| 50 SpeechRecognitionClientProxy::~SpeechRecognitionClientProxy() | 49 SpeechRecognitionClientProxy::~SpeechRecognitionClientProxy() |
| 51 { | 50 { |
| 52 } | 51 } |
| 53 | 52 |
| 54 PassOwnPtr<SpeechRecognitionClientProxy> SpeechRecognitionClientProxy::create(We
bSpeechRecognizer* recognizer) | 53 PassOwnPtr<SpeechRecognitionClientProxy> SpeechRecognitionClientProxy::create(We
bSpeechRecognizer* recognizer) |
| 55 { | 54 { |
| 56 return adoptPtr(new SpeechRecognitionClientProxy(recognizer)); | 55 return adoptPtr(new SpeechRecognitionClientProxy(recognizer)); |
| 57 } | 56 } |
| 58 | 57 |
| 59 void SpeechRecognitionClientProxy::start(SpeechRecognition* recognition, const S
peechGrammarList* grammarList, const String& lang, const KURL& serviceURI, bool
continuous, bool interimResults, unsigned long maxAlternatives, MediaStreamTrack
* audioTrack) | 58 void SpeechRecognitionClientProxy::start(SpeechRecognition* recognition, const S
peechGrammarList* grammarList, const String& lang, bool continuous, bool interim
Results, unsigned long maxAlternatives, MediaStreamTrack* audioTrack) |
| 60 { | 59 { |
| 61 WebVector<WebSpeechGrammar> webSpeechGrammars(static_cast<size_t>(grammarLis
t->length())); | 60 WebVector<WebSpeechGrammar> webSpeechGrammars(static_cast<size_t>(grammarLis
t->length())); |
| 62 for (unsigned long i = 0; i < grammarList->length(); ++i) | 61 for (unsigned long i = 0; i < grammarList->length(); ++i) |
| 63 webSpeechGrammars[i] = grammarList->item(i); | 62 webSpeechGrammars[i] = grammarList->item(i); |
| 64 | 63 |
| 65 WebMediaStreamTrack track; | 64 WebMediaStreamTrack track; |
| 66 if (RuntimeEnabledFeatures::mediaStreamSpeechEnabled() && audioTrack) | 65 if (RuntimeEnabledFeatures::mediaStreamSpeechEnabled() && audioTrack) |
| 67 track.assign(audioTrack->component()); | 66 track.assign(audioTrack->component()); |
| 68 WebSpeechRecognitionParams params(webSpeechGrammars, lang, serviceURI, conti
nuous, interimResults, maxAlternatives, track, WebSecurityOrigin(recognition->ex
ecutionContext()->securityOrigin())); | 67 WebSpeechRecognitionParams params(webSpeechGrammars, lang, continuous, inter
imResults, maxAlternatives, track, WebSecurityOrigin(recognition->executionConte
xt()->securityOrigin())); |
| 69 m_recognizer->start(recognition, params, this); | 68 m_recognizer->start(recognition, params, this); |
| 70 } | 69 } |
| 71 | 70 |
| 72 void SpeechRecognitionClientProxy::stop(SpeechRecognition* recognition) | 71 void SpeechRecognitionClientProxy::stop(SpeechRecognition* recognition) |
| 73 { | 72 { |
| 74 m_recognizer->stop(recognition, this); | 73 m_recognizer->stop(recognition, this); |
| 75 } | 74 } |
| 76 | 75 |
| 77 void SpeechRecognitionClientProxy::abort(SpeechRecognition* recognition) | 76 void SpeechRecognitionClientProxy::abort(SpeechRecognition* recognition) |
| 78 { | 77 { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 SpeechRecognition* recognition(handle); | 143 SpeechRecognition* recognition(handle); |
| 145 recognition->didEnd(); | 144 recognition->didEnd(); |
| 146 } | 145 } |
| 147 | 146 |
| 148 SpeechRecognitionClientProxy::SpeechRecognitionClientProxy(WebSpeechRecognizer*
recognizer) | 147 SpeechRecognitionClientProxy::SpeechRecognitionClientProxy(WebSpeechRecognizer*
recognizer) |
| 149 : m_recognizer(recognizer) | 148 : m_recognizer(recognizer) |
| 150 { | 149 { |
| 151 } | 150 } |
| 152 | 151 |
| 153 } // namespace blink | 152 } // namespace blink |
| OLD | NEW |