Index: content/browser/speech/speech_input_manager.h |
diff --git a/content/browser/speech/speech_input_manager.h b/content/browser/speech/speech_input_manager.h |
index dbfcf1f19d457461eb7d3997e626e8b8d43966a6..0f9b5e441563b682d06889554d8c200a054dc2cd 100644 |
--- a/content/browser/speech/speech_input_manager.h |
+++ b/content/browser/speech/speech_input_manager.h |
@@ -5,7 +5,11 @@ |
#ifndef CONTENT_BROWSER_SPEECH_SPEECH_INPUT_MANAGER_H_ |
#define CONTENT_BROWSER_SPEECH_SPEECH_INPUT_MANAGER_H_ |
+#include <map> |
+#include <string> |
+ |
#include "base/basictypes.h" |
+#include "content/browser/speech/speech_recognizer.h" |
#include "content/common/speech_input_result.h" |
#include "ui/gfx/rect.h" |
@@ -15,7 +19,7 @@ namespace speech_input { |
// handles requests received from various render views and makes sure only one |
// of them can use speech recognition at a time. It also sends recognition |
// results and status events to the render views when required. |
-class SpeechInputManager { |
+class SpeechInputManager : public SpeechRecognizerDelegate { |
public: |
// Implemented by the dispatcher host to relay events to the render views. |
class Delegate { |
@@ -46,24 +50,78 @@ class SpeechInputManager { |
// request. |
// |element_rect| is the display bounds of the html element requesting speech |
// input (in page coordinates). |
- virtual void StartRecognition(Delegate* delegate, |
- int caller_id, |
- int render_process_id, |
- int render_view_id, |
- const gfx::Rect& element_rect, |
- const std::string& language, |
- const std::string& grammar, |
- const std::string& origin_url) = 0; |
- virtual void CancelRecognition(int caller_id) = 0; |
- virtual void StopRecording(int caller_id) = 0; |
- |
- virtual void CancelAllRequestsWithDelegate(Delegate* delegate) = 0; |
+ void StartRecognition(Delegate* delegate, |
+ int caller_id, |
+ int render_process_id, |
+ int render_view_id, |
+ const gfx::Rect& element_rect, |
+ const std::string& language, |
+ const std::string& grammar, |
+ const std::string& origin_url); |
+ void CancelRecognition(int caller_id); |
+ void CancelAllRequestsWithDelegate(Delegate* delegate); |
+ void StopRecording(int caller_id); |
+ |
+ // SpeechRecognizer::Delegate methods. |
+ virtual void DidStartReceivingAudio(int caller_id); |
+ virtual void SetRecognitionResult(int caller_id, |
+ bool error, |
+ const SpeechInputResultArray& result); |
+ virtual void DidCompleteRecording(int caller_id); |
+ virtual void DidCompleteRecognition(int caller_id); |
+ virtual void OnRecognizerError(int caller_id, |
+ SpeechRecognizer::ErrorCode error); |
+ virtual void DidCompleteEnvironmentEstimation(int caller_id); |
+ virtual void SetInputVolume(int caller_id, float volume, float noise_volume); |
void set_censor_results(bool censor) { censor_results_ = censor; } |
bool censor_results() { return censor_results_; } |
+ protected: |
+ virtual void CreateBubble(int caller_id, |
Satish
2011/09/12 12:23:05
add comments for each of these explaining what the
allanwoj
2011/09/19 18:30:38
Done.
|
+ int render_process_id, |
+ int render_view_id, |
+ const gfx::Rect& element_rect) = 0; |
+ virtual void FetchRequestInfo() = 0; |
+ virtual void NoMicBubbleMessage(int caller_id) = 0; |
Satish
2011/09/12 12:23:05
perhaps rename this to HandleNoMicError() similar
allanwoj
2011/09/19 18:30:38
Done.
|
+ virtual void CloseBubble(int caller_id) = 0; |
Satish
2011/09/12 12:23:05
Since we are separating chrome/ from content/, we
allanwoj
2011/09/19 18:30:38
Done.
|
+ virtual void SetBubbleWarmUpMode(int caller_id) = 0; |
+ virtual void SetBubbleRecognizingMode(int caller_id) = 0; |
+ virtual void SetBubbleRecordingMode(int caller_id) = 0; |
+ virtual void SetBubbleInputVolume(int caller_id, |
+ float volume, |
+ float noise_volume) = 0; |
+ virtual void HandleRecognizerError(int caller_id, |
+ SpeechRecognizer::ErrorCode error) = 0; |
+ |
+ void OnFocusChanged(int caller_id); |
Satish
2011/09/12 12:23:05
add explanatory comment since this is used by the
allanwoj
2011/09/19 18:30:38
Added comment but left the name as it is, as I hav
|
+ |
+ bool HasPendingRequest(int caller_id) const; |
+ |
+ // Starts/restarts recognition for an existing request. |
+ void StartRecognitionForRequest(int caller_id); |
+ |
+ void CancelRecognitionAndInformDelegate(int caller_id); |
+ |
+ std::string request_info_; |
+ bool can_report_metrics_; |
+ |
private: |
+ struct SpeechInputRequest { |
+ SpeechInputRequest(); |
+ ~SpeechInputRequest(); |
+ |
+ Delegate* delegate; |
+ scoped_refptr<SpeechRecognizer> recognizer; |
+ bool is_active; // Set to true when recording or recognition is going on. |
+ }; |
+ |
+ Delegate* GetDelegate(int caller_id) const; |
+ |
+ typedef std::map<int, SpeechInputRequest> SpeechRecognizerMap; |
+ SpeechRecognizerMap requests_; |
+ int recording_caller_id_; |
bool censor_results_; |
}; |