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 "base/synchronization/lock.h" | 9 #include "base/synchronization/lock.h" |
10 #include "content/browser/speech/speech_recognizer.h" | 10 #include "content/browser/speech/speech_recognizer.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 // Used for API tests. | 27 // Used for API tests. |
28 class SpeechInputExtensionInterface { | 28 class SpeechInputExtensionInterface { |
29 public: | 29 public: |
30 SpeechInputExtensionInterface(); | 30 SpeechInputExtensionInterface(); |
31 virtual ~SpeechInputExtensionInterface(); | 31 virtual ~SpeechInputExtensionInterface(); |
32 | 32 |
33 // Called from the IO thread. | 33 // Called from the IO thread. |
34 virtual void StartRecording( | 34 virtual void StartRecording( |
35 speech_input::SpeechRecognizerDelegate* delegate, | 35 speech_input::SpeechRecognizerDelegate* delegate, |
36 net::URLRequestContextGetter* context_getter, | 36 net::URLRequestContextGetter* context_getter, |
37 const content::ResourceContext* resource_context, | 37 content::ResourceContext* resource_context, |
38 int caller_id, | 38 int caller_id, |
39 const std::string& language, | 39 const std::string& language, |
40 const std::string& grammar, | 40 const std::string& grammar, |
41 bool filter_profanities) = 0; | 41 bool filter_profanities) = 0; |
42 | 42 |
43 virtual void StopRecording(bool recognition_failed) = 0; | 43 virtual void StopRecording(bool recognition_failed) = 0; |
44 virtual bool HasAudioInputDevices( | 44 virtual bool HasAudioInputDevices( |
45 const content::ResourceContext* resource_context) = 0; | 45 content::ResourceContext* resource_context) = 0; |
46 virtual bool IsRecordingInProcess( | 46 virtual bool IsRecordingInProcess( |
47 const content::ResourceContext* resource_context) = 0; | 47 content::ResourceContext* resource_context) = 0; |
48 | 48 |
49 // Called from the UI thread. | 49 // Called from the UI thread. |
50 virtual bool HasValidRecognizer() = 0; | 50 virtual bool HasValidRecognizer() = 0; |
51 | 51 |
52 protected: | 52 protected: |
53 scoped_refptr<speech_input::SpeechRecognizer> recognizer_; | 53 scoped_refptr<speech_input::SpeechRecognizer> recognizer_; |
54 }; | 54 }; |
55 | 55 |
56 // Manages the speech input requests and responses from the extensions | 56 // Manages the speech input requests and responses from the extensions |
57 // associated to the given profile. | 57 // associated to the given profile. |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 float noise_volume) OVERRIDE; | 134 float noise_volume) OVERRIDE; |
135 | 135 |
136 // Methods for API testing. | 136 // Methods for API testing. |
137 void SetSpeechInputExtensionInterface( | 137 void SetSpeechInputExtensionInterface( |
138 SpeechInputExtensionInterface* interface); | 138 SpeechInputExtensionInterface* interface); |
139 SpeechInputExtensionInterface* GetSpeechInputExtensionInterface(); | 139 SpeechInputExtensionInterface* GetSpeechInputExtensionInterface(); |
140 | 140 |
141 private: | 141 private: |
142 // SpeechInputExtensionInterface methods: | 142 // SpeechInputExtensionInterface methods: |
143 virtual bool IsRecordingInProcess( | 143 virtual bool IsRecordingInProcess( |
144 const content::ResourceContext* resource_context) OVERRIDE; | 144 content::ResourceContext* resource_context) OVERRIDE; |
145 virtual bool HasAudioInputDevices( | 145 virtual bool HasAudioInputDevices( |
146 const content::ResourceContext* resource_context) OVERRIDE; | 146 content::ResourceContext* resource_context) OVERRIDE; |
147 virtual bool HasValidRecognizer() OVERRIDE; | 147 virtual bool HasValidRecognizer() OVERRIDE; |
148 | 148 |
149 virtual void StartRecording( | 149 virtual void StartRecording( |
150 speech_input::SpeechRecognizerDelegate* delegate, | 150 speech_input::SpeechRecognizerDelegate* delegate, |
151 net::URLRequestContextGetter* context_getter, | 151 net::URLRequestContextGetter* context_getter, |
152 const content::ResourceContext* resource_context, | 152 content::ResourceContext* resource_context, |
153 int caller_id, | 153 int caller_id, |
154 const std::string& language, | 154 const std::string& language, |
155 const std::string& grammar, | 155 const std::string& grammar, |
156 bool filter_profanities) OVERRIDE; | 156 bool filter_profanities) OVERRIDE; |
157 | 157 |
158 virtual void StopRecording(bool recognition_failed) OVERRIDE; | 158 virtual void StopRecording(bool recognition_failed) OVERRIDE; |
159 | 159 |
160 // Internal methods. | 160 // Internal methods. |
161 void StartOnIOThread( | 161 void StartOnIOThread( |
162 net::URLRequestContextGetter* context_getter, | 162 net::URLRequestContextGetter* context_getter, |
163 const content::ResourceContext* resource_context, | 163 content::ResourceContext* resource_context, |
164 const std::string& language, | 164 const std::string& language, |
165 const std::string& grammar, | 165 const std::string& grammar, |
166 bool filter_profanities); | 166 bool filter_profanities); |
167 void ForceStopOnIOThread(); | 167 void ForceStopOnIOThread(); |
168 void IsRecordingOnIOThread(const IsRecordingCallback& callback, | 168 void IsRecordingOnIOThread(const IsRecordingCallback& callback, |
169 const content::ResourceContext* resource_context); | 169 content::ResourceContext* resource_context); |
170 | 170 |
171 void SetRecognitionResultOnUIThread( | 171 void SetRecognitionResultOnUIThread( |
172 const content::SpeechInputResult& result, | 172 const content::SpeechInputResult& result, |
173 const std::string& extension_id); | 173 const std::string& extension_id); |
174 void DidStartReceivingAudioOnUIThread(); | 174 void DidStartReceivingAudioOnUIThread(); |
175 void StopSucceededOnUIThread(); | 175 void StopSucceededOnUIThread(); |
176 void IsRecordingOnUIThread(const IsRecordingCallback& callback, bool result); | 176 void IsRecordingOnUIThread(const IsRecordingCallback& callback, bool result); |
177 | 177 |
178 void DispatchError(const std::string& error, bool dispatch_event); | 178 void DispatchError(const std::string& error, bool dispatch_event); |
179 void DispatchEventToExtension(const std::string& extension_id, | 179 void DispatchEventToExtension(const std::string& extension_id, |
(...skipping 22 matching lines...) Expand all Loading... |
202 State state_; | 202 State state_; |
203 std::string extension_id_in_use_; | 203 std::string extension_id_in_use_; |
204 | 204 |
205 // Used in the UI thread. | 205 // Used in the UI thread. |
206 scoped_ptr<content::NotificationRegistrar> registrar_; | 206 scoped_ptr<content::NotificationRegistrar> registrar_; |
207 SpeechInputExtensionInterface* speech_interface_; | 207 SpeechInputExtensionInterface* speech_interface_; |
208 scoped_ptr<SpeechInputExtensionNotification> notification_; | 208 scoped_ptr<SpeechInputExtensionNotification> notification_; |
209 }; | 209 }; |
210 | 210 |
211 #endif // CHROME_BROWSER_SPEECH_SPEECH_INPUT_EXTENSION_MANAGER_H_ | 211 #endif // CHROME_BROWSER_SPEECH_SPEECH_INPUT_EXTENSION_MANAGER_H_ |
OLD | NEW |