| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/renderer/speech_recognition_dispatcher.h" | 5 #include "content/renderer/speech_recognition_dispatcher.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "content/common/speech_recognition_messages.h" | 9 #include "content/common/speech_recognition_messages.h" |
| 10 #include "content/renderer/render_view_impl.h" | 10 #include "content/renderer/render_view_impl.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 | 62 |
| 63 SpeechRecognitionHostMsg_StartRequest_Params msg_params; | 63 SpeechRecognitionHostMsg_StartRequest_Params msg_params; |
| 64 for (size_t i = 0; i < params.grammars().size(); ++i) { | 64 for (size_t i = 0; i < params.grammars().size(); ++i) { |
| 65 const WebSpeechGrammar& grammar = params.grammars()[i]; | 65 const WebSpeechGrammar& grammar = params.grammars()[i]; |
| 66 msg_params.grammars.push_back( | 66 msg_params.grammars.push_back( |
| 67 content::SpeechRecognitionGrammar(grammar.src().spec(), | 67 content::SpeechRecognitionGrammar(grammar.src().spec(), |
| 68 grammar.weight())); | 68 grammar.weight())); |
| 69 } | 69 } |
| 70 msg_params.language = UTF16ToUTF8(params.language()); | 70 msg_params.language = UTF16ToUTF8(params.language()); |
| 71 msg_params.is_one_shot = !params.continuous(); | 71 msg_params.is_one_shot = !params.continuous(); |
| 72 msg_params.origin_url = ""; // TODO(primiano) we need an origin from WebKit. | 72 msg_params.origin_url = params.origin().toString().utf8(); |
| 73 msg_params.render_view_id = routing_id(); | 73 msg_params.render_view_id = routing_id(); |
| 74 msg_params.request_id = GetIDForHandle(handle); | 74 msg_params.request_id = GetIDForHandle(handle); |
| 75 Send(new SpeechRecognitionHostMsg_StartRequest(msg_params)); | 75 Send(new SpeechRecognitionHostMsg_StartRequest(msg_params)); |
| 76 } | 76 } |
| 77 | 77 |
| 78 void SpeechRecognitionDispatcher::stop( | 78 void SpeechRecognitionDispatcher::stop( |
| 79 const WebSpeechRecognitionHandle& handle, | 79 const WebSpeechRecognitionHandle& handle, |
| 80 WebSpeechRecognizerClient* recognizer_client) { | 80 WebSpeechRecognizerClient* recognizer_client) { |
| 81 DCHECK(recognizer_client_ == recognizer_client); | 81 DCHECK(recognizer_client_ == recognizer_client); |
| 82 Send(new SpeechRecognitionHostMsg_StopCaptureRequest(routing_id(), | 82 Send(new SpeechRecognitionHostMsg_StopCaptureRequest(routing_id(), |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 ++next_id_; | 184 ++next_id_; |
| 185 return new_id; | 185 return new_id; |
| 186 } | 186 } |
| 187 | 187 |
| 188 const WebSpeechRecognitionHandle& SpeechRecognitionDispatcher::GetHandleFromID( | 188 const WebSpeechRecognitionHandle& SpeechRecognitionDispatcher::GetHandleFromID( |
| 189 int request_id) { | 189 int request_id) { |
| 190 HandleMap::iterator iter = handle_map_.find(request_id); | 190 HandleMap::iterator iter = handle_map_.find(request_id); |
| 191 DCHECK(iter != handle_map_.end()); | 191 DCHECK(iter != handle_map_.end()); |
| 192 return iter->second; | 192 return iter->second; |
| 193 } | 193 } |
| OLD | NEW |