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 |
(...skipping 11 matching lines...) Expand all Loading... | |
22 // handles requests received from various render views and makes sure only one | 22 // handles requests received from various render views and makes sure only one |
23 // of them can use speech recognition at a time. It also sends recognition | 23 // of them can use speech recognition at a time. It also sends recognition |
24 // results and status events to the render views when required. | 24 // results and status events to the render views when required. |
25 class CONTENT_EXPORT SpeechInputManager : public SpeechRecognizerDelegate { | 25 class CONTENT_EXPORT SpeechInputManager : public SpeechRecognizerDelegate { |
26 public: | 26 public: |
27 // Implemented by the dispatcher host to relay events to the render views. | 27 // Implemented by the dispatcher host to relay events to the render views. |
28 class Delegate { | 28 class Delegate { |
29 public: | 29 public: |
30 virtual void SetRecognitionResult( | 30 virtual void SetRecognitionResult( |
31 int caller_id, | 31 int caller_id, |
32 const SpeechInputResultArray& result) = 0; | 32 const SpeechInputResult& result) = 0; |
33 virtual void DidCompleteRecording(int caller_id) = 0; | 33 virtual void DidCompleteRecording(int caller_id) = 0; |
34 virtual void DidCompleteRecognition(int caller_id) = 0; | 34 virtual void DidCompleteRecognition(int caller_id) = 0; |
35 | 35 |
36 protected: | 36 protected: |
37 virtual ~Delegate() {} | 37 virtual ~Delegate() {} |
38 }; | 38 }; |
39 | 39 |
40 SpeechInputManager(); | 40 SpeechInputManager(); |
41 | 41 |
42 // Invokes the platform provided microphone settings UI in a non-blocking way, | 42 // Invokes the platform provided microphone settings UI in a non-blocking way, |
(...skipping 17 matching lines...) Expand all Loading... | |
60 const gfx::Rect& element_rect, | 60 const gfx::Rect& element_rect, |
61 const std::string& language, | 61 const std::string& language, |
62 const std::string& grammar, | 62 const std::string& grammar, |
63 const std::string& origin_url, | 63 const std::string& origin_url, |
64 net::URLRequestContextGetter* context_getter, | 64 net::URLRequestContextGetter* context_getter, |
65 SpeechInputPreferences* speech_input_prefs); | 65 SpeechInputPreferences* speech_input_prefs); |
66 virtual void CancelRecognition(int caller_id); | 66 virtual void CancelRecognition(int caller_id); |
67 virtual void CancelAllRequestsWithDelegate(Delegate* delegate); | 67 virtual void CancelAllRequestsWithDelegate(Delegate* delegate); |
68 virtual void StopRecording(int caller_id); | 68 virtual void StopRecording(int caller_id); |
69 | 69 |
70 // SpeechRecognizer::Delegate methods. | 70 // SpeechRecognizerDelegate methods. |
71 virtual void DidStartReceivingAudio(int caller_id); | 71 virtual void DidStartReceivingAudio(int caller_id); |
Satish
2011/10/06 09:09:06
OVERRIDE
Leandro GraciĆ” Gil
2011/10/06 18:26:25
Done.
| |
72 virtual void SetRecognitionResult(int caller_id, | 72 virtual void SetRecognitionResult(int caller_id, |
73 bool error, | 73 bool error, |
74 const SpeechInputResultArray& result); | 74 const SpeechInputResult& result) OVERRIDE; |
75 virtual void DidCompleteRecording(int caller_id); | 75 virtual void DidCompleteRecording(int caller_id) OVERRIDE; |
76 virtual void DidCompleteRecognition(int caller_id); | 76 virtual void DidCompleteRecognition(int caller_id) OVERRIDE; |
77 virtual void DidStartReceivingSpeech(int caller_id) OVERRIDE; | |
78 virtual void DidStopReceivingSpeech(int caller_id) OVERRIDE; | |
79 | |
77 virtual void OnRecognizerError(int caller_id, | 80 virtual void OnRecognizerError(int caller_id, |
78 SpeechRecognizer::ErrorCode error); | 81 SpeechInputError error) OVERRIDE; |
79 virtual void DidCompleteEnvironmentEstimation(int caller_id); | 82 virtual void DidCompleteEnvironmentEstimation(int caller_id) OVERRIDE; |
80 virtual void SetInputVolume(int caller_id, float volume, float noise_volume); | 83 virtual void SetInputVolume(int caller_id, float volume, |
84 float noise_volume) OVERRIDE; | |
81 | 85 |
82 protected: | 86 protected: |
83 // The pure virtual methods are used for displaying the current state of | 87 // The pure virtual methods are used for displaying the current state of |
84 // recognition and for fetching optional request information. | 88 // recognition and for fetching optional request information. |
85 | 89 |
86 // Get the optional request information if available. | 90 // Get the optional request information if available. |
87 virtual void GetRequestInfo(bool* can_report_metrics, | 91 virtual void GetRequestInfo(bool* can_report_metrics, |
88 std::string* request_info) = 0; | 92 std::string* request_info) = 0; |
89 | 93 |
90 // Called when recognition has been requested from point |element_rect_| on | 94 // Called when recognition has been requested from point |element_rect_| on |
(...skipping 15 matching lines...) Expand all Loading... | |
106 // Continuously updated with the current input volume. | 110 // Continuously updated with the current input volume. |
107 virtual void ShowInputVolume(int caller_id, | 111 virtual void ShowInputVolume(int caller_id, |
108 float volume, | 112 float volume, |
109 float noise_volume) = 0; | 113 float noise_volume) = 0; |
110 | 114 |
111 // Called when no microphone has been found. | 115 // Called when no microphone has been found. |
112 virtual void ShowNoMicError(int caller_id) = 0; | 116 virtual void ShowNoMicError(int caller_id) = 0; |
113 | 117 |
114 // Called when there has been a error with the recognition. | 118 // Called when there has been a error with the recognition. |
115 virtual void ShowRecognizerError(int caller_id, | 119 virtual void ShowRecognizerError(int caller_id, |
116 SpeechRecognizer::ErrorCode error) = 0; | 120 SpeechInputError error) = 0; |
117 | 121 |
118 // Called when recognition has ended or has been canceled. | 122 // Called when recognition has ended or has been canceled. |
119 virtual void DoClose(int caller_id) = 0; | 123 virtual void DoClose(int caller_id) = 0; |
120 | 124 |
121 // Cancels recognition for the specified caller if it is active. | 125 // Cancels recognition for the specified caller if it is active. |
122 void OnFocusChanged(int caller_id); | 126 void OnFocusChanged(int caller_id); |
123 | 127 |
124 bool HasPendingRequest(int caller_id) const; | 128 bool HasPendingRequest(int caller_id) const; |
125 | 129 |
126 // Starts/restarts recognition for an existing request. | 130 // Starts/restarts recognition for an existing request. |
(...skipping 22 matching lines...) Expand all Loading... | |
149 | 153 |
150 // This typedef is to workaround the issue with certain versions of | 154 // This typedef is to workaround the issue with certain versions of |
151 // Visual Studio where it gets confused between multiple Delegate | 155 // Visual Studio where it gets confused between multiple Delegate |
152 // classes and gives a C2500 error. (I saw this error on the try bots - | 156 // classes and gives a C2500 error. (I saw this error on the try bots - |
153 // the workaround was not needed for my machine). | 157 // the workaround was not needed for my machine). |
154 typedef SpeechInputManager::Delegate SpeechInputManagerDelegate; | 158 typedef SpeechInputManager::Delegate SpeechInputManagerDelegate; |
155 | 159 |
156 } // namespace speech_input | 160 } // namespace speech_input |
157 | 161 |
158 #endif // CONTENT_BROWSER_SPEECH_SPEECH_INPUT_MANAGER_H_ | 162 #endif // CONTENT_BROWSER_SPEECH_SPEECH_INPUT_MANAGER_H_ |
OLD | NEW |