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 30 matching lines...) Expand all Loading... |
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 | 47 |
48 // This class connects the input elements requiring speech input with the platfo
rm specific | 48 // 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 | 49 // 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. | 50 // recognition and methods for the speech recognition engine to return back the
results. |
51 class SpeechInput : public SpeechInputListener, public Supplement<Page> { | 51 class SpeechInput FINAL : public SpeechInputListener, public Supplement<Page> { |
52 WTF_MAKE_NONCOPYABLE(SpeechInput); | 52 WTF_MAKE_NONCOPYABLE(SpeechInput); |
53 public: | 53 public: |
54 virtual ~SpeechInput(); | 54 virtual ~SpeechInput(); |
55 | 55 |
56 static PassOwnPtr<SpeechInput> create(SpeechInputClient*); | 56 static PassOwnPtr<SpeechInput> create(SpeechInputClient*); |
57 static const char* supplementName(); | 57 static const char* supplementName(); |
58 static SpeechInput* from(Page* page) { return static_cast<SpeechInput*>(Supp
lement<Page>::from(page, supplementName())); } | 58 static SpeechInput* from(Page* page) { return static_cast<SpeechInput*>(Supp
lement<Page>::from(page, supplementName())); } |
59 | 59 |
60 // Generates a unique ID for the given listener to be used for speech reques
ts. | 60 // 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. | 61 // This should be the first call made by listeners before anything else. |
62 int registerListener(SpeechInputListener*); | 62 int registerListener(SpeechInputListener*); |
63 | 63 |
64 // Invoked when the listener is done with recording or getting destroyed. | 64 // 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. | 65 // Failure to unregister may result in crashes if there were any pending spe
ech events. |
66 void unregisterListener(int); | 66 void unregisterListener(int); |
67 | 67 |
68 // Methods invoked by the input elements. | 68 // Methods invoked by the input elements. |
69 bool startRecognition(int listenerId, const IntRect& elementRect, const Atom
icString& language, const String& grammar, SecurityOrigin*); | 69 bool startRecognition(int listenerId, const IntRect& elementRect, const Atom
icString& language, const String& grammar, SecurityOrigin*); |
70 void stopRecording(int); | 70 void stopRecording(int); |
71 void cancelRecognition(int); | 71 void cancelRecognition(int); |
72 | 72 |
73 // SpeechInputListener methods. | 73 // SpeechInputListener methods. |
74 virtual void didCompleteRecording(int); | 74 virtual void didCompleteRecording(int) OVERRIDE; |
75 virtual void didCompleteRecognition(int); | 75 virtual void didCompleteRecognition(int) OVERRIDE; |
76 virtual void setRecognitionResult(int, const SpeechInputResultArray&); | 76 virtual void setRecognitionResult(int, const SpeechInputResultArray&) OVERRI
DE; |
77 | 77 |
78 private: | 78 private: |
79 explicit SpeechInput(SpeechInputClient*); | 79 explicit SpeechInput(SpeechInputClient*); |
80 | 80 |
81 SpeechInputClient* m_client; | 81 SpeechInputClient* m_client; |
82 HashMap<int, SpeechInputListener*> m_listeners; | 82 HashMap<int, SpeechInputListener*> m_listeners; |
83 int m_nextListenerId; | 83 int m_nextListenerId; |
84 }; | 84 }; |
85 | 85 |
86 } // namespace WebCore | 86 } // namespace WebCore |
87 | 87 |
88 #endif // ENABLE(INPUT_SPEECH) | 88 #endif // ENABLE(INPUT_SPEECH) |
89 | 89 |
90 #endif // SpeechInput_h | 90 #endif // SpeechInput_h |
OLD | NEW |