| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| 11 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
| 12 #include "base/thread_task_runner_handle.h" | 12 #include "base/thread_task_runner_handle.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "content/browser/browser_main_loop.h" | 14 #include "content/browser/browser_main_loop.h" |
| 15 #include "content/browser/renderer_host/media/media_stream_manager.h" | 15 #include "content/browser/renderer_host/media/media_stream_manager.h" |
| 16 #include "content/browser/renderer_host/media/media_stream_ui_proxy.h" | 16 #include "content/browser/renderer_host/media/media_stream_ui_proxy.h" |
| 17 #include "content/browser/speech/speech_recognition_engine.h" | 17 #include "content/browser/speech/speech_recognition_engine.h" |
| 18 #include "content/browser/speech/speech_recognizer_impl.h" | 18 #include "content/browser/speech/speech_recognizer_impl.h" |
| 19 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
| 20 #include "content/public/browser/content_browser_client.h" | 20 #include "content/public/browser/content_browser_client.h" |
| 21 #include "content/public/browser/resource_context.h" | 21 #include "content/public/browser/resource_context.h" |
| 22 #include "content/public/browser/speech_recognition_event_listener.h" | 22 #include "content/public/browser/speech_recognition_event_listener.h" |
| 23 #include "content/public/browser/speech_recognition_manager_delegate.h" | 23 #include "content/public/browser/speech_recognition_manager_delegate.h" |
| 24 #include "content/public/browser/speech_recognition_session_config.h" | 24 #include "content/public/browser/speech_recognition_session_config.h" |
| 25 #include "content/public/browser/speech_recognition_session_context.h" | 25 #include "content/public/browser/speech_recognition_session_context.h" |
| 26 #include "content/public/common/speech_recognition_error.h" | 26 #include "content/public/common/speech_recognition_error.h" |
| 27 #include "content/public/common/speech_recognition_result.h" | 27 #include "content/public/common/speech_recognition_result.h" |
| 28 #include "media/audio/audio_device_description.h" | 28 #include "media/audio/audio_device_description.h" |
| 29 #include "media/audio/audio_manager.h" | 29 #include "media/audio/audio_manager.h" |
| 30 #include "url/gurl.h" |
| 31 #include "url/origin.h" |
| 30 | 32 |
| 31 #if defined(OS_ANDROID) | 33 #if defined(OS_ANDROID) |
| 32 #include "content/browser/speech/speech_recognizer_impl_android.h" | 34 #include "content/browser/speech/speech_recognizer_impl_android.h" |
| 33 #endif | 35 #endif |
| 34 | 36 |
| 35 using base::Callback; | 37 using base::Callback; |
| 36 | 38 |
| 37 namespace content { | 39 namespace content { |
| 38 | 40 |
| 39 SpeechRecognitionManager* SpeechRecognitionManager::manager_for_tests_; | 41 SpeechRecognitionManager* SpeechRecognitionManager::manager_for_tests_; |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 DCHECK(iter != sessions_.end()); | 181 DCHECK(iter != sessions_.end()); |
| 180 Session* session = iter->second; | 182 Session* session = iter->second; |
| 181 | 183 |
| 182 if (session->abort_requested) | 184 if (session->abort_requested) |
| 183 return; | 185 return; |
| 184 | 186 |
| 185 if (ask_user) { | 187 if (ask_user) { |
| 186 SpeechRecognitionSessionContext& context = session->context; | 188 SpeechRecognitionSessionContext& context = session->context; |
| 187 context.label = media_stream_manager_->MakeMediaAccessRequest( | 189 context.label = media_stream_manager_->MakeMediaAccessRequest( |
| 188 context.render_process_id, context.render_frame_id, context.request_id, | 190 context.render_process_id, context.render_frame_id, context.request_id, |
| 189 StreamControls(true, false), GURL(context.context_name), | 191 StreamControls(true, false), url::Origin(GURL(context.context_name)), |
| 190 base::Bind( | 192 base::Bind( |
| 191 &SpeechRecognitionManagerImpl::MediaRequestPermissionCallback, | 193 &SpeechRecognitionManagerImpl::MediaRequestPermissionCallback, |
| 192 weak_factory_.GetWeakPtr(), session_id)); | 194 weak_factory_.GetWeakPtr(), session_id)); |
| 193 return; | 195 return; |
| 194 } | 196 } |
| 195 | 197 |
| 196 if (is_allowed) { | 198 if (is_allowed) { |
| 197 base::ThreadTaskRunnerHandle::Get()->PostTask( | 199 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 198 FROM_HERE, | 200 FROM_HERE, |
| 199 base::Bind(&SpeechRecognitionManagerImpl::DispatchEvent, | 201 base::Bind(&SpeechRecognitionManagerImpl::DispatchEvent, |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 SpeechRecognitionManagerImpl::Session::Session() | 668 SpeechRecognitionManagerImpl::Session::Session() |
| 667 : id(kSessionIDInvalid), | 669 : id(kSessionIDInvalid), |
| 668 abort_requested(false), | 670 abort_requested(false), |
| 669 listener_is_active(true) { | 671 listener_is_active(true) { |
| 670 } | 672 } |
| 671 | 673 |
| 672 SpeechRecognitionManagerImpl::Session::~Session() { | 674 SpeechRecognitionManagerImpl::Session::~Session() { |
| 673 } | 675 } |
| 674 | 676 |
| 675 } // namespace content | 677 } // namespace content |
| OLD | NEW |