Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 37 #include "core/speech/SpeechInputListener.h" | 37 #include "core/speech/SpeechInputListener.h" |
| 38 #include "wtf/Forward.h" | 38 #include "wtf/Forward.h" |
| 39 #include "wtf/HashMap.h" | 39 #include "wtf/HashMap.h" |
| 40 | 40 |
| 41 namespace WebCore { | 41 namespace WebCore { |
| 42 | 42 |
| 43 class IntRect; | 43 class IntRect; |
| 44 class SecurityOrigin; | 44 class SecurityOrigin; |
| 45 class SpeechInputClient; | 45 class SpeechInputClient; |
| 46 class SpeechInputListener; | 46 class SpeechInputListener; |
| 47 class InputFieldSpeechButtonElement; | |
| 47 | 48 |
| 48 // This class connects the input elements requiring speech input with the platfo rm specific | 49 // This class connects the input elements requiring speech input with the platfo rm specific |
| 49 // speech recognition engine. It provides methods for the input elements to acti vate speech | 50 // speech recognition engine. It provides methods for the input elements to acti vate speech |
| 50 // recognition and methods for the speech recognition engine to return back the results. | 51 // recognition and methods for the speech recognition engine to return back the results. |
| 51 class SpeechInput FINAL : public SpeechInputListener, public Supplement<Page> { | 52 class SpeechInput FINAL : public SpeechInputListener, public Supplement<Page> { |
| 52 WTF_MAKE_NONCOPYABLE(SpeechInput); | 53 WTF_MAKE_NONCOPYABLE(SpeechInput); |
| 53 public: | 54 public: |
| 54 virtual ~SpeechInput(); | 55 virtual ~SpeechInput(); |
| 55 | 56 |
| 56 static PassOwnPtr<SpeechInput> create(PassOwnPtr<SpeechInputClient>); | 57 static PassOwnPtr<SpeechInput> create(PassOwnPtr<SpeechInputClient>); |
| 57 static const char* supplementName(); | 58 static const char* supplementName(); |
| 58 static SpeechInput* from(Page* page) { return static_cast<SpeechInput*>(Supp lement<Page>::from(page, supplementName())); } | 59 static SpeechInput* from(Page* page) { return static_cast<SpeechInput*>(Supp lement<Page>::from(page, supplementName())); } |
| 59 | 60 |
| 60 // Generates a unique ID for the given listener to be used for speech reques ts. | 61 // Generates a unique ID for the given listener to be used for speech reques ts. |
| 61 // This should be the first call made by listeners before anything else. | 62 // This should be the first call made by listeners before anything else. |
| 62 int registerListener(SpeechInputListener*); | 63 int registerListener(InputFieldSpeechButtonElement*); |
| 63 | 64 |
| 64 // Invoked when the listener is done with recording or getting destroyed. | 65 // Invoked when the listener is done with recording or getting destroyed. |
| 65 // Failure to unregister may result in crashes if there were any pending spe ech events. | 66 // Failure to unregister may result in crashes if there were any pending spe ech events. |
| 66 void unregisterListener(int); | 67 void unregisterListener(int); |
| 67 | 68 |
| 68 // Methods invoked by the input elements. | 69 // Methods invoked by the input elements. |
| 69 bool startRecognition(int listenerId, const IntRect& elementRect, const Atom icString& language, const String& grammar, SecurityOrigin*); | 70 bool startRecognition(int listenerId, const IntRect& elementRect, const Atom icString& language, const String& grammar, SecurityOrigin*); |
| 70 void stopRecording(int); | 71 void stopRecording(int); |
| 71 void cancelRecognition(int); | 72 void cancelRecognition(int); |
| 72 | 73 |
| 73 // SpeechInputListener methods. | 74 // SpeechInputListener methods. |
| 74 virtual void didCompleteRecording(int) OVERRIDE; | 75 virtual void didCompleteRecording(int) OVERRIDE; |
| 75 virtual void didCompleteRecognition(int) OVERRIDE; | 76 virtual void didCompleteRecognition(int) OVERRIDE; |
| 76 virtual void setRecognitionResult(int, const SpeechInputResultArray&) OVERRI DE; | 77 virtual void setRecognitionResult(int, const SpeechInputResultArray&) OVERRI DE; |
| 77 | 78 |
| 78 virtual void trace(Visitor*) OVERRIDE { } | 79 virtual void trace(Visitor*) OVERRIDE { } |
| 80 void clearWeakMembers(Visitor*); | |
| 79 | 81 |
| 80 private: | 82 private: |
| 81 explicit SpeechInput(PassOwnPtr<SpeechInputClient>); | 83 explicit SpeechInput(PassOwnPtr<SpeechInputClient>); |
| 82 | 84 |
| 83 OwnPtr<SpeechInputClient> m_client; | 85 OwnPtr<SpeechInputClient> m_client; |
| 84 HashMap<int, SpeechInputListener*> m_listeners; | 86 // FIXME: Oilpan: go back to using SpeechInputListener as the type when |
|
Mads Ager (chromium)
2014/04/11 12:37:56
This FIXME can be taken care of when we have moved
| |
| 87 // all SpeechInputListners (SpeechInput and InputFieldSpeechButtonElement) | |
| 88 // have been moved to the oilpan heap. At that point SpeechInputListener | |
| 89 // will be a GarbageCollectedMixin. | |
| 90 HashMap<int, InputFieldSpeechButtonElement*> m_listeners; | |
| 85 int m_nextListenerId; | 91 int m_nextListenerId; |
| 86 }; | 92 }; |
| 87 | 93 |
| 88 } // namespace WebCore | 94 } // namespace WebCore |
| 89 | 95 |
| 90 #endif // ENABLE(INPUT_SPEECH) | 96 #endif // ENABLE(INPUT_SPEECH) |
| 91 | 97 |
| 92 #endif // SpeechInput_h | 98 #endif // SpeechInput_h |
| OLD | NEW |