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