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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 | 46 |
47 void SpeechRecognition::start(ExceptionState& exceptionState) | 47 void SpeechRecognition::start(ExceptionState& exceptionState) |
48 { | 48 { |
49 ASSERT(m_controller); | 49 ASSERT(m_controller); |
50 if (m_started) { | 50 if (m_started) { |
51 exceptionState.throwDOMException(InvalidStateError, "recognition has alr
eady started."); | 51 exceptionState.throwDOMException(InvalidStateError, "recognition has alr
eady started."); |
52 return; | 52 return; |
53 } | 53 } |
54 | 54 |
55 m_finalResults.clear(); | 55 m_finalResults.clear(); |
56 m_controller->start(this, m_grammars.get(), m_lang, m_continuous, m_interimR
esults, m_maxAlternatives); | 56 m_controller->start(this, m_grammars.get(), m_lang, m_continuous, m_interimR
esults, m_maxAlternatives, m_audioTrack); |
57 m_started = true; | 57 m_started = true; |
58 } | 58 } |
59 | 59 |
60 void SpeechRecognition::stopFunction() | 60 void SpeechRecognition::stopFunction() |
61 { | 61 { |
62 ASSERT(m_controller); | 62 ASSERT(m_controller); |
63 if (m_started && !m_stopping) { | 63 if (m_started && !m_stopping) { |
64 m_stopping = true; | 64 m_stopping = true; |
65 m_controller->stop(this); | 65 m_controller->stop(this); |
66 } | 66 } |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 } | 161 } |
162 | 162 |
163 bool SpeechRecognition::hasPendingActivity() const | 163 bool SpeechRecognition::hasPendingActivity() const |
164 { | 164 { |
165 return m_started; | 165 return m_started; |
166 } | 166 } |
167 | 167 |
168 SpeechRecognition::SpeechRecognition(ExecutionContext* context) | 168 SpeechRecognition::SpeechRecognition(ExecutionContext* context) |
169 : ActiveDOMObject(context) | 169 : ActiveDOMObject(context) |
170 , m_grammars(SpeechGrammarList::create()) // FIXME: The spec is not clear on
the default value for the grammars attribute. | 170 , m_grammars(SpeechGrammarList::create()) // FIXME: The spec is not clear on
the default value for the grammars attribute. |
| 171 , m_audioTrack(nullptr) |
171 , m_continuous(false) | 172 , m_continuous(false) |
172 , m_interimResults(false) | 173 , m_interimResults(false) |
173 , m_maxAlternatives(1) | 174 , m_maxAlternatives(1) |
174 , m_controller(nullptr) | 175 , m_controller(nullptr) |
175 , m_stoppedByActiveDOMObject(false) | 176 , m_stoppedByActiveDOMObject(false) |
176 , m_started(false) | 177 , m_started(false) |
177 , m_stopping(false) | 178 , m_stopping(false) |
178 { | 179 { |
179 Document* document = toDocument(executionContext()); | 180 Document* document = toDocument(executionContext()); |
180 | 181 |
181 Page* page = document->page(); | 182 Page* page = document->page(); |
182 ASSERT(page); | 183 ASSERT(page); |
183 | 184 |
184 m_controller = SpeechRecognitionController::from(page); | 185 m_controller = SpeechRecognitionController::from(page); |
185 ASSERT(m_controller); | 186 ASSERT(m_controller); |
186 | 187 |
187 // FIXME: Need to hook up with Page to get notified when the visibility chan
ges. | 188 // FIXME: Need to hook up with Page to get notified when the visibility chan
ges. |
188 } | 189 } |
189 | 190 |
190 SpeechRecognition::~SpeechRecognition() | 191 SpeechRecognition::~SpeechRecognition() |
191 { | 192 { |
192 } | 193 } |
193 | 194 |
194 void SpeechRecognition::trace(Visitor* visitor) | 195 void SpeechRecognition::trace(Visitor* visitor) |
195 { | 196 { |
196 visitor->trace(m_grammars); | 197 visitor->trace(m_grammars); |
| 198 visitor->trace(m_audioTrack); |
197 #if ENABLE(OILPAN) | 199 #if ENABLE(OILPAN) |
198 visitor->trace(m_controller); | 200 visitor->trace(m_controller); |
199 #endif | 201 #endif |
200 visitor->trace(m_finalResults); | 202 visitor->trace(m_finalResults); |
201 EventTargetWithInlineData::trace(visitor); | 203 EventTargetWithInlineData::trace(visitor); |
202 } | 204 } |
203 | 205 |
204 } // namespace blink | 206 } // namespace blink |
OLD | NEW |