| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #include "content/browser/speech/speech_recognition_manager_impl.h" | 5 #include "content/browser/speech/speech_recognition_manager_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "content/browser/browser_main_loop.h" | 8 #include "content/browser/browser_main_loop.h" |
| 9 #include "content/browser/renderer_host/media/media_stream_manager.h" | 9 #include "content/browser/renderer_host/media/media_stream_manager.h" |
| 10 #include "content/browser/renderer_host/media/media_stream_ui_proxy.h" | 10 #include "content/browser/renderer_host/media/media_stream_ui_proxy.h" |
| 11 #include "content/browser/speech/google_one_shot_remote_engine.h" | 11 #include "content/browser/speech/google_one_shot_remote_engine.h" |
| 12 #include "content/browser/speech/google_streaming_remote_engine.h" | 12 #include "content/browser/speech/google_streaming_remote_engine.h" |
| 13 #include "content/browser/speech/speech_recognition_engine.h" | 13 #include "content/browser/speech/speech_recognition_engine.h" |
| 14 #include "content/browser/speech/speech_recognizer_impl.h" | 14 #include "content/browser/speech/speech_recognizer_impl.h" |
| 15 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
| 16 #include "content/public/browser/content_browser_client.h" | 16 #include "content/public/browser/content_browser_client.h" |
| 17 #include "content/public/browser/resource_context.h" | 17 #include "content/public/browser/resource_context.h" |
| 18 #include "content/public/browser/speech_recognition_event_listener.h" | 18 #include "content/public/browser/speech_recognition_event_listener.h" |
| 19 #include "content/public/browser/speech_recognition_manager_delegate.h" | 19 #include "content/public/browser/speech_recognition_manager_delegate.h" |
| 20 #include "content/public/browser/speech_recognition_session_config.h" | 20 #include "content/public/browser/speech_recognition_session_config.h" |
| 21 #include "content/public/browser/speech_recognition_session_context.h" | 21 #include "content/public/browser/speech_recognition_session_context.h" |
| 22 #include "content/public/common/speech_recognition_error.h" | 22 #include "content/public/common/speech_recognition_error.h" |
| 23 #include "content/public/common/speech_recognition_result.h" | 23 #include "content/public/common/speech_recognition_result.h" |
| 24 #include "media/audio/audio_manager.h" | 24 #include "media/audio/audio_manager.h" |
| 25 | 25 |
| 26 #if defined(OS_ANDROID) |
| 27 #include "content/browser/speech/speech_recognizer_impl_android.h" |
| 28 #endif |
| 29 |
| 26 using base::Callback; | 30 using base::Callback; |
| 27 | 31 |
| 28 namespace content { | 32 namespace content { |
| 29 | 33 |
| 30 SpeechRecognitionManager* SpeechRecognitionManager::manager_for_tests_; | 34 SpeechRecognitionManager* SpeechRecognitionManager::manager_for_tests_; |
| 31 | 35 |
| 32 namespace { | 36 namespace { |
| 33 | 37 |
| 34 SpeechRecognitionManagerImpl* g_speech_recognition_manager_impl; | 38 SpeechRecognitionManagerImpl* g_speech_recognition_manager_impl; |
| 35 | 39 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 } | 138 } |
| 135 | 139 |
| 136 google_remote_engine->SetConfig(remote_engine_config); | 140 google_remote_engine->SetConfig(remote_engine_config); |
| 137 | 141 |
| 138 session->recognizer = new SpeechRecognizerImpl( | 142 session->recognizer = new SpeechRecognizerImpl( |
| 139 this, | 143 this, |
| 140 session_id, | 144 session_id, |
| 141 !config.continuous, | 145 !config.continuous, |
| 142 google_remote_engine); | 146 google_remote_engine); |
| 143 #else | 147 #else |
| 144 // TODO(janx): Implement a SpeechRecognizerImplAndroid with a JNI interface | 148 session->recognizer = new SpeechRecognizerImplAndroid(this, session_id); |
| 145 // forwarding calls to Android's platform speech recognition service (see | |
| 146 // crbug.com/222352). | |
| 147 session->recognizer = NULL; | |
| 148 #endif | 149 #endif |
| 149 return session_id; | 150 return session_id; |
| 150 } | 151 } |
| 151 | 152 |
| 152 void SpeechRecognitionManagerImpl::StartSession(int session_id) { | 153 void SpeechRecognitionManagerImpl::StartSession(int session_id) { |
| 153 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 154 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 154 if (!SessionExists(session_id)) | 155 if (!SessionExists(session_id)) |
| 155 return; | 156 return; |
| 156 | 157 |
| 157 // If there is another active session, abort that. | 158 // If there is another active session, abort that. |
| (...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 659 | 660 |
| 660 SpeechRecognitionManagerImpl::Session::Session() | 661 SpeechRecognitionManagerImpl::Session::Session() |
| 661 : id(kSessionIDInvalid), | 662 : id(kSessionIDInvalid), |
| 662 listener_is_active(true) { | 663 listener_is_active(true) { |
| 663 } | 664 } |
| 664 | 665 |
| 665 SpeechRecognitionManagerImpl::Session::~Session() { | 666 SpeechRecognitionManagerImpl::Session::~Session() { |
| 666 } | 667 } |
| 667 | 668 |
| 668 } // namespace content | 669 } // namespace content |
| OLD | NEW |