| 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 #ifndef SpeechRecognition_h | 26 #ifndef SpeechRecognition_h |
| 27 #define SpeechRecognition_h | 27 #define SpeechRecognition_h |
| 28 | 28 |
| 29 #include "bindings/v8/ScriptWrappable.h" | 29 #include "bindings/v8/ScriptWrappable.h" |
| 30 #include "core/dom/ActiveDOMObject.h" | 30 #include "core/dom/ActiveDOMObject.h" |
| 31 #include "modules/EventTargetModules.h" | 31 #include "modules/EventTargetModules.h" |
| 32 #include "modules/speech/SpeechGrammarList.h" | 32 #include "modules/speech/SpeechGrammarList.h" |
| 33 #include "modules/speech/SpeechRecognitionResult.h" | 33 #include "modules/speech/SpeechRecognitionResult.h" |
| 34 #include "platform/heap/Handle.h" | 34 #include "platform/heap/Handle.h" |
| 35 #include "wtf/Compiler.h" | 35 #include "wtf/Compiler.h" |
| 36 #include "wtf/PassRefPtr.h" |
| 37 #include "wtf/RefCounted.h" |
| 36 #include "wtf/text/WTFString.h" | 38 #include "wtf/text/WTFString.h" |
| 37 | 39 |
| 38 namespace WebCore { | 40 namespace WebCore { |
| 39 | 41 |
| 40 class ExceptionState; | 42 class ExceptionState; |
| 41 class ExecutionContext; | 43 class ExecutionContext; |
| 42 class SpeechRecognitionController; | 44 class SpeechRecognitionController; |
| 43 class SpeechRecognitionError; | 45 class SpeechRecognitionError; |
| 44 | 46 |
| 45 class SpeechRecognition FINAL : public RefCountedGarbageCollected<SpeechRecognit
ion>, public ScriptWrappable, public ActiveDOMObject, public EventTargetWithInli
neData { | 47 class SpeechRecognition FINAL : public RefCountedWillBeRefCountedGarbageCollecte
d<SpeechRecognition>, public ScriptWrappable, public ActiveDOMObject, public Eve
ntTargetWithInlineData { |
| 46 DEFINE_EVENT_TARGET_REFCOUNTING(RefCountedGarbageCollected<SpeechRecognition
>); | 48 REFCOUNTED_EVENT_TARGET(SpeechRecognition); |
| 47 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(SpeechRecognition); | 49 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(SpeechRecognition); |
| 48 public: | 50 public: |
| 49 static SpeechRecognition* create(ExecutionContext*); | 51 static PassRefPtrWillBeRawPtr<SpeechRecognition> create(ExecutionContext*); |
| 50 virtual ~SpeechRecognition(); | 52 virtual ~SpeechRecognition(); |
| 51 | 53 |
| 52 // Attributes. | 54 // Attributes. |
| 53 SpeechGrammarList* grammars() { return m_grammars.get(); } | 55 SpeechGrammarList* grammars() { return m_grammars.get(); } |
| 54 void setGrammars(SpeechGrammarList* grammars) { m_grammars = grammars; } | 56 void setGrammars(PassRefPtrWillBeRawPtr<SpeechGrammarList> grammars) { m_gra
mmars = grammars; } |
| 55 String lang() { return m_lang; } | 57 String lang() { return m_lang; } |
| 56 void setLang(const String& lang) { m_lang = lang; } | 58 void setLang(const String& lang) { m_lang = lang; } |
| 57 bool continuous() { return m_continuous; } | 59 bool continuous() { return m_continuous; } |
| 58 void setContinuous(bool continuous) { m_continuous = continuous; } | 60 void setContinuous(bool continuous) { m_continuous = continuous; } |
| 59 bool interimResults() { return m_interimResults; } | 61 bool interimResults() { return m_interimResults; } |
| 60 void setInterimResults(bool interimResults) { m_interimResults = interimResu
lts; } | 62 void setInterimResults(bool interimResults) { m_interimResults = interimResu
lts; } |
| 61 unsigned long maxAlternatives() { return m_maxAlternatives; } | 63 unsigned long maxAlternatives() { return m_maxAlternatives; } |
| 62 void setMaxAlternatives(unsigned long maxAlternatives) { m_maxAlternatives =
maxAlternatives; } | 64 void setMaxAlternatives(unsigned long maxAlternatives) { m_maxAlternatives =
maxAlternatives; } |
| 63 | 65 |
| 64 // Callable by the user. | 66 // Callable by the user. |
| 65 void start(ExceptionState&); | 67 void start(ExceptionState&); |
| 66 void stopFunction(); | 68 void stopFunction(); |
| 67 void abort(); | 69 void abort(); |
| 68 | 70 |
| 69 // Called by the SpeechRecognitionClient. | 71 // Called by the SpeechRecognitionClient. |
| 70 void didStartAudio(); | 72 void didStartAudio(); |
| 71 void didStartSound(); | 73 void didStartSound(); |
| 72 void didStartSpeech(); | 74 void didStartSpeech(); |
| 73 void didEndSpeech(); | 75 void didEndSpeech(); |
| 74 void didEndSound(); | 76 void didEndSound(); |
| 75 void didEndAudio(); | 77 void didEndAudio(); |
| 76 void didReceiveResults(const HeapVector<Member<SpeechRecognitionResult> >& n
ewFinalResults, const HeapVector<Member<SpeechRecognitionResult> >& currentInter
imResults); | 78 void didReceiveResults(const WillBeHeapVector<RefPtrWillBeMember<SpeechRecog
nitionResult> >& newFinalResults, const WillBeHeapVector<RefPtrWillBeMember<Spee
chRecognitionResult> >& currentInterimResults); |
| 77 void didReceiveNoMatch(SpeechRecognitionResult*); | 79 void didReceiveNoMatch(PassRefPtrWillBeRawPtr<SpeechRecognitionResult>); |
| 78 void didReceiveError(PassRefPtrWillBeRawPtr<SpeechRecognitionError>); | 80 void didReceiveError(PassRefPtrWillBeRawPtr<SpeechRecognitionError>); |
| 79 void didStart(); | 81 void didStart(); |
| 80 void didEnd(); | 82 void didEnd(); |
| 81 | 83 |
| 82 // EventTarget. | 84 // EventTarget. |
| 83 virtual const AtomicString& interfaceName() const OVERRIDE; | 85 virtual const AtomicString& interfaceName() const OVERRIDE; |
| 84 virtual ExecutionContext* executionContext() const OVERRIDE; | 86 virtual ExecutionContext* executionContext() const OVERRIDE; |
| 85 | 87 |
| 86 // ActiveDOMObject. | 88 // ActiveDOMObject. |
| 87 virtual bool hasPendingActivity() const OVERRIDE; | 89 virtual bool hasPendingActivity() const OVERRIDE; |
| 88 virtual void stop() OVERRIDE; | 90 virtual void stop() OVERRIDE; |
| 89 | 91 |
| 90 DEFINE_ATTRIBUTE_EVENT_LISTENER(audiostart); | 92 DEFINE_ATTRIBUTE_EVENT_LISTENER(audiostart); |
| 91 DEFINE_ATTRIBUTE_EVENT_LISTENER(soundstart); | 93 DEFINE_ATTRIBUTE_EVENT_LISTENER(soundstart); |
| 92 DEFINE_ATTRIBUTE_EVENT_LISTENER(speechstart); | 94 DEFINE_ATTRIBUTE_EVENT_LISTENER(speechstart); |
| 93 DEFINE_ATTRIBUTE_EVENT_LISTENER(speechend); | 95 DEFINE_ATTRIBUTE_EVENT_LISTENER(speechend); |
| 94 DEFINE_ATTRIBUTE_EVENT_LISTENER(soundend); | 96 DEFINE_ATTRIBUTE_EVENT_LISTENER(soundend); |
| 95 DEFINE_ATTRIBUTE_EVENT_LISTENER(audioend); | 97 DEFINE_ATTRIBUTE_EVENT_LISTENER(audioend); |
| 96 DEFINE_ATTRIBUTE_EVENT_LISTENER(result); | 98 DEFINE_ATTRIBUTE_EVENT_LISTENER(result); |
| 97 DEFINE_ATTRIBUTE_EVENT_LISTENER(nomatch); | 99 DEFINE_ATTRIBUTE_EVENT_LISTENER(nomatch); |
| 98 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); | 100 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); |
| 99 DEFINE_ATTRIBUTE_EVENT_LISTENER(start); | 101 DEFINE_ATTRIBUTE_EVENT_LISTENER(start); |
| 100 DEFINE_ATTRIBUTE_EVENT_LISTENER(end); | 102 DEFINE_ATTRIBUTE_EVENT_LISTENER(end); |
| 101 | 103 |
| 102 virtual void trace(Visitor*) OVERRIDE; | 104 virtual void trace(Visitor*) OVERRIDE; |
| 103 | 105 |
| 104 private: | 106 private: |
| 107 friend class RefCounted<SpeechRecognition>; |
| 108 |
| 105 explicit SpeechRecognition(ExecutionContext*); | 109 explicit SpeechRecognition(ExecutionContext*); |
| 106 | 110 |
| 107 Member<SpeechGrammarList> m_grammars; | 111 RefPtrWillBeMember<SpeechGrammarList> m_grammars; |
| 108 String m_lang; | 112 String m_lang; |
| 109 bool m_continuous; | 113 bool m_continuous; |
| 110 bool m_interimResults; | 114 bool m_interimResults; |
| 111 unsigned long m_maxAlternatives; | 115 unsigned long m_maxAlternatives; |
| 112 | 116 |
| 113 SpeechRecognitionController* m_controller; | 117 SpeechRecognitionController* m_controller; |
| 114 bool m_stoppedByActiveDOMObject; | 118 bool m_stoppedByActiveDOMObject; |
| 115 bool m_started; | 119 bool m_started; |
| 116 bool m_stopping; | 120 bool m_stopping; |
| 117 HeapVector<Member<SpeechRecognitionResult> > m_finalResults; | 121 WillBeHeapVector<RefPtrWillBeMember<SpeechRecognitionResult> > m_finalResult
s; |
| 118 }; | 122 }; |
| 119 | 123 |
| 120 } // namespace WebCore | 124 } // namespace WebCore |
| 121 | 125 |
| 122 #endif // SpeechRecognition_h | 126 #endif // SpeechRecognition_h |
| OLD | NEW |