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