Index: content/renderer/speech_recognition_dispatcher.cc |
diff --git a/content/renderer/speech_input_dispatcher.cc b/content/renderer/speech_recognition_dispatcher.cc |
similarity index 58% |
rename from content/renderer/speech_input_dispatcher.cc |
rename to content/renderer/speech_recognition_dispatcher.cc |
index 8ffc69ea822e1528fcce51ea30588db0b9db685e..f3096764ad866f471ca83da586dd9c24aeeb9f61 100644 |
--- a/content/renderer/speech_input_dispatcher.cc |
+++ b/content/renderer/speech_recognition_dispatcher.cc |
@@ -2,10 +2,10 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "content/renderer/speech_input_dispatcher.h" |
+#include "content/renderer/speech_recognition_dispatcher.h" |
#include "base/utf_string_conversions.h" |
-#include "content/common/speech_input_messages.h" |
+#include "content/common/speech_recognition_messages.h" |
#include "content/renderer/render_view_impl.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" |
@@ -25,38 +25,39 @@ using WebKit::WebInputElement; |
using WebKit::WebNode; |
using WebKit::WebView; |
-SpeechInputDispatcher::SpeechInputDispatcher( |
+SpeechRecognitionDispatcher::SpeechRecognitionDispatcher( |
RenderViewImpl* render_view, |
WebKit::WebSpeechInputListener* listener) |
: content::RenderViewObserver(render_view), |
listener_(listener) { |
} |
-bool SpeechInputDispatcher::OnMessageReceived(const IPC::Message& message) { |
+bool SpeechRecognitionDispatcher::OnMessageReceived( |
+ const IPC::Message& message) { |
bool handled = true; |
- IPC_BEGIN_MESSAGE_MAP(SpeechInputDispatcher, message) |
- IPC_MESSAGE_HANDLER(SpeechInputMsg_SetRecognitionResult, |
- OnSpeechRecognitionResult) |
- IPC_MESSAGE_HANDLER(SpeechInputMsg_RecordingComplete, |
- OnSpeechRecordingComplete) |
- IPC_MESSAGE_HANDLER(SpeechInputMsg_RecognitionComplete, |
- OnSpeechRecognitionComplete) |
- IPC_MESSAGE_HANDLER(SpeechInputMsg_ToggleSpeechInput, |
+ IPC_BEGIN_MESSAGE_MAP(SpeechRecognitionDispatcher, message) |
+ IPC_MESSAGE_HANDLER(SpeechRecognitionMsg_ResultRetrieved, |
Satish
2012/03/05 13:32:33
as we discussed offline lets separate the old and
Primiano Tucci (use gerrit)
2012/03/05 17:37:52
As we re-discussed offline I renamed the messages
|
+ OnResultRetrieved) |
+ IPC_MESSAGE_HANDLER(SpeechRecognitionMsg_AudioEnded, |
+ OnAudioEnded) |
+ IPC_MESSAGE_HANDLER(SpeechRecognitionMsg_RecognitionEnded, |
+ OnRecognitionEnded) |
+ IPC_MESSAGE_HANDLER(SpeechRecognitionMsg_ToggleSpeechInput, |
OnSpeechRecognitionToggleSpeechInput) |
IPC_MESSAGE_UNHANDLED(handled = false) |
IPC_END_MESSAGE_MAP() |
return handled; |
} |
-bool SpeechInputDispatcher::startRecognition( |
+bool SpeechRecognitionDispatcher::startRecognition( |
int request_id, |
const WebKit::WebRect& element_rect, |
const WebKit::WebString& language, |
const WebKit::WebString& grammar, |
const WebKit::WebSecurityOrigin& origin) { |
- VLOG(1) << "SpeechInputDispatcher::startRecognition enter"; |
+ VLOG(1) << "SpeechRecognitionDispatcher::startRecognition enter"; |
- SpeechInputHostMsg_StartRecognition_Params params; |
+ SpeechRecognitionHostMsg_StartRequest_Params params; |
params.grammar = UTF16ToUTF8(grammar); |
params.language = UTF16ToUTF8(language); |
params.origin_url = UTF16ToUTF8(origin.toString()); |
@@ -66,50 +67,51 @@ bool SpeechInputDispatcher::startRecognition( |
params.element_rect = element_rect; |
params.element_rect.Offset(-scroll.width(), -scroll.height()); |
- Send(new SpeechInputHostMsg_StartRecognition(params)); |
- VLOG(1) << "SpeechInputDispatcher::startRecognition exit"; |
+ Send(new SpeechRecognitionHostMsg_StartRequest(params)); |
+ VLOG(1) << "SpeechRecognitionDispatcher::startRecognition exit"; |
return true; |
} |
-void SpeechInputDispatcher::cancelRecognition(int request_id) { |
- VLOG(1) << "SpeechInputDispatcher::cancelRecognition enter"; |
- Send(new SpeechInputHostMsg_CancelRecognition(routing_id(), request_id)); |
- VLOG(1) << "SpeechInputDispatcher::cancelRecognition exit"; |
+void SpeechRecognitionDispatcher::cancelRecognition(int request_id) { |
+ VLOG(1) << "SpeechRecognitionDispatcher::cancelRecognition enter"; |
+ Send(new SpeechRecognitionHostMsg_AbortRequest(routing_id(), request_id)); |
+ VLOG(1) << "SpeechRecognitionDispatcher::cancelRecognition exit"; |
} |
-void SpeechInputDispatcher::stopRecording(int request_id) { |
- VLOG(1) << "SpeechInputDispatcher::stopRecording enter"; |
- Send(new SpeechInputHostMsg_StopRecording(routing_id(), request_id)); |
- VLOG(1) << "SpeechInputDispatcher::stopRecording exit"; |
+void SpeechRecognitionDispatcher::stopRecording(int request_id) { |
+ VLOG(1) << "SpeechRecognitionDispatcher::stopRecording enter"; |
+ Send(new SpeechRecognitionHostMsg_StopAudioCaptureRequest(routing_id(), |
+ request_id)); |
+ VLOG(1) << "SpeechRecognitionDispatcher::stopRecording exit"; |
} |
-void SpeechInputDispatcher::OnSpeechRecognitionResult( |
+void SpeechRecognitionDispatcher::OnResultRetrieved( |
int request_id, |
const content::SpeechInputResult& result) { |
- VLOG(1) << "SpeechInputDispatcher::OnSpeechRecognitionResult enter"; |
+ VLOG(1) << "SpeechRecognitionDispatcher::OnResultRetrieved enter"; |
WebKit::WebSpeechInputResultArray webkit_result(result.hypotheses.size()); |
for (size_t i = 0; i < result.hypotheses.size(); ++i) { |
webkit_result[i].assign(result.hypotheses[i].utterance, |
result.hypotheses[i].confidence); |
} |
listener_->setRecognitionResult(request_id, webkit_result); |
- VLOG(1) << "SpeechInputDispatcher::OnSpeechRecognitionResult exit"; |
+ VLOG(1) << "SpeechRecognitionDispatcher::OnResultRetrieved exit"; |
} |
-void SpeechInputDispatcher::OnSpeechRecordingComplete(int request_id) { |
- VLOG(1) << "SpeechInputDispatcher::OnSpeechRecordingComplete enter"; |
+void SpeechRecognitionDispatcher::OnAudioEnded(int request_id) { |
+ VLOG(1) << "SpeechRecognitionDispatcher::OnAudioEnded enter"; |
listener_->didCompleteRecording(request_id); |
- VLOG(1) << "SpeechInputDispatcher::OnSpeechRecordingComplete exit"; |
+ VLOG(1) << "SpeechRecognitionDispatcher::OnAudioEnded exit"; |
} |
-void SpeechInputDispatcher::OnSpeechRecognitionComplete(int request_id) { |
- VLOG(1) << "SpeechInputDispatcher::OnSpeechRecognitionComplete enter"; |
+void SpeechRecognitionDispatcher::OnRecognitionEnded(int request_id) { |
+ VLOG(1) << "SpeechRecognitionDispatcher::OnRecognitionEnded enter"; |
listener_->didCompleteRecognition(request_id); |
- VLOG(1) << "SpeechInputDispatcher::OnSpeechRecognitionComplete exit"; |
+ VLOG(1) << "SpeechRecognitionDispatcher::OnRecognitionEnded exit"; |
} |
-void SpeechInputDispatcher::OnSpeechRecognitionToggleSpeechInput() { |
- VLOG(1) << "SpeechInputDispatcher::OnSpeechRecognitionToggleSpeechInput"; |
+void SpeechRecognitionDispatcher::OnSpeechRecognitionToggleSpeechInput() { |
+ VLOG(1) <<"SpeechRecognitionDispatcher::OnSpeechRecognitionToggleSpeechInput"; |
WebView* web_view = render_view()->GetWebView(); |