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/strings/utf_string_conversions.h" | 8 #include "base/strings/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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 WebSpeechRecognizerClient* recognizer_client) { | 59 WebSpeechRecognizerClient* recognizer_client) { |
60 DCHECK(!recognizer_client_ || recognizer_client_ == recognizer_client); | 60 DCHECK(!recognizer_client_ || recognizer_client_ == recognizer_client); |
61 recognizer_client_ = recognizer_client; | 61 recognizer_client_ = recognizer_client; |
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 SpeechRecognitionGrammar(grammar.src().spec(), grammar.weight())); | 67 SpeechRecognitionGrammar(grammar.src().spec(), grammar.weight())); |
68 } | 68 } |
69 msg_params.language = UTF16ToUTF8(params.language()); | 69 msg_params.language = base::UTF16ToUTF8(params.language()); |
70 msg_params.max_hypotheses = static_cast<uint32>(params.maxAlternatives()); | 70 msg_params.max_hypotheses = static_cast<uint32>(params.maxAlternatives()); |
71 msg_params.continuous = params.continuous(); | 71 msg_params.continuous = params.continuous(); |
72 msg_params.interim_results = params.interimResults(); | 72 msg_params.interim_results = params.interimResults(); |
73 msg_params.origin_url = params.origin().toString().utf8(); | 73 msg_params.origin_url = params.origin().toString().utf8(); |
74 msg_params.render_view_id = routing_id(); | 74 msg_params.render_view_id = routing_id(); |
75 msg_params.request_id = GetOrCreateIDForHandle(handle); | 75 msg_params.request_id = GetOrCreateIDForHandle(handle); |
76 // The handle mapping will be removed in |OnRecognitionEnd|. | 76 // The handle mapping will be removed in |OnRecognitionEnd|. |
77 Send(new SpeechRecognitionHostMsg_StartRequest(msg_params)); | 77 Send(new SpeechRecognitionHostMsg_StartRequest(msg_params)); |
78 } | 78 } |
79 | 79 |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 } | 235 } |
236 | 236 |
237 const WebSpeechRecognitionHandle& SpeechRecognitionDispatcher::GetHandleFromID( | 237 const WebSpeechRecognitionHandle& SpeechRecognitionDispatcher::GetHandleFromID( |
238 int request_id) { | 238 int request_id) { |
239 HandleMap::iterator iter = handle_map_.find(request_id); | 239 HandleMap::iterator iter = handle_map_.find(request_id); |
240 DCHECK(iter != handle_map_.end()); | 240 DCHECK(iter != handle_map_.end()); |
241 return iter->second; | 241 return iter->second; |
242 } | 242 } |
243 | 243 |
244 } // namespace content | 244 } // namespace content |
OLD | NEW |