OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_BROWSER_SPEECH_SPEECH_INPUT_MANAGER_H_ | 5 #ifndef CONTENT_BROWSER_SPEECH_SPEECH_INPUT_MANAGER_H_ |
6 #define CONTENT_BROWSER_SPEECH_SPEECH_INPUT_MANAGER_H_ | 6 #define CONTENT_BROWSER_SPEECH_SPEECH_INPUT_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "content/browser/speech/speech_recognizer.h" |
13 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
14 #include "content/public/browser/speech_recognizer_delegate.h" | |
15 #include "ui/gfx/rect.h" | 14 #include "ui/gfx/rect.h" |
16 | 15 |
17 class AudioManager; | |
18 | |
19 namespace content { | 16 namespace content { |
20 class ResourceContext; | 17 class ResourceContext; |
21 class SpeechInputPreferences; | 18 class SpeechInputPreferences; |
22 struct SpeechInputResult; | 19 struct SpeechInputResult; |
23 } | 20 } |
24 | 21 |
25 namespace net { | |
26 class URLRequestContextGetter; | |
27 } | |
28 | |
29 namespace speech_input { | 22 namespace speech_input { |
30 class SpeechRecognizer; | |
31 | 23 |
32 // This is the gatekeeper for speech recognition in the browser process. It | 24 // This is the gatekeeper for speech recognition in the browser process. It |
33 // handles requests received from various render views and makes sure only one | 25 // handles requests received from various render views and makes sure only one |
34 // of them can use speech recognition at a time. It also sends recognition | 26 // of them can use speech recognition at a time. It also sends recognition |
35 // results and status events to the render views when required. | 27 // results and status events to the render views when required. |
36 class CONTENT_EXPORT SpeechInputManager | 28 class CONTENT_EXPORT SpeechInputManager : public SpeechRecognizerDelegate { |
37 : public content::SpeechRecognizerDelegate { | |
38 public: | 29 public: |
39 // Implemented by the dispatcher host to relay events to the render views. | 30 // Implemented by the dispatcher host to relay events to the render views. |
40 class Delegate { | 31 class Delegate { |
41 public: | 32 public: |
42 virtual void SetRecognitionResult( | 33 virtual void SetRecognitionResult( |
43 int caller_id, | 34 int caller_id, |
44 const content::SpeechInputResult& result) = 0; | 35 const content::SpeechInputResult& result) = 0; |
45 virtual void DidCompleteRecording(int caller_id) = 0; | 36 virtual void DidCompleteRecording(int caller_id) = 0; |
46 virtual void DidCompleteRecognition(int caller_id) = 0; | 37 virtual void DidCompleteRecognition(int caller_id) = 0; |
47 | 38 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 const std::string& language, | 77 const std::string& language, |
87 const std::string& grammar, | 78 const std::string& grammar, |
88 const std::string& origin_url, | 79 const std::string& origin_url, |
89 net::URLRequestContextGetter* context_getter, | 80 net::URLRequestContextGetter* context_getter, |
90 content::SpeechInputPreferences* speech_input_prefs, | 81 content::SpeechInputPreferences* speech_input_prefs, |
91 AudioManager* audio_manager); | 82 AudioManager* audio_manager); |
92 virtual void CancelRecognition(int caller_id); | 83 virtual void CancelRecognition(int caller_id); |
93 virtual void CancelAllRequestsWithDelegate(Delegate* delegate); | 84 virtual void CancelAllRequestsWithDelegate(Delegate* delegate); |
94 virtual void StopRecording(int caller_id); | 85 virtual void StopRecording(int caller_id); |
95 | 86 |
96 // Overridden from content::SpeechRecognizerDelegate: | 87 // SpeechRecognizerDelegate methods. |
97 virtual void DidStartReceivingAudio(int caller_id) OVERRIDE; | 88 virtual void DidStartReceivingAudio(int caller_id) OVERRIDE; |
98 virtual void SetRecognitionResult( | 89 virtual void SetRecognitionResult( |
99 int caller_id, | 90 int caller_id, |
100 const content::SpeechInputResult& result) OVERRIDE; | 91 const content::SpeechInputResult& result) OVERRIDE; |
101 virtual void DidCompleteRecording(int caller_id) OVERRIDE; | 92 virtual void DidCompleteRecording(int caller_id) OVERRIDE; |
102 virtual void DidCompleteRecognition(int caller_id) OVERRIDE; | 93 virtual void DidCompleteRecognition(int caller_id) OVERRIDE; |
103 virtual void DidStartReceivingSpeech(int caller_id) OVERRIDE; | 94 virtual void DidStartReceivingSpeech(int caller_id) OVERRIDE; |
104 virtual void DidStopReceivingSpeech(int caller_id) OVERRIDE; | 95 virtual void DidStopReceivingSpeech(int caller_id) OVERRIDE; |
105 | 96 |
106 virtual void OnRecognizerError(int caller_id, | 97 virtual void OnRecognizerError(int caller_id, |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 | 176 |
186 // This typedef is to workaround the issue with certain versions of | 177 // This typedef is to workaround the issue with certain versions of |
187 // Visual Studio where it gets confused between multiple Delegate | 178 // Visual Studio where it gets confused between multiple Delegate |
188 // classes and gives a C2500 error. (I saw this error on the try bots - | 179 // classes and gives a C2500 error. (I saw this error on the try bots - |
189 // the workaround was not needed for my machine). | 180 // the workaround was not needed for my machine). |
190 typedef SpeechInputManager::Delegate SpeechInputManagerDelegate; | 181 typedef SpeechInputManager::Delegate SpeechInputManagerDelegate; |
191 | 182 |
192 } // namespace speech_input | 183 } // namespace speech_input |
193 | 184 |
194 #endif // CONTENT_BROWSER_SPEECH_SPEECH_INPUT_MANAGER_H_ | 185 #endif // CONTENT_BROWSER_SPEECH_SPEECH_INPUT_MANAGER_H_ |
OLD | NEW |