| 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 15 matching lines...) Expand all Loading... |
| 26 #include "config.h" | 26 #include "config.h" |
| 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/speech/SpeechGrammarList.h" | 30 #include "modules/speech/SpeechGrammarList.h" |
| 31 #include "modules/speech/SpeechRecognition.h" | 31 #include "modules/speech/SpeechRecognition.h" |
| 32 #include "modules/speech/SpeechRecognitionError.h" | 32 #include "modules/speech/SpeechRecognitionError.h" |
| 33 #include "modules/speech/SpeechRecognitionResult.h" | 33 #include "modules/speech/SpeechRecognitionResult.h" |
| 34 #include "modules/speech/SpeechRecognitionResultList.h" | 34 #include "modules/speech/SpeechRecognitionResultList.h" |
| 35 #include "platform/weborigin/SecurityOrigin.h" | 35 #include "platform/weborigin/SecurityOrigin.h" |
| 36 #include "public/platform/WebMediaStreamTrack.h" |
| 36 #include "public/web/WebSecurityOrigin.h" | 37 #include "public/web/WebSecurityOrigin.h" |
| 37 #include "public/web/WebSpeechGrammar.h" | 38 #include "public/web/WebSpeechGrammar.h" |
| 38 #include "public/web/WebSpeechRecognitionHandle.h" | 39 #include "public/web/WebSpeechRecognitionHandle.h" |
| 39 #include "public/web/WebSpeechRecognitionParams.h" | 40 #include "public/web/WebSpeechRecognitionParams.h" |
| 40 #include "public/web/WebSpeechRecognitionResult.h" | 41 #include "public/web/WebSpeechRecognitionResult.h" |
| 41 #include "public/web/WebSpeechRecognizer.h" | 42 #include "public/web/WebSpeechRecognizer.h" |
| 42 #include "wtf/PassRefPtr.h" | 43 #include "wtf/PassRefPtr.h" |
| 43 | 44 |
| 44 namespace blink { | 45 namespace blink { |
| 45 | 46 |
| 46 SpeechRecognitionClientProxy::~SpeechRecognitionClientProxy() | 47 SpeechRecognitionClientProxy::~SpeechRecognitionClientProxy() |
| 47 { | 48 { |
| 48 } | 49 } |
| 49 | 50 |
| 50 PassOwnPtr<SpeechRecognitionClientProxy> SpeechRecognitionClientProxy::create(We
bSpeechRecognizer* recognizer) | 51 PassOwnPtr<SpeechRecognitionClientProxy> SpeechRecognitionClientProxy::create(We
bSpeechRecognizer* recognizer) |
| 51 { | 52 { |
| 52 return adoptPtr(new SpeechRecognitionClientProxy(recognizer)); | 53 return adoptPtr(new SpeechRecognitionClientProxy(recognizer)); |
| 53 } | 54 } |
| 54 | 55 |
| 56 void SpeechRecognitionClientProxy::attach(SpeechRecognition* recognition, MediaS
treamTrack* audioTrack) |
| 57 { |
| 58 if (audioTrack) |
| 59 m_recognizer->attach(WebSpeechRecognitionHandle(recognition), audioTrack
->component(), this); |
| 60 else |
| 61 m_recognizer->detach(WebSpeechRecognitionHandle(recognition), this); |
| 62 } |
| 63 |
| 55 void SpeechRecognitionClientProxy::start(SpeechRecognition* recognition, const S
peechGrammarList* grammarList, const String& lang, bool continuous, bool interim
Results, unsigned long maxAlternatives) | 64 void SpeechRecognitionClientProxy::start(SpeechRecognition* recognition, const S
peechGrammarList* grammarList, const String& lang, bool continuous, bool interim
Results, unsigned long maxAlternatives) |
| 56 { | 65 { |
| 57 WebVector<WebSpeechGrammar> webSpeechGrammars(static_cast<size_t>(grammarLis
t->length())); | 66 WebVector<WebSpeechGrammar> webSpeechGrammars(static_cast<size_t>(grammarLis
t->length())); |
| 58 for (unsigned long i = 0; i < grammarList->length(); ++i) | 67 for (unsigned long i = 0; i < grammarList->length(); ++i) |
| 59 webSpeechGrammars[i] = grammarList->item(i); | 68 webSpeechGrammars[i] = grammarList->item(i); |
| 60 | 69 |
| 61 WebSpeechRecognitionParams params(webSpeechGrammars, lang, continuous, inter
imResults, maxAlternatives, WebSecurityOrigin(recognition->executionContext()->s
ecurityOrigin())); | 70 WebSpeechRecognitionParams params(webSpeechGrammars, lang, continuous, inter
imResults, maxAlternatives, WebSecurityOrigin(recognition->executionContext()->s
ecurityOrigin())); |
| 62 m_recognizer->start(WebSpeechRecognitionHandle(recognition), params, this); | 71 m_recognizer->start(WebSpeechRecognitionHandle(recognition), params, this); |
| 63 } | 72 } |
| 64 | 73 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 SpeechRecognition* recognition(handle); | 146 SpeechRecognition* recognition(handle); |
| 138 recognition->didEnd(); | 147 recognition->didEnd(); |
| 139 } | 148 } |
| 140 | 149 |
| 141 SpeechRecognitionClientProxy::SpeechRecognitionClientProxy(WebSpeechRecognizer*
recognizer) | 150 SpeechRecognitionClientProxy::SpeechRecognitionClientProxy(WebSpeechRecognizer*
recognizer) |
| 142 : m_recognizer(recognizer) | 151 : m_recognizer(recognizer) |
| 143 { | 152 { |
| 144 } | 153 } |
| 145 | 154 |
| 146 } // namespace blink | 155 } // namespace blink |
| OLD | NEW |