| 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) OVERRIDE; |
| 72 virtual void SetRecognitionResult(int caller_id, | 72 virtual void SetRecognitionResult(int caller_id, |
| 73 bool error, | 73 const SpeechInputResult& result) OVERRIDE; |
| 74 const SpeechInputResultArray& result); | 74 virtual void DidCompleteRecording(int caller_id) OVERRIDE; |
| 75 virtual void DidCompleteRecording(int caller_id); | 75 virtual void DidCompleteRecognition(int caller_id) OVERRIDE; |
| 76 virtual void DidCompleteRecognition(int caller_id); | 76 virtual void DidStartReceivingSpeech(int caller_id) OVERRIDE; |
| 77 virtual void DidStopReceivingSpeech(int caller_id) OVERRIDE; |
| 78 |
| 77 virtual void OnRecognizerError(int caller_id, | 79 virtual void OnRecognizerError(int caller_id, |
| 78 SpeechRecognizer::ErrorCode error); | 80 SpeechInputError error) OVERRIDE; |
| 79 virtual void DidCompleteEnvironmentEstimation(int caller_id); | 81 virtual void DidCompleteEnvironmentEstimation(int caller_id) OVERRIDE; |
| 80 virtual void SetInputVolume(int caller_id, float volume, float noise_volume); | 82 virtual void SetInputVolume(int caller_id, float volume, |
| 83 float noise_volume) OVERRIDE; |
| 81 | 84 |
| 82 protected: | 85 protected: |
| 83 // The pure virtual methods are used for displaying the current state of | 86 // The pure virtual methods are used for displaying the current state of |
| 84 // recognition and for fetching optional request information. | 87 // recognition and for fetching optional request information. |
| 85 | 88 |
| 86 // Get the optional request information if available. | 89 // Get the optional request information if available. |
| 87 virtual void GetRequestInfo(bool* can_report_metrics, | 90 virtual void GetRequestInfo(bool* can_report_metrics, |
| 88 std::string* request_info) = 0; | 91 std::string* request_info) = 0; |
| 89 | 92 |
| 90 // Called when recognition has been requested from point |element_rect_| on | 93 // 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. | 109 // Continuously updated with the current input volume. |
| 107 virtual void ShowInputVolume(int caller_id, | 110 virtual void ShowInputVolume(int caller_id, |
| 108 float volume, | 111 float volume, |
| 109 float noise_volume) = 0; | 112 float noise_volume) = 0; |
| 110 | 113 |
| 111 // Called when no microphone has been found. | 114 // Called when no microphone has been found. |
| 112 virtual void ShowNoMicError(int caller_id) = 0; | 115 virtual void ShowNoMicError(int caller_id) = 0; |
| 113 | 116 |
| 114 // Called when there has been a error with the recognition. | 117 // Called when there has been a error with the recognition. |
| 115 virtual void ShowRecognizerError(int caller_id, | 118 virtual void ShowRecognizerError(int caller_id, |
| 116 SpeechRecognizer::ErrorCode error) = 0; | 119 SpeechInputError error) = 0; |
| 117 | 120 |
| 118 // Called when recognition has ended or has been canceled. | 121 // Called when recognition has ended or has been canceled. |
| 119 virtual void DoClose(int caller_id) = 0; | 122 virtual void DoClose(int caller_id) = 0; |
| 120 | 123 |
| 121 // Cancels recognition for the specified caller if it is active. | 124 // Cancels recognition for the specified caller if it is active. |
| 122 void OnFocusChanged(int caller_id); | 125 void OnFocusChanged(int caller_id); |
| 123 | 126 |
| 124 bool HasPendingRequest(int caller_id) const; | 127 bool HasPendingRequest(int caller_id) const; |
| 125 | 128 |
| 126 // Starts/restarts recognition for an existing request. | 129 // Starts/restarts recognition for an existing request. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 149 | 152 |
| 150 // This typedef is to workaround the issue with certain versions of | 153 // This typedef is to workaround the issue with certain versions of |
| 151 // Visual Studio where it gets confused between multiple Delegate | 154 // Visual Studio where it gets confused between multiple Delegate |
| 152 // classes and gives a C2500 error. (I saw this error on the try bots - | 155 // classes and gives a C2500 error. (I saw this error on the try bots - |
| 153 // the workaround was not needed for my machine). | 156 // the workaround was not needed for my machine). |
| 154 typedef SpeechInputManager::Delegate SpeechInputManagerDelegate; | 157 typedef SpeechInputManager::Delegate SpeechInputManagerDelegate; |
| 155 | 158 |
| 156 } // namespace speech_input | 159 } // namespace speech_input |
| 157 | 160 |
| 158 #endif // CONTENT_BROWSER_SPEECH_SPEECH_INPUT_MANAGER_H_ | 161 #endif // CONTENT_BROWSER_SPEECH_SPEECH_INPUT_MANAGER_H_ |
| OLD | NEW |