| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 bool SpeechRecognitionDispatcherHost::OnMessageReceived( | 45 bool SpeechRecognitionDispatcherHost::OnMessageReceived( |
| 46 const IPC::Message& message) { | 46 const IPC::Message& message) { |
| 47 bool handled = true; | 47 bool handled = true; |
| 48 IPC_BEGIN_MESSAGE_MAP(SpeechRecognitionDispatcherHost, message) | 48 IPC_BEGIN_MESSAGE_MAP(SpeechRecognitionDispatcherHost, message) |
| 49 IPC_MESSAGE_HANDLER(SpeechRecognitionHostMsg_StartRequest, | 49 IPC_MESSAGE_HANDLER(SpeechRecognitionHostMsg_StartRequest, |
| 50 OnStartRequest) | 50 OnStartRequest) |
| 51 IPC_MESSAGE_HANDLER(SpeechRecognitionHostMsg_AbortRequest, | 51 IPC_MESSAGE_HANDLER(SpeechRecognitionHostMsg_AbortRequest, |
| 52 OnAbortRequest) | 52 OnAbortRequest) |
| 53 IPC_MESSAGE_HANDLER(SpeechRecognitionHostMsg_StopCaptureRequest, | 53 IPC_MESSAGE_HANDLER(SpeechRecognitionHostMsg_StopCaptureRequest, |
| 54 OnStopCaptureRequest) | 54 OnStopCaptureRequest) |
| 55 IPC_MESSAGE_HANDLER(SpeechRecognitionHostMsg_AbortAllRequests, |
| 56 OnAbortAllRequests) |
| 55 IPC_MESSAGE_UNHANDLED(handled = false) | 57 IPC_MESSAGE_UNHANDLED(handled = false) |
| 56 IPC_END_MESSAGE_MAP() | 58 IPC_END_MESSAGE_MAP() |
| 57 return handled; | 59 return handled; |
| 58 } | 60 } |
| 59 | 61 |
| 60 void SpeechRecognitionDispatcherHost::OverrideThreadForMessage( | 62 void SpeechRecognitionDispatcherHost::OverrideThreadForMessage( |
| 61 const IPC::Message& message, | 63 const IPC::Message& message, |
| 62 BrowserThread::ID* thread) { | 64 BrowserThread::ID* thread) { |
| 63 if (message.type() == SpeechRecognitionHostMsg_StartRequest::ID) | 65 if (message.type() == SpeechRecognitionHostMsg_StartRequest::ID) |
| 64 *thread = BrowserThread::UI; | 66 *thread = BrowserThread::UI; |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 int request_id) { | 159 int request_id) { |
| 158 int session_id = SpeechRecognitionManager::GetInstance()->GetSession( | 160 int session_id = SpeechRecognitionManager::GetInstance()->GetSession( |
| 159 render_process_id_, render_view_id, request_id); | 161 render_process_id_, render_view_id, request_id); |
| 160 | 162 |
| 161 // The renderer might provide an invalid |request_id| if the session was not | 163 // The renderer might provide an invalid |request_id| if the session was not |
| 162 // started as expected, e.g., due to unsatisfied security requirements. | 164 // started as expected, e.g., due to unsatisfied security requirements. |
| 163 if (session_id != SpeechRecognitionManager::kSessionIDInvalid) | 165 if (session_id != SpeechRecognitionManager::kSessionIDInvalid) |
| 164 SpeechRecognitionManager::GetInstance()->AbortSession(session_id); | 166 SpeechRecognitionManager::GetInstance()->AbortSession(session_id); |
| 165 } | 167 } |
| 166 | 168 |
| 169 void SpeechRecognitionDispatcherHost::OnAbortAllRequests(int render_view_id) { |
| 170 SpeechRecognitionManager::GetInstance()->AbortAllSessionsForRenderView( |
| 171 render_process_id_, render_view_id); |
| 172 } |
| 173 |
| 167 void SpeechRecognitionDispatcherHost::OnStopCaptureRequest( | 174 void SpeechRecognitionDispatcherHost::OnStopCaptureRequest( |
| 168 int render_view_id, int request_id) { | 175 int render_view_id, int request_id) { |
| 169 int session_id = SpeechRecognitionManager::GetInstance()->GetSession( | 176 int session_id = SpeechRecognitionManager::GetInstance()->GetSession( |
| 170 render_process_id_, render_view_id, request_id); | 177 render_process_id_, render_view_id, request_id); |
| 171 | 178 |
| 172 // The renderer might provide an invalid |request_id| if the session was not | 179 // The renderer might provide an invalid |request_id| if the session was not |
| 173 // started as expected, e.g., due to unsatisfied security requirements. | 180 // started as expected, e.g., due to unsatisfied security requirements. |
| 174 if (session_id != SpeechRecognitionManager::kSessionIDInvalid) { | 181 if (session_id != SpeechRecognitionManager::kSessionIDInvalid) { |
| 175 SpeechRecognitionManager::GetInstance()->StopAudioCaptureForSession( | 182 SpeechRecognitionManager::GetInstance()->StopAudioCaptureForSession( |
| 176 session_id); | 183 session_id); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 void SpeechRecognitionDispatcherHost::OnAudioLevelsChange(int session_id, | 252 void SpeechRecognitionDispatcherHost::OnAudioLevelsChange(int session_id, |
| 246 float volume, | 253 float volume, |
| 247 float noise_volume) { | 254 float noise_volume) { |
| 248 } | 255 } |
| 249 | 256 |
| 250 void SpeechRecognitionDispatcherHost::OnEnvironmentEstimationComplete( | 257 void SpeechRecognitionDispatcherHost::OnEnvironmentEstimationComplete( |
| 251 int session_id) { | 258 int session_id) { |
| 252 } | 259 } |
| 253 | 260 |
| 254 } // namespace content | 261 } // namespace content |
| OLD | NEW |