| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_input_dispatcher_host.h" | 5 #include "content/browser/speech/speech_input_dispatcher_host.h" |
| 6 | 6 |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "chrome/common/speech_input_messages.h" | 8 #include "chrome/common/speech_input_messages.h" |
| 9 | 9 |
| 10 namespace speech_input { | 10 namespace speech_input { |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 manager()->CancelAllRequestsWithDelegate(this); | 122 manager()->CancelAllRequestsWithDelegate(this); |
| 123 } | 123 } |
| 124 | 124 |
| 125 SpeechInputManager* SpeechInputDispatcherHost::manager() { | 125 SpeechInputManager* SpeechInputDispatcherHost::manager() { |
| 126 return (*manager_accessor_)(); | 126 return (*manager_accessor_)(); |
| 127 } | 127 } |
| 128 | 128 |
| 129 bool SpeechInputDispatcherHost::OnMessageReceived( | 129 bool SpeechInputDispatcherHost::OnMessageReceived( |
| 130 const IPC::Message& message, bool* message_was_ok) { | 130 const IPC::Message& message, bool* message_was_ok) { |
| 131 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 131 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 132 | 132 bool handled = true; |
| 133 uint32 message_type = message.type(); | 133 IPC_BEGIN_MESSAGE_MAP_EX(SpeechInputDispatcherHost, message, |
| 134 if (message_type == SpeechInputHostMsg_StartRecognition::ID || | 134 *message_was_ok) |
| 135 message_type == SpeechInputHostMsg_CancelRecognition::ID || | 135 IPC_MESSAGE_HANDLER(SpeechInputHostMsg_StartRecognition, |
| 136 message_type == SpeechInputHostMsg_StopRecording::ID) { | 136 OnStartRecognition) |
| 137 if (!SpeechInputManager::IsFeatureEnabled()) { | 137 IPC_MESSAGE_HANDLER(SpeechInputHostMsg_CancelRecognition, |
| 138 *message_was_ok = false; | 138 OnCancelRecognition) |
| 139 return true; | 139 IPC_MESSAGE_HANDLER(SpeechInputHostMsg_StopRecording, |
| 140 } | 140 OnStopRecording) |
| 141 | 141 IPC_MESSAGE_UNHANDLED(handled = false) |
| 142 may_have_pending_requests_ = true; | 142 IPC_END_MESSAGE_MAP() |
| 143 IPC_BEGIN_MESSAGE_MAP_EX(SpeechInputDispatcherHost, message, | 143 return handled; |
| 144 *message_was_ok) | |
| 145 IPC_MESSAGE_HANDLER(SpeechInputHostMsg_StartRecognition, | |
| 146 OnStartRecognition) | |
| 147 IPC_MESSAGE_HANDLER(SpeechInputHostMsg_CancelRecognition, | |
| 148 OnCancelRecognition) | |
| 149 IPC_MESSAGE_HANDLER(SpeechInputHostMsg_StopRecording, | |
| 150 OnStopRecording) | |
| 151 IPC_END_MESSAGE_MAP() | |
| 152 return true; | |
| 153 } | |
| 154 | |
| 155 return false; | |
| 156 } | 144 } |
| 157 | 145 |
| 158 void SpeechInputDispatcherHost::OnStartRecognition( | 146 void SpeechInputDispatcherHost::OnStartRecognition( |
| 159 const SpeechInputHostMsg_StartRecognition_Params ¶ms) { | 147 const SpeechInputHostMsg_StartRecognition_Params ¶ms) { |
| 160 int caller_id = g_speech_input_callers.Get().CreateId( | 148 int caller_id = g_speech_input_callers.Get().CreateId( |
| 161 render_process_id_, params.render_view_id, params.request_id); | 149 render_process_id_, params.render_view_id, params.request_id); |
| 162 manager()->StartRecognition(this, caller_id, | 150 manager()->StartRecognition(this, caller_id, |
| 163 render_process_id_, | 151 render_process_id_, |
| 164 params.render_view_id, params.element_rect, | 152 params.render_view_id, params.element_rect, |
| 165 params.language, params.grammar, | 153 params.language, params.grammar, |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 g_speech_input_callers.Get().render_view_id(caller_id); | 204 g_speech_input_callers.Get().render_view_id(caller_id); |
| 217 int caller_request_id = g_speech_input_callers.Get().request_id(caller_id); | 205 int caller_request_id = g_speech_input_callers.Get().request_id(caller_id); |
| 218 Send(new SpeechInputMsg_RecognitionComplete(caller_render_view_id, | 206 Send(new SpeechInputMsg_RecognitionComplete(caller_render_view_id, |
| 219 caller_request_id)); | 207 caller_request_id)); |
| 220 // Request sequence ended, so remove mapping. | 208 // Request sequence ended, so remove mapping. |
| 221 g_speech_input_callers.Get().RemoveId(caller_id); | 209 g_speech_input_callers.Get().RemoveId(caller_id); |
| 222 VLOG(1) << "SpeechInputDispatcherHost::DidCompleteRecognition exit"; | 210 VLOG(1) << "SpeechInputDispatcherHost::DidCompleteRecognition exit"; |
| 223 } | 211 } |
| 224 | 212 |
| 225 } // namespace speech_input | 213 } // namespace speech_input |
| OLD | NEW |