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 "chrome/browser/speech/speech_input_dispatcher_host.h" | 5 #include "chrome/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/render_messages.h" | 8 #include "chrome/common/render_messages.h" |
9 | 9 |
10 namespace speech_input { | 10 namespace speech_input { |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 SpeechInputDispatcherHost::~SpeechInputDispatcherHost() { | 114 SpeechInputDispatcherHost::~SpeechInputDispatcherHost() { |
115 } | 115 } |
116 | 116 |
117 SpeechInputManager* SpeechInputDispatcherHost::manager() { | 117 SpeechInputManager* SpeechInputDispatcherHost::manager() { |
118 return (*manager_accessor_)(); | 118 return (*manager_accessor_)(); |
119 } | 119 } |
120 | 120 |
121 bool SpeechInputDispatcherHost::OnMessageReceived( | 121 bool SpeechInputDispatcherHost::OnMessageReceived( |
122 const IPC::Message& message, bool* message_was_ok) { | 122 const IPC::Message& message, bool* message_was_ok) { |
123 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 123 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
124 bool handled = true; | 124 |
125 IPC_BEGIN_MESSAGE_MAP_EX(SpeechInputDispatcherHost, message, | 125 uint32 message_type = message.type(); |
126 *message_was_ok) | 126 if (message_type == ViewHostMsg_SpeechInput_StartRecognition::ID || |
127 IPC_MESSAGE_HANDLER(ViewHostMsg_SpeechInput_StartRecognition, | 127 message_type == ViewHostMsg_SpeechInput_CancelRecognition::ID || |
128 OnStartRecognition) | 128 message_type == ViewHostMsg_SpeechInput_StopRecording::ID) { |
129 IPC_MESSAGE_HANDLER(ViewHostMsg_SpeechInput_CancelRecognition, | 129 if (!SpeechInputManager::IsFeatureEnabled()) { |
130 OnCancelRecognition) | 130 *message_was_ok = false; |
131 IPC_MESSAGE_HANDLER(ViewHostMsg_SpeechInput_StopRecording, | 131 return true; |
132 OnStopRecording) | 132 } |
133 IPC_MESSAGE_UNHANDLED(handled = false) | 133 |
134 IPC_END_MESSAGE_MAP() | 134 IPC_BEGIN_MESSAGE_MAP_EX(SpeechInputDispatcherHost, message, |
135 return handled; | 135 *message_was_ok) |
| 136 IPC_MESSAGE_HANDLER(ViewHostMsg_SpeechInput_StartRecognition, |
| 137 OnStartRecognition) |
| 138 IPC_MESSAGE_HANDLER(ViewHostMsg_SpeechInput_CancelRecognition, |
| 139 OnCancelRecognition) |
| 140 IPC_MESSAGE_HANDLER(ViewHostMsg_SpeechInput_StopRecording, |
| 141 OnStopRecording) |
| 142 IPC_END_MESSAGE_MAP() |
| 143 return true; |
| 144 } |
| 145 |
| 146 return false; |
136 } | 147 } |
137 | 148 |
138 void SpeechInputDispatcherHost::OnStartRecognition( | 149 void SpeechInputDispatcherHost::OnStartRecognition( |
139 int render_view_id, | 150 int render_view_id, |
140 int request_id, | 151 int request_id, |
141 const gfx::Rect& element_rect, | 152 const gfx::Rect& element_rect, |
142 const std::string& language, | 153 const std::string& language, |
143 const std::string& grammar) { | 154 const std::string& grammar) { |
144 int caller_id = g_speech_input_callers.Get().CreateId( | 155 int caller_id = g_speech_input_callers.Get().CreateId( |
145 render_process_id_, render_view_id, request_id); | 156 render_process_id_, render_view_id, request_id); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 g_speech_input_callers.Get().render_view_id(caller_id); | 210 g_speech_input_callers.Get().render_view_id(caller_id); |
200 int caller_request_id = g_speech_input_callers.Get().request_id(caller_id); | 211 int caller_request_id = g_speech_input_callers.Get().request_id(caller_id); |
201 Send(new ViewMsg_SpeechInput_RecognitionComplete(caller_render_view_id, | 212 Send(new ViewMsg_SpeechInput_RecognitionComplete(caller_render_view_id, |
202 caller_request_id)); | 213 caller_request_id)); |
203 // Request sequence ended, so remove mapping. | 214 // Request sequence ended, so remove mapping. |
204 g_speech_input_callers.Get().RemoveId(caller_id); | 215 g_speech_input_callers.Get().RemoveId(caller_id); |
205 VLOG(1) << "SpeechInputDispatcherHost::DidCompleteRecognition exit"; | 216 VLOG(1) << "SpeechInputDispatcherHost::DidCompleteRecognition exit"; |
206 } | 217 } |
207 | 218 |
208 } // namespace speech_input | 219 } // namespace speech_input |
OLD | NEW |