Chromium Code Reviews| 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/render_frame_host.h" | |
| 18 #include "content/public/browser/render_process_host.h" | |
| 19 #include "content/public/browser/render_view_host.h" | |
| 17 #include "content/public/browser/resource_context.h" | 20 #include "content/public/browser/resource_context.h" |
| 18 #include "content/public/browser/speech_recognition_event_listener.h" | 21 #include "content/public/browser/speech_recognition_event_listener.h" |
| 19 #include "content/public/browser/speech_recognition_manager_delegate.h" | 22 #include "content/public/browser/speech_recognition_manager_delegate.h" |
| 20 #include "content/public/browser/speech_recognition_session_config.h" | 23 #include "content/public/browser/speech_recognition_session_config.h" |
| 21 #include "content/public/browser/speech_recognition_session_context.h" | 24 #include "content/public/browser/speech_recognition_session_context.h" |
| 22 #include "content/public/common/speech_recognition_error.h" | 25 #include "content/public/common/speech_recognition_error.h" |
| 23 #include "content/public/common/speech_recognition_result.h" | 26 #include "content/public/common/speech_recognition_result.h" |
| 24 #include "media/audio/audio_manager.h" | 27 #include "media/audio/audio_manager.h" |
| 25 #include "media/audio/audio_manager_base.h" | 28 #include "media/audio/audio_manager_base.h" |
| 26 | 29 |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 187 | 190 |
| 188 SessionsTable::iterator iter = sessions_.find(session_id); | 191 SessionsTable::iterator iter = sessions_.find(session_id); |
| 189 DCHECK(iter != sessions_.end()); | 192 DCHECK(iter != sessions_.end()); |
| 190 Session* session = iter->second; | 193 Session* session = iter->second; |
| 191 | 194 |
| 192 if (session->abort_requested) | 195 if (session->abort_requested) |
| 193 return; | 196 return; |
| 194 | 197 |
| 195 if (ask_user) { | 198 if (ask_user) { |
| 196 SpeechRecognitionSessionContext& context = session->context; | 199 SpeechRecognitionSessionContext& context = session->context; |
| 197 context.label = media_stream_manager_->MakeMediaAccessRequest( | 200 // TODO(miu): This is a hack to allow SpeechRecognition to operate with the |
| 198 context.render_process_id, | 201 // MediaStreamManager, which partitions requests per RenderFrame, not per |
| 199 context.render_view_id, | 202 // RenderView. http://crbug.com/390749 |
| 200 context.request_id, | 203 RenderViewHost* const rvh = RenderViewHost::FromID( |
| 201 StreamOptions(true, false), | 204 context.render_process_id, context.render_view_id); |
|
ncarter (slow)
2014/07/11 22:32:25
This code seems misplaced; you can't get an RVH on
miu
2014/07/12 03:16:29
Done. Yeah, I oops'ed; and also noticed the trybo
| |
| 202 GURL(context.context_name), | 205 RenderFrameHost* const main_frame = rvh ? rvh->GetMainFrame() : NULL; |
| 203 base::Bind( | 206 if (main_frame) { |
| 204 &SpeechRecognitionManagerImpl::MediaRequestPermissionCallback, | 207 context.label = media_stream_manager_->MakeMediaAccessRequest( |
| 205 weak_factory_.GetWeakPtr(), session_id)); | 208 main_frame->GetProcess()->GetID(), |
| 209 main_frame->GetRoutingID(), | |
| 210 context.request_id, | |
| 211 StreamOptions(true, false), | |
| 212 GURL(context.context_name), | |
| 213 base::Bind( | |
| 214 &SpeechRecognitionManagerImpl::MediaRequestPermissionCallback, | |
| 215 weak_factory_.GetWeakPtr(), session_id)); | |
| 216 } | |
| 206 return; | 217 return; |
| 207 } | 218 } |
| 208 | 219 |
| 209 if (is_allowed) { | 220 if (is_allowed) { |
| 210 base::MessageLoop::current()->PostTask( | 221 base::MessageLoop::current()->PostTask( |
| 211 FROM_HERE, | 222 FROM_HERE, |
| 212 base::Bind(&SpeechRecognitionManagerImpl::DispatchEvent, | 223 base::Bind(&SpeechRecognitionManagerImpl::DispatchEvent, |
| 213 weak_factory_.GetWeakPtr(), | 224 weak_factory_.GetWeakPtr(), |
| 214 session_id, | 225 session_id, |
| 215 EVENT_START)); | 226 EVENT_START)); |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 691 SpeechRecognitionManagerImpl::Session::Session() | 702 SpeechRecognitionManagerImpl::Session::Session() |
| 692 : id(kSessionIDInvalid), | 703 : id(kSessionIDInvalid), |
| 693 abort_requested(false), | 704 abort_requested(false), |
| 694 listener_is_active(true) { | 705 listener_is_active(true) { |
| 695 } | 706 } |
| 696 | 707 |
| 697 SpeechRecognitionManagerImpl::Session::~Session() { | 708 SpeechRecognitionManagerImpl::Session::~Session() { |
| 698 } | 709 } |
| 699 | 710 |
| 700 } // namespace content | 711 } // namespace content |
| OLD | NEW |