| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/browser/speech/speech_recognition_request.h" | 5 #include "content/browser/speech/speech_recognition_request.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 // Example of the contents of this list: "es,en-GB;q=0.8", "" | 137 // Example of the contents of this list: "es,en-GB;q=0.8", "" |
| 138 net::URLRequestContext* request_context = | 138 net::URLRequestContext* request_context = |
| 139 url_context_->GetURLRequestContext(); | 139 url_context_->GetURLRequestContext(); |
| 140 DCHECK(request_context); | 140 DCHECK(request_context); |
| 141 std::string accepted_language_list = request_context->accept_language(); | 141 std::string accepted_language_list = request_context->accept_language(); |
| 142 size_t separator = accepted_language_list.find_first_of(",;"); | 142 size_t separator = accepted_language_list.find_first_of(",;"); |
| 143 lang_param = accepted_language_list.substr(0, separator); | 143 lang_param = accepted_language_list.substr(0, separator); |
| 144 } | 144 } |
| 145 if (lang_param.empty()) | 145 if (lang_param.empty()) |
| 146 lang_param = "en-US"; | 146 lang_param = "en-US"; |
| 147 parts.push_back("lang=" + EscapeQueryParamValue(lang_param, true)); | 147 parts.push_back("lang=" + net::EscapeQueryParamValue(lang_param, true)); |
| 148 | 148 |
| 149 if (!grammar.empty()) | 149 if (!grammar.empty()) |
| 150 parts.push_back("lm=" + EscapeQueryParamValue(grammar, true)); | 150 parts.push_back("lm=" + net::EscapeQueryParamValue(grammar, true)); |
| 151 if (!hardware_info.empty()) | 151 if (!hardware_info.empty()) |
| 152 parts.push_back("xhw=" + EscapeQueryParamValue(hardware_info, true)); | 152 parts.push_back("xhw=" + net::EscapeQueryParamValue(hardware_info, true)); |
| 153 parts.push_back("maxresults=" + base::IntToString(kMaxResults)); | 153 parts.push_back("maxresults=" + base::IntToString(kMaxResults)); |
| 154 parts.push_back(censor_results ? "pfilter=2" : "pfilter=0"); | 154 parts.push_back(censor_results ? "pfilter=2" : "pfilter=0"); |
| 155 | 155 |
| 156 GURL url(std::string(kDefaultSpeechRecognitionUrl) + JoinString(parts, '&')); | 156 GURL url(std::string(kDefaultSpeechRecognitionUrl) + JoinString(parts, '&')); |
| 157 | 157 |
| 158 url_fetcher_.reset(URLFetcher::Create(url_fetcher_id_for_tests, | 158 url_fetcher_.reset(URLFetcher::Create(url_fetcher_id_for_tests, |
| 159 url, | 159 url, |
| 160 URLFetcher::POST, | 160 URLFetcher::POST, |
| 161 this)); | 161 this)); |
| 162 url_fetcher_->set_chunked_upload(content_type); | 162 url_fetcher_->set_chunked_upload(content_type); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 192 SpeechInputResultArray result; | 192 SpeechInputResultArray result; |
| 193 if (!error) | 193 if (!error) |
| 194 error = !ParseServerResponse(data, &result); | 194 error = !ParseServerResponse(data, &result); |
| 195 url_fetcher_.reset(); | 195 url_fetcher_.reset(); |
| 196 | 196 |
| 197 DVLOG(1) << "SpeechRecognitionRequest: Invoking delegate with result."; | 197 DVLOG(1) << "SpeechRecognitionRequest: Invoking delegate with result."; |
| 198 delegate_->SetRecognitionResult(error, result); | 198 delegate_->SetRecognitionResult(error, result); |
| 199 } | 199 } |
| 200 | 200 |
| 201 } // namespace speech_input | 201 } // namespace speech_input |
| OLD | NEW |