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 13 matching lines...) Expand all Loading... | |
24 */ | 24 */ |
25 | 25 |
26 #include "config.h" | 26 #include "config.h" |
27 | 27 |
28 #include "modules/speech/SpeechRecognition.h" | 28 #include "modules/speech/SpeechRecognition.h" |
29 | 29 |
30 #include "bindings/core/v8/ExceptionState.h" | 30 #include "bindings/core/v8/ExceptionState.h" |
31 #include "core/dom/Document.h" | 31 #include "core/dom/Document.h" |
32 #include "core/dom/ExceptionCode.h" | 32 #include "core/dom/ExceptionCode.h" |
33 #include "core/page/Page.h" | 33 #include "core/page/Page.h" |
34 #include "modules/mediastream/MediaStreamTrack.h" | |
burnik
2014/09/22 14:29:46
Required by |Trace(...)|
| |
34 #include "modules/speech/SpeechRecognitionController.h" | 35 #include "modules/speech/SpeechRecognitionController.h" |
35 #include "modules/speech/SpeechRecognitionError.h" | 36 #include "modules/speech/SpeechRecognitionError.h" |
36 #include "modules/speech/SpeechRecognitionEvent.h" | 37 #include "modules/speech/SpeechRecognitionEvent.h" |
37 | 38 |
38 namespace blink { | 39 namespace blink { |
39 | 40 |
40 SpeechRecognition* SpeechRecognition::create(ExecutionContext* context) | 41 SpeechRecognition* SpeechRecognition::create(ExecutionContext* context) |
41 { | 42 { |
42 SpeechRecognition* speechRecognition = adoptRefCountedGarbageCollectedWillBe Noop(new SpeechRecognition(context)); | 43 SpeechRecognition* speechRecognition = adoptRefCountedGarbageCollectedWillBe Noop(new SpeechRecognition(context)); |
43 speechRecognition->suspendIfNeeded(); | 44 speechRecognition->suspendIfNeeded(); |
44 return speechRecognition; | 45 return speechRecognition; |
45 } | 46 } |
46 | 47 |
47 void SpeechRecognition::start(ExceptionState& exceptionState) | 48 void SpeechRecognition::start(ExceptionState& exceptionState) |
48 { | 49 { |
49 ASSERT(m_controller); | 50 ASSERT(m_controller); |
50 if (m_started) { | 51 if (m_started) { |
51 exceptionState.throwDOMException(InvalidStateError, "recognition has alr eady started."); | 52 exceptionState.throwDOMException(InvalidStateError, "recognition has alr eady started."); |
52 return; | 53 return; |
53 } | 54 } |
54 | 55 |
55 m_finalResults.clear(); | 56 m_finalResults.clear(); |
56 m_controller->start(this, m_grammars.get(), m_lang, m_continuous, m_interimR esults, m_maxAlternatives); | 57 m_controller->start(this, m_grammars.get(), m_lang, m_continuous, m_interimR esults, m_maxAlternatives, m_audioTrack); |
57 m_started = true; | 58 m_started = true; |
58 } | 59 } |
59 | 60 |
60 void SpeechRecognition::stopFunction() | 61 void SpeechRecognition::stopFunction() |
61 { | 62 { |
62 ASSERT(m_controller); | 63 ASSERT(m_controller); |
63 if (m_started && !m_stopping) { | 64 if (m_started && !m_stopping) { |
64 m_stopping = true; | 65 m_stopping = true; |
65 m_controller->stop(this); | 66 m_controller->stop(this); |
66 } | 67 } |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
161 } | 162 } |
162 | 163 |
163 bool SpeechRecognition::hasPendingActivity() const | 164 bool SpeechRecognition::hasPendingActivity() const |
164 { | 165 { |
165 return m_started; | 166 return m_started; |
166 } | 167 } |
167 | 168 |
168 SpeechRecognition::SpeechRecognition(ExecutionContext* context) | 169 SpeechRecognition::SpeechRecognition(ExecutionContext* context) |
169 : ActiveDOMObject(context) | 170 : ActiveDOMObject(context) |
170 , m_grammars(SpeechGrammarList::create()) // FIXME: The spec is not clear on the default value for the grammars attribute. | 171 , m_grammars(SpeechGrammarList::create()) // FIXME: The spec is not clear on the default value for the grammars attribute. |
172 , m_audioTrack(nullptr) | |
171 , m_continuous(false) | 173 , m_continuous(false) |
172 , m_interimResults(false) | 174 , m_interimResults(false) |
173 , m_maxAlternatives(1) | 175 , m_maxAlternatives(1) |
174 , m_controller(nullptr) | 176 , m_controller(nullptr) |
175 , m_stoppedByActiveDOMObject(false) | 177 , m_stoppedByActiveDOMObject(false) |
176 , m_started(false) | 178 , m_started(false) |
177 , m_stopping(false) | 179 , m_stopping(false) |
178 { | 180 { |
179 Document* document = toDocument(executionContext()); | 181 Document* document = toDocument(executionContext()); |
180 | 182 |
181 Page* page = document->page(); | 183 Page* page = document->page(); |
182 ASSERT(page); | 184 ASSERT(page); |
183 | 185 |
184 m_controller = SpeechRecognitionController::from(page); | 186 m_controller = SpeechRecognitionController::from(page); |
185 ASSERT(m_controller); | 187 ASSERT(m_controller); |
186 | 188 |
187 // FIXME: Need to hook up with Page to get notified when the visibility chan ges. | 189 // FIXME: Need to hook up with Page to get notified when the visibility chan ges. |
188 } | 190 } |
189 | 191 |
190 SpeechRecognition::~SpeechRecognition() | 192 SpeechRecognition::~SpeechRecognition() |
191 { | 193 { |
192 } | 194 } |
193 | 195 |
194 void SpeechRecognition::trace(Visitor* visitor) | 196 void SpeechRecognition::trace(Visitor* visitor) |
195 { | 197 { |
196 visitor->trace(m_grammars); | 198 visitor->trace(m_grammars); |
199 visitor->trace(m_audioTrack); | |
197 #if ENABLE(OILPAN) | 200 #if ENABLE(OILPAN) |
198 visitor->trace(m_controller); | 201 visitor->trace(m_controller); |
199 #endif | 202 #endif |
200 visitor->trace(m_finalResults); | 203 visitor->trace(m_finalResults); |
201 EventTargetWithInlineData::trace(visitor); | 204 EventTargetWithInlineData::trace(visitor); |
202 } | 205 } |
203 | 206 |
204 } // namespace blink | 207 } // namespace blink |
OLD | NEW |