| 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/renderer/speech_input_dispatcher.h" | 5 #include "chrome/renderer/speech_input_dispatcher.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/renderer/render_view.h" | 8 #include "chrome/renderer/render_view.h" |
| 9 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" | 9 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" |
| 10 #include "third_party/WebKit/WebKit/chromium/public/WebSpeechInputListener.h" | 10 #include "third_party/WebKit/WebKit/chromium/public/WebSpeechInputListener.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 IPC_MESSAGE_UNHANDLED(handled = false) | 32 IPC_MESSAGE_UNHANDLED(handled = false) |
| 33 IPC_END_MESSAGE_MAP() | 33 IPC_END_MESSAGE_MAP() |
| 34 return handled; | 34 return handled; |
| 35 } | 35 } |
| 36 | 36 |
| 37 bool SpeechInputDispatcher::startRecognition( | 37 bool SpeechInputDispatcher::startRecognition( |
| 38 int request_id, | 38 int request_id, |
| 39 const WebKit::WebRect& element_rect, | 39 const WebKit::WebRect& element_rect, |
| 40 const WebKit::WebString& language, | 40 const WebKit::WebString& language, |
| 41 const WebKit::WebString& grammar) { | 41 const WebKit::WebString& grammar) { |
| 42 return startRecognition(request_id, element_rect, grammar); | |
| 43 } | |
| 44 | |
| 45 bool SpeechInputDispatcher::startRecognition( | |
| 46 int request_id, | |
| 47 const WebKit::WebRect& element_rect, | |
| 48 const WebKit::WebString& grammar) { | |
| 49 VLOG(1) << "SpeechInputDispatcher::startRecognition enter"; | 42 VLOG(1) << "SpeechInputDispatcher::startRecognition enter"; |
| 50 gfx::Size scroll = render_view_->webview()->mainFrame()->scrollOffset(); | 43 gfx::Size scroll = render_view_->webview()->mainFrame()->scrollOffset(); |
| 51 gfx::Rect rect = element_rect; | 44 gfx::Rect rect = element_rect; |
| 52 rect.Offset(-scroll.width(), -scroll.height()); | 45 rect.Offset(-scroll.width(), -scroll.height()); |
| 53 render_view_->Send(new ViewHostMsg_SpeechInput_StartRecognition( | 46 render_view_->Send(new ViewHostMsg_SpeechInput_StartRecognition( |
| 54 render_view_->routing_id(), request_id, rect, UTF16ToUTF8(grammar))); | 47 render_view_->routing_id(), request_id, rect, |
| 48 UTF16ToUTF8(language), UTF16ToUTF8(grammar))); |
| 55 VLOG(1) << "SpeechInputDispatcher::startRecognition exit"; | 49 VLOG(1) << "SpeechInputDispatcher::startRecognition exit"; |
| 56 return true; | 50 return true; |
| 57 } | 51 } |
| 58 | 52 |
| 59 void SpeechInputDispatcher::cancelRecognition(int request_id) { | 53 void SpeechInputDispatcher::cancelRecognition(int request_id) { |
| 60 VLOG(1) << "SpeechInputDispatcher::cancelRecognition enter"; | 54 VLOG(1) << "SpeechInputDispatcher::cancelRecognition enter"; |
| 61 render_view_->Send(new ViewHostMsg_SpeechInput_CancelRecognition( | 55 render_view_->Send(new ViewHostMsg_SpeechInput_CancelRecognition( |
| 62 render_view_->routing_id(), request_id)); | 56 render_view_->routing_id(), request_id)); |
| 63 VLOG(1) << "SpeechInputDispatcher::cancelRecognition exit"; | 57 VLOG(1) << "SpeechInputDispatcher::cancelRecognition exit"; |
| 64 } | 58 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 84 VLOG(1) << "SpeechInputDispatcher::OnSpeechRecordingComplete enter"; | 78 VLOG(1) << "SpeechInputDispatcher::OnSpeechRecordingComplete enter"; |
| 85 listener_->didCompleteRecording(request_id); | 79 listener_->didCompleteRecording(request_id); |
| 86 VLOG(1) << "SpeechInputDispatcher::OnSpeechRecordingComplete exit"; | 80 VLOG(1) << "SpeechInputDispatcher::OnSpeechRecordingComplete exit"; |
| 87 } | 81 } |
| 88 | 82 |
| 89 void SpeechInputDispatcher::OnSpeechRecognitionComplete(int request_id) { | 83 void SpeechInputDispatcher::OnSpeechRecognitionComplete(int request_id) { |
| 90 VLOG(1) << "SpeechInputDispatcher::OnSpeechRecognitionComplete enter"; | 84 VLOG(1) << "SpeechInputDispatcher::OnSpeechRecognitionComplete enter"; |
| 91 listener_->didCompleteRecognition(request_id); | 85 listener_->didCompleteRecognition(request_id); |
| 92 VLOG(1) << "SpeechInputDispatcher::OnSpeechRecognitionComplete exit"; | 86 VLOG(1) << "SpeechInputDispatcher::OnSpeechRecognitionComplete exit"; |
| 93 } | 87 } |
| OLD | NEW |