| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CHROME_BROWSER_SPEECH_SPEECH_INPUT_EXTENSION_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_SPEECH_SPEECH_INPUT_EXTENSION_MANAGER_H_ |
| 6 #define CHROME_BROWSER_SPEECH_SPEECH_INPUT_EXTENSION_MANAGER_H_ | 6 #define CHROME_BROWSER_SPEECH_SPEECH_INPUT_EXTENSION_MANAGER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 virtual void StartRecording( | 38 virtual void StartRecording( |
| 39 content::SpeechRecognizerDelegate* delegate, | 39 content::SpeechRecognizerDelegate* delegate, |
| 40 net::URLRequestContextGetter* context_getter, | 40 net::URLRequestContextGetter* context_getter, |
| 41 int caller_id, | 41 int caller_id, |
| 42 const std::string& language, | 42 const std::string& language, |
| 43 const std::string& grammar, | 43 const std::string& grammar, |
| 44 bool filter_profanities) = 0; | 44 bool filter_profanities) = 0; |
| 45 | 45 |
| 46 virtual void StopRecording(bool recognition_failed) = 0; | 46 virtual void StopRecording(bool recognition_failed) = 0; |
| 47 virtual bool HasAudioInputDevices() = 0; | 47 virtual bool HasAudioInputDevices() = 0; |
| 48 virtual bool IsRecordingInProcess() = 0; | 48 virtual bool IsCapturingAudio() = 0; |
| 49 | 49 |
| 50 // Called from the UI thread. | 50 // Called from the UI thread. |
| 51 virtual bool HasValidRecognizer() = 0; | 51 virtual bool HasValidRecognizer() = 0; |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 // Manages the speech input requests and responses from the extensions | 54 // Manages the speech input requests and responses from the extensions |
| 55 // associated to the given profile. | 55 // associated to the given profile. |
| 56 class SpeechInputExtensionManager | 56 class SpeechInputExtensionManager |
| 57 : public base::RefCountedThreadSafe<SpeechInputExtensionManager>, | 57 : public base::RefCountedThreadSafe<SpeechInputExtensionManager>, |
| 58 public content::SpeechRecognizerDelegate, | 58 public content::SpeechRecognizerDelegate, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 void ShutdownOnUIThread(); | 110 void ShutdownOnUIThread(); |
| 111 | 111 |
| 112 // Methods from content::NotificationObserver. | 112 // Methods from content::NotificationObserver. |
| 113 virtual void Observe(int type, | 113 virtual void Observe(int type, |
| 114 const content::NotificationSource& source, | 114 const content::NotificationSource& source, |
| 115 const content::NotificationDetails& details) OVERRIDE; | 115 const content::NotificationDetails& details) OVERRIDE; |
| 116 | 116 |
| 117 // Methods from SpeechRecognizerDelegate. | 117 // Methods from SpeechRecognizerDelegate. |
| 118 virtual void SetRecognitionResult( | 118 virtual void SetRecognitionResult( |
| 119 int caller_id, | 119 int caller_id, |
| 120 const content::SpeechInputResult& result) OVERRIDE; | 120 const content::SpeechRecognitionResult& result) OVERRIDE; |
| 121 | 121 |
| 122 virtual void DidStartReceivingAudio(int caller_id) OVERRIDE; | 122 virtual void DidStartReceivingAudio(int caller_id) OVERRIDE; |
| 123 virtual void DidCompleteRecording(int caller_id) OVERRIDE; | 123 virtual void DidCompleteRecording(int caller_id) OVERRIDE; |
| 124 virtual void DidCompleteRecognition(int caller_id) OVERRIDE; | 124 virtual void DidCompleteRecognition(int caller_id) OVERRIDE; |
| 125 virtual void DidStartReceivingSpeech(int caller_id) OVERRIDE; | 125 virtual void DidStartReceivingSpeech(int caller_id) OVERRIDE; |
| 126 virtual void DidStopReceivingSpeech(int caller_id) OVERRIDE; | 126 virtual void DidStopReceivingSpeech(int caller_id) OVERRIDE; |
| 127 virtual void OnRecognizerError(int caller_id, | 127 virtual void OnRecognizerError(int caller_id, |
| 128 content::SpeechInputError error) | 128 content::SpeechRecognitionErrorCode error) |
| 129 OVERRIDE; | 129 OVERRIDE; |
| 130 virtual void DidCompleteEnvironmentEstimation(int caller_id) OVERRIDE; | 130 virtual void DidCompleteEnvironmentEstimation(int caller_id) OVERRIDE; |
| 131 virtual void SetInputVolume(int caller_id, float volume, | 131 virtual void SetInputVolume(int caller_id, float volume, |
| 132 float noise_volume) OVERRIDE; | 132 float noise_volume) OVERRIDE; |
| 133 | 133 |
| 134 // Methods for API testing. | 134 // Methods for API testing. |
| 135 void SetSpeechInputExtensionInterface( | 135 void SetSpeechInputExtensionInterface( |
| 136 SpeechInputExtensionInterface* interface); | 136 SpeechInputExtensionInterface* interface); |
| 137 SpeechInputExtensionInterface* GetSpeechInputExtensionInterface(); | 137 SpeechInputExtensionInterface* GetSpeechInputExtensionInterface(); |
| 138 | 138 |
| 139 private: | 139 private: |
| 140 // SpeechInputExtensionInterface methods: | 140 // SpeechInputExtensionInterface methods: |
| 141 virtual bool IsRecordingInProcess() OVERRIDE; | 141 virtual bool IsCapturingAudio() OVERRIDE; |
| 142 virtual bool HasAudioInputDevices() OVERRIDE; | 142 virtual bool HasAudioInputDevices() OVERRIDE; |
| 143 virtual bool HasValidRecognizer() OVERRIDE; | 143 virtual bool HasValidRecognizer() OVERRIDE; |
| 144 virtual void StartRecording( | 144 virtual void StartRecording( |
| 145 content::SpeechRecognizerDelegate* delegate, | 145 content::SpeechRecognizerDelegate* delegate, |
| 146 net::URLRequestContextGetter* context_getter, | 146 net::URLRequestContextGetter* context_getter, |
| 147 int caller_id, | 147 int caller_id, |
| 148 const std::string& language, | 148 const std::string& language, |
| 149 const std::string& grammar, | 149 const std::string& grammar, |
| 150 bool filter_profanities) OVERRIDE; | 150 bool filter_profanities) OVERRIDE; |
| 151 | 151 |
| 152 virtual void StopRecording(bool recognition_failed) OVERRIDE; | 152 virtual void StopRecording(bool recognition_failed) OVERRIDE; |
| 153 | 153 |
| 154 // Internal methods. | 154 // Internal methods. |
| 155 void StartOnIOThread( | 155 void StartOnIOThread( |
| 156 net::URLRequestContextGetter* context_getter, | 156 net::URLRequestContextGetter* context_getter, |
| 157 const std::string& language, | 157 const std::string& language, |
| 158 const std::string& grammar, | 158 const std::string& grammar, |
| 159 bool filter_profanities); | 159 bool filter_profanities); |
| 160 void ForceStopOnIOThread(); | 160 void ForceStopOnIOThread(); |
| 161 void IsRecordingOnIOThread(const IsRecordingCallback& callback); | 161 void IsRecordingOnIOThread(const IsRecordingCallback& callback); |
| 162 | 162 |
| 163 void SetRecognitionResultOnUIThread( | 163 void SetRecognitionResultOnUIThread( |
| 164 const content::SpeechInputResult& result, | 164 const content::SpeechRecognitionResult& result, |
| 165 const std::string& extension_id); | 165 const std::string& extension_id); |
| 166 void DidStartReceivingAudioOnUIThread(); | 166 void DidStartReceivingAudioOnUIThread(); |
| 167 void StopSucceededOnUIThread(); | 167 void StopSucceededOnUIThread(); |
| 168 void IsRecordingOnUIThread(const IsRecordingCallback& callback, bool result); | 168 void IsRecordingOnUIThread(const IsRecordingCallback& callback, bool result); |
| 169 | 169 |
| 170 void DispatchError(const std::string& error, bool dispatch_event); | 170 void DispatchError(const std::string& error, bool dispatch_event); |
| 171 void DispatchEventToExtension(const std::string& extension_id, | 171 void DispatchEventToExtension(const std::string& extension_id, |
| 172 const std::string& event, | 172 const std::string& event, |
| 173 const std::string& json_args); | 173 const std::string& json_args); |
| 174 void ExtensionUnloaded(const std::string& extension_id); | 174 void ExtensionUnloaded(const std::string& extension_id); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 197 // Used in the UI thread. | 197 // Used in the UI thread. |
| 198 scoped_ptr<content::NotificationRegistrar> registrar_; | 198 scoped_ptr<content::NotificationRegistrar> registrar_; |
| 199 SpeechInputExtensionInterface* speech_interface_; | 199 SpeechInputExtensionInterface* speech_interface_; |
| 200 scoped_ptr<SpeechInputExtensionNotification> notification_; | 200 scoped_ptr<SpeechInputExtensionNotification> notification_; |
| 201 | 201 |
| 202 // Used in the IO thread. | 202 // Used in the IO thread. |
| 203 scoped_refptr<content::SpeechRecognizer> recognizer_; | 203 scoped_refptr<content::SpeechRecognizer> recognizer_; |
| 204 }; | 204 }; |
| 205 | 205 |
| 206 #endif // CHROME_BROWSER_SPEECH_SPEECH_INPUT_EXTENSION_MANAGER_H_ | 206 #endif // CHROME_BROWSER_SPEECH_SPEECH_INPUT_EXTENSION_MANAGER_H_ |
| OLD | NEW |