| 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 <stddef.h> |
| 8 #include <stdint.h> |
| 9 |
| 8 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 9 #include "content/common/speech_recognition_messages.h" | 11 #include "content/common/speech_recognition_messages.h" |
| 10 #include "content/renderer/render_view_impl.h" | 12 #include "content/renderer/render_view_impl.h" |
| 11 #include "third_party/WebKit/public/platform/WebString.h" | 13 #include "third_party/WebKit/public/platform/WebString.h" |
| 12 #include "third_party/WebKit/public/platform/WebVector.h" | 14 #include "third_party/WebKit/public/platform/WebVector.h" |
| 13 #include "third_party/WebKit/public/web/WebSpeechGrammar.h" | 15 #include "third_party/WebKit/public/web/WebSpeechGrammar.h" |
| 14 #include "third_party/WebKit/public/web/WebSpeechRecognitionParams.h" | 16 #include "third_party/WebKit/public/web/WebSpeechRecognitionParams.h" |
| 15 #include "third_party/WebKit/public/web/WebSpeechRecognitionResult.h" | 17 #include "third_party/WebKit/public/web/WebSpeechRecognitionResult.h" |
| 16 #include "third_party/WebKit/public/web/WebSpeechRecognizerClient.h" | 18 #include "third_party/WebKit/public/web/WebSpeechRecognizerClient.h" |
| 17 | 19 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 | 97 |
| 96 SpeechRecognitionHostMsg_StartRequest_Params msg_params; | 98 SpeechRecognitionHostMsg_StartRequest_Params msg_params; |
| 97 for (size_t i = 0; i < params.grammars().size(); ++i) { | 99 for (size_t i = 0; i < params.grammars().size(); ++i) { |
| 98 const WebSpeechGrammar& grammar = params.grammars()[i]; | 100 const WebSpeechGrammar& grammar = params.grammars()[i]; |
| 99 msg_params.grammars.push_back( | 101 msg_params.grammars.push_back( |
| 100 SpeechRecognitionGrammar(grammar.src().string().utf8(), | 102 SpeechRecognitionGrammar(grammar.src().string().utf8(), |
| 101 grammar.weight())); | 103 grammar.weight())); |
| 102 } | 104 } |
| 103 msg_params.language = | 105 msg_params.language = |
| 104 base::UTF16ToUTF8(base::StringPiece16(params.language())); | 106 base::UTF16ToUTF8(base::StringPiece16(params.language())); |
| 105 msg_params.max_hypotheses = static_cast<uint32>(params.maxAlternatives()); | 107 msg_params.max_hypotheses = static_cast<uint32_t>(params.maxAlternatives()); |
| 106 msg_params.continuous = params.continuous(); | 108 msg_params.continuous = params.continuous(); |
| 107 msg_params.interim_results = params.interimResults(); | 109 msg_params.interim_results = params.interimResults(); |
| 108 msg_params.origin_url = params.origin().toString().utf8(); | 110 msg_params.origin_url = params.origin().toString().utf8(); |
| 109 msg_params.render_view_id = routing_id(); | 111 msg_params.render_view_id = routing_id(); |
| 110 msg_params.request_id = GetOrCreateIDForHandle(handle); | 112 msg_params.request_id = GetOrCreateIDForHandle(handle); |
| 111 #if defined(ENABLE_WEBRTC) | 113 #if defined(ENABLE_WEBRTC) |
| 112 // Fall back to default input when the track is not allowed. | 114 // Fall back to default input when the track is not allowed. |
| 113 msg_params.using_audio_track = !audio_track_.isNull(); | 115 msg_params.using_audio_track = !audio_track_.isNull(); |
| 114 #else | 116 #else |
| 115 msg_params.using_audio_track = false; | 117 msg_params.using_audio_track = false; |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 } | 315 } |
| 314 | 316 |
| 315 const WebSpeechRecognitionHandle& SpeechRecognitionDispatcher::GetHandleFromID( | 317 const WebSpeechRecognitionHandle& SpeechRecognitionDispatcher::GetHandleFromID( |
| 316 int request_id) { | 318 int request_id) { |
| 317 HandleMap::iterator iter = handle_map_.find(request_id); | 319 HandleMap::iterator iter = handle_map_.find(request_id); |
| 318 CHECK(iter != handle_map_.end()); | 320 CHECK(iter != handle_map_.end()); |
| 319 return iter->second; | 321 return iter->second; |
| 320 } | 322 } |
| 321 | 323 |
| 322 } // namespace content | 324 } // namespace content |
| OLD | NEW |