Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(138)

Side by Side Diff: Source/modules/speech/SpeechRecognition.cpp

Issue 1211973002: Revert of Adding a serviceURI param to SpeechRecognition Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/modules/speech/SpeechRecognition.h ('k') | Source/modules/speech/SpeechRecognition.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 17 matching lines...) Expand all
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" 34 #include "modules/mediastream/MediaStreamTrack.h"
35 #include "modules/speech/SpeechRecognitionController.h" 35 #include "modules/speech/SpeechRecognitionController.h"
36 #include "modules/speech/SpeechRecognitionError.h" 36 #include "modules/speech/SpeechRecognitionError.h"
37 #include "modules/speech/SpeechRecognitionEvent.h" 37 #include "modules/speech/SpeechRecognitionEvent.h"
38 #include "platform/weborigin/KURL.h"
39 38
40 namespace blink { 39 namespace blink {
41 40
42 SpeechRecognition* SpeechRecognition::create(ExecutionContext* context) 41 SpeechRecognition* SpeechRecognition::create(ExecutionContext* context)
43 { 42 {
44 ASSERT(context && context->isDocument()); 43 ASSERT(context && context->isDocument());
45 Document* document = toDocument(context); 44 Document* document = toDocument(context);
46 ASSERT(document); 45 ASSERT(document);
47 SpeechRecognition* speechRecognition = new SpeechRecognition(document->page( ), context); 46 SpeechRecognition* speechRecognition = new SpeechRecognition(document->page( ), context);
48 speechRecognition->suspendIfNeeded(); 47 speechRecognition->suspendIfNeeded();
49 return speechRecognition; 48 return speechRecognition;
50 } 49 }
51 50
52 void SpeechRecognition::start(ExceptionState& exceptionState) 51 void SpeechRecognition::start(ExceptionState& exceptionState)
53 { 52 {
54 if (!m_controller) 53 if (!m_controller)
55 return; 54 return;
56 55
57 if (m_started) { 56 if (m_started) {
58 exceptionState.throwDOMException(InvalidStateError, "recognition has alr eady started."); 57 exceptionState.throwDOMException(InvalidStateError, "recognition has alr eady started.");
59 return; 58 return;
60 } 59 }
61 60
62 KURL url(m_serviceURI);
63 // Throw an error if serviceuri is not empty and url is invalid.
64 if (!m_serviceURI.empty() && !url.isValid()) {
65 exceptionState.throwDOMException(ValidationError, "serviceuri is invalid ");
66 return;
67 }
68
69 m_finalResults.clear(); 61 m_finalResults.clear();
70 m_controller->start(this, m_grammars, m_lang, url, m_continuous, m_interimRe sults, m_maxAlternatives, m_audioTrack); 62 m_controller->start(this, m_grammars, m_lang, m_continuous, m_interimResults , m_maxAlternatives, m_audioTrack);
71 m_started = true; 63 m_started = true;
72 } 64 }
73 65
74 void SpeechRecognition::stopFunction() 66 void SpeechRecognition::stopFunction()
75 { 67 {
76 if (!m_controller) 68 if (!m_controller)
77 return; 69 return;
78 70
79 if (m_started && !m_stopping) { 71 if (m_started && !m_stopping) {
80 m_stopping = true; 72 m_stopping = true;
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 #if ENABLE(OILPAN) 208 #if ENABLE(OILPAN)
217 visitor->trace(m_controller); 209 visitor->trace(m_controller);
218 #endif 210 #endif
219 visitor->trace(m_finalResults); 211 visitor->trace(m_finalResults);
220 RefCountedGarbageCollectedEventTargetWithInlineData<SpeechRecognition>::trac e(visitor); 212 RefCountedGarbageCollectedEventTargetWithInlineData<SpeechRecognition>::trac e(visitor);
221 PageLifecycleObserver::trace(visitor); 213 PageLifecycleObserver::trace(visitor);
222 ActiveDOMObject::trace(visitor); 214 ActiveDOMObject::trace(visitor);
223 } 215 }
224 216
225 } // namespace blink 217 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/speech/SpeechRecognition.h ('k') | Source/modules/speech/SpeechRecognition.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698