OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/browser/speech/speech_recognizer.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/common/speech_input_result.h" | 14 #include "content/common/speech_input_result.h" |
15 #include "ui/gfx/rect.h" | 15 #include "ui/gfx/rect.h" |
16 | 16 |
17 namespace speech_input { | 17 namespace speech_input { |
18 | 18 |
19 // This is the gatekeeper for speech recognition in the browser process. It | 19 // This is the gatekeeper for speech recognition in the browser process. It |
20 // handles requests received from various render views and makes sure only one | 20 // handles requests received from various render views and makes sure only one |
21 // of them can use speech recognition at a time. It also sends recognition | 21 // of them can use speech recognition at a time. It also sends recognition |
22 // results and status events to the render views when required. | 22 // results and status events to the render views when required. |
23 class SpeechInputManager : public SpeechRecognizerDelegate { | 23 class CONTENT_EXPORT SpeechInputManager : public SpeechRecognizerDelegate { |
24 public: | 24 public: |
25 // Implemented by the dispatcher host to relay events to the render views. | 25 // Implemented by the dispatcher host to relay events to the render views. |
26 class Delegate { | 26 class Delegate { |
27 public: | 27 public: |
28 virtual void SetRecognitionResult( | 28 virtual void SetRecognitionResult( |
29 int caller_id, | 29 int caller_id, |
30 const SpeechInputResultArray& result) = 0; | 30 const SpeechInputResultArray& result) = 0; |
31 virtual void DidCompleteRecording(int caller_id) = 0; | 31 virtual void DidCompleteRecording(int caller_id) = 0; |
32 virtual void DidCompleteRecognition(int caller_id) = 0; | 32 virtual void DidCompleteRecognition(int caller_id) = 0; |
33 | 33 |
34 protected: | 34 protected: |
35 virtual ~Delegate() {} | 35 virtual ~Delegate() {} |
36 }; | 36 }; |
37 | 37 |
38 CONTENT_EXPORT SpeechInputManager(); | 38 SpeechInputManager(); |
39 | 39 |
40 // Invokes the platform provided microphone settings UI in a non-blocking way, | 40 // Invokes the platform provided microphone settings UI in a non-blocking way, |
41 // via the BrowserThread::FILE thread. | 41 // via the BrowserThread::FILE thread. |
42 static void ShowAudioInputSettings(); | 42 static void ShowAudioInputSettings(); |
43 | 43 |
44 CONTENT_EXPORT virtual ~SpeechInputManager(); | 44 virtual ~SpeechInputManager(); |
45 | 45 |
46 // Handlers for requests from render views. | 46 // Handlers for requests from render views. |
47 | 47 |
48 // |delegate| is a weak pointer and should remain valid until | 48 // |delegate| is a weak pointer and should remain valid until |
49 // its |DidCompleteRecognition| method is called or recognition is cancelled. | 49 // its |DidCompleteRecognition| method is called or recognition is cancelled. |
50 // |render_process_id| is the ID of the renderer process initiating the | 50 // |render_process_id| is the ID of the renderer process initiating the |
51 // request. | 51 // request. |
52 // |element_rect| is the display bounds of the html element requesting speech | 52 // |element_rect| is the display bounds of the html element requesting speech |
53 // input (in page coordinates). | 53 // input (in page coordinates). |
54 virtual void StartRecognition(Delegate* delegate, | 54 virtual void StartRecognition(Delegate* delegate, |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 | 150 |
151 // This typedef is to workaround the issue with certain versions of | 151 // This typedef is to workaround the issue with certain versions of |
152 // Visual Studio where it gets confused between multiple Delegate | 152 // Visual Studio where it gets confused between multiple Delegate |
153 // classes and gives a C2500 error. (I saw this error on the try bots - | 153 // classes and gives a C2500 error. (I saw this error on the try bots - |
154 // the workaround was not needed for my machine). | 154 // the workaround was not needed for my machine). |
155 typedef SpeechInputManager::Delegate SpeechInputManagerDelegate; | 155 typedef SpeechInputManager::Delegate SpeechInputManagerDelegate; |
156 | 156 |
157 } // namespace speech_input | 157 } // namespace speech_input |
158 | 158 |
159 #endif // CONTENT_BROWSER_SPEECH_SPEECH_INPUT_MANAGER_H_ | 159 #endif // CONTENT_BROWSER_SPEECH_SPEECH_INPUT_MANAGER_H_ |
OLD | NEW |