| 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 #include "content/browser/speech/speech_recognition_dispatcher_host.h" | 5 #include "content/browser/speech/speech_recognition_dispatcher_host.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "content/browser/browser_plugin/browser_plugin_guest.h" | 10 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 const IPC::Message& message, bool* message_was_ok) { | 48 const IPC::Message& message, bool* message_was_ok) { |
| 49 bool handled = true; | 49 bool handled = true; |
| 50 IPC_BEGIN_MESSAGE_MAP_EX(SpeechRecognitionDispatcherHost, message, | 50 IPC_BEGIN_MESSAGE_MAP_EX(SpeechRecognitionDispatcherHost, message, |
| 51 *message_was_ok) | 51 *message_was_ok) |
| 52 IPC_MESSAGE_HANDLER(SpeechRecognitionHostMsg_StartRequest, | 52 IPC_MESSAGE_HANDLER(SpeechRecognitionHostMsg_StartRequest, |
| 53 OnStartRequest) | 53 OnStartRequest) |
| 54 IPC_MESSAGE_HANDLER(SpeechRecognitionHostMsg_AbortRequest, | 54 IPC_MESSAGE_HANDLER(SpeechRecognitionHostMsg_AbortRequest, |
| 55 OnAbortRequest) | 55 OnAbortRequest) |
| 56 IPC_MESSAGE_HANDLER(SpeechRecognitionHostMsg_StopCaptureRequest, | 56 IPC_MESSAGE_HANDLER(SpeechRecognitionHostMsg_StopCaptureRequest, |
| 57 OnStopCaptureRequest) | 57 OnStopCaptureRequest) |
| 58 IPC_MESSAGE_HANDLER(SpeechRecognitionHostMsg_AbortAllRequests, |
| 59 OnAbortAllRequests) |
| 58 IPC_MESSAGE_UNHANDLED(handled = false) | 60 IPC_MESSAGE_UNHANDLED(handled = false) |
| 59 IPC_END_MESSAGE_MAP() | 61 IPC_END_MESSAGE_MAP() |
| 60 return handled; | 62 return handled; |
| 61 } | 63 } |
| 62 | 64 |
| 63 void SpeechRecognitionDispatcherHost::OverrideThreadForMessage( | 65 void SpeechRecognitionDispatcherHost::OverrideThreadForMessage( |
| 64 const IPC::Message& message, | 66 const IPC::Message& message, |
| 65 BrowserThread::ID* thread) { | 67 BrowserThread::ID* thread) { |
| 66 if (message.type() == SpeechRecognitionHostMsg_StartRequest::ID) | 68 if (message.type() == SpeechRecognitionHostMsg_StartRequest::ID) |
| 67 *thread = BrowserThread::UI; | 69 *thread = BrowserThread::UI; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 int request_id) { | 163 int request_id) { |
| 162 int session_id = SpeechRecognitionManager::GetInstance()->GetSession( | 164 int session_id = SpeechRecognitionManager::GetInstance()->GetSession( |
| 163 render_process_id_, render_view_id, request_id); | 165 render_process_id_, render_view_id, request_id); |
| 164 | 166 |
| 165 // The renderer might provide an invalid |request_id| if the session was not | 167 // The renderer might provide an invalid |request_id| if the session was not |
| 166 // started as expected, e.g., due to unsatisfied security requirements. | 168 // started as expected, e.g., due to unsatisfied security requirements. |
| 167 if (session_id != SpeechRecognitionManager::kSessionIDInvalid) | 169 if (session_id != SpeechRecognitionManager::kSessionIDInvalid) |
| 168 SpeechRecognitionManager::GetInstance()->AbortSession(session_id); | 170 SpeechRecognitionManager::GetInstance()->AbortSession(session_id); |
| 169 } | 171 } |
| 170 | 172 |
| 173 void SpeechRecognitionDispatcherHost::OnAbortAllRequests(int render_view_id) { |
| 174 SpeechRecognitionManager::GetInstance()->AbortAllSessionsForRenderView( |
| 175 render_process_id_, render_view_id); |
| 176 } |
| 177 |
| 171 void SpeechRecognitionDispatcherHost::OnStopCaptureRequest( | 178 void SpeechRecognitionDispatcherHost::OnStopCaptureRequest( |
| 172 int render_view_id, int request_id) { | 179 int render_view_id, int request_id) { |
| 173 int session_id = SpeechRecognitionManager::GetInstance()->GetSession( | 180 int session_id = SpeechRecognitionManager::GetInstance()->GetSession( |
| 174 render_process_id_, render_view_id, request_id); | 181 render_process_id_, render_view_id, request_id); |
| 175 | 182 |
| 176 // The renderer might provide an invalid |request_id| if the session was not | 183 // The renderer might provide an invalid |request_id| if the session was not |
| 177 // started as expected, e.g., due to unsatisfied security requirements. | 184 // started as expected, e.g., due to unsatisfied security requirements. |
| 178 if (session_id != SpeechRecognitionManager::kSessionIDInvalid) { | 185 if (session_id != SpeechRecognitionManager::kSessionIDInvalid) { |
| 179 SpeechRecognitionManager::GetInstance()->StopAudioCaptureForSession( | 186 SpeechRecognitionManager::GetInstance()->StopAudioCaptureForSession( |
| 180 session_id); | 187 session_id); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 void SpeechRecognitionDispatcherHost::OnAudioLevelsChange(int session_id, | 256 void SpeechRecognitionDispatcherHost::OnAudioLevelsChange(int session_id, |
| 250 float volume, | 257 float volume, |
| 251 float noise_volume) { | 258 float noise_volume) { |
| 252 } | 259 } |
| 253 | 260 |
| 254 void SpeechRecognitionDispatcherHost::OnEnvironmentEstimationComplete( | 261 void SpeechRecognitionDispatcherHost::OnEnvironmentEstimationComplete( |
| 255 int session_id) { | 262 int session_id) { |
| 256 } | 263 } |
| 257 | 264 |
| 258 } // namespace content | 265 } // namespace content |
| OLD | NEW |