Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Side by Side Diff: content/browser/speech/speech_recognition_request.cc

Issue 8199010: Fixing misleading name a in speech input setting and related variables. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review fixes. Landing if no problems in the bots. Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 net::URLRequestContextGetter* context, Delegate* delegate) 141 net::URLRequestContextGetter* context, Delegate* delegate)
142 : url_context_(context), 142 : url_context_(context),
143 delegate_(delegate) { 143 delegate_(delegate) {
144 DCHECK(delegate); 144 DCHECK(delegate);
145 } 145 }
146 146
147 SpeechRecognitionRequest::~SpeechRecognitionRequest() {} 147 SpeechRecognitionRequest::~SpeechRecognitionRequest() {}
148 148
149 void SpeechRecognitionRequest::Start(const std::string& language, 149 void SpeechRecognitionRequest::Start(const std::string& language,
150 const std::string& grammar, 150 const std::string& grammar,
151 bool censor_results, 151 bool filter_profanities,
152 const std::string& hardware_info, 152 const std::string& hardware_info,
153 const std::string& origin_url, 153 const std::string& origin_url,
154 const std::string& content_type) { 154 const std::string& content_type) {
155 DCHECK(!url_fetcher_.get()); 155 DCHECK(!url_fetcher_.get());
156 156
157 std::vector<std::string> parts; 157 std::vector<std::string> parts;
158 158
159 std::string lang_param = language; 159 std::string lang_param = language;
160 if (lang_param.empty() && url_context_) { 160 if (lang_param.empty() && url_context_) {
161 // If no language is provided then we use the first from the accepted 161 // If no language is provided then we use the first from the accepted
162 // language list. If this list is empty then it defaults to "en-US". 162 // language list. If this list is empty then it defaults to "en-US".
163 // Example of the contents of this list: "es,en-GB;q=0.8", "" 163 // Example of the contents of this list: "es,en-GB;q=0.8", ""
164 net::URLRequestContext* request_context = 164 net::URLRequestContext* request_context =
165 url_context_->GetURLRequestContext(); 165 url_context_->GetURLRequestContext();
166 DCHECK(request_context); 166 DCHECK(request_context);
167 std::string accepted_language_list = request_context->accept_language(); 167 std::string accepted_language_list = request_context->accept_language();
168 size_t separator = accepted_language_list.find_first_of(",;"); 168 size_t separator = accepted_language_list.find_first_of(",;");
169 lang_param = accepted_language_list.substr(0, separator); 169 lang_param = accepted_language_list.substr(0, separator);
170 } 170 }
171 if (lang_param.empty()) 171 if (lang_param.empty())
172 lang_param = "en-US"; 172 lang_param = "en-US";
173 parts.push_back("lang=" + net::EscapeQueryParamValue(lang_param, true)); 173 parts.push_back("lang=" + net::EscapeQueryParamValue(lang_param, true));
174 174
175 if (!grammar.empty()) 175 if (!grammar.empty())
176 parts.push_back("lm=" + net::EscapeQueryParamValue(grammar, true)); 176 parts.push_back("lm=" + net::EscapeQueryParamValue(grammar, true));
177 if (!hardware_info.empty()) 177 if (!hardware_info.empty())
178 parts.push_back("xhw=" + net::EscapeQueryParamValue(hardware_info, true)); 178 parts.push_back("xhw=" + net::EscapeQueryParamValue(hardware_info, true));
179 parts.push_back("maxresults=" + base::IntToString(kMaxResults)); 179 parts.push_back("maxresults=" + base::IntToString(kMaxResults));
180 parts.push_back(censor_results ? "pfilter=2" : "pfilter=0"); 180 parts.push_back(filter_profanities ? "pfilter=2" : "pfilter=0");
181 181
182 GURL url(std::string(kDefaultSpeechRecognitionUrl) + JoinString(parts, '&')); 182 GURL url(std::string(kDefaultSpeechRecognitionUrl) + JoinString(parts, '&'));
183 183
184 url_fetcher_.reset(URLFetcher::Create(url_fetcher_id_for_tests, 184 url_fetcher_.reset(URLFetcher::Create(url_fetcher_id_for_tests,
185 url, 185 url,
186 URLFetcher::POST, 186 URLFetcher::POST,
187 this)); 187 this));
188 url_fetcher_->set_chunked_upload(content_type); 188 url_fetcher_->set_chunked_upload(content_type);
189 url_fetcher_->set_request_context(url_context_); 189 url_fetcher_->set_request_context(url_context_);
190 url_fetcher_->set_referrer(origin_url); 190 url_fetcher_->set_referrer(origin_url);
(...skipping 22 matching lines...) Expand all
213 !ParseServerResponse(source->GetResponseStringRef(), &result)) { 213 !ParseServerResponse(source->GetResponseStringRef(), &result)) {
214 result.error = kErrorNetwork; 214 result.error = kErrorNetwork;
215 } 215 }
216 216
217 DVLOG(1) << "SpeechRecognitionRequest: Invoking delegate with result."; 217 DVLOG(1) << "SpeechRecognitionRequest: Invoking delegate with result.";
218 url_fetcher_.reset(); 218 url_fetcher_.reset();
219 delegate_->SetRecognitionResult(result); 219 delegate_->SetRecognitionResult(result);
220 } 220 }
221 221
222 } // namespace speech_input 222 } // namespace speech_input
OLDNEW
« no previous file with comments | « content/browser/speech/speech_recognition_request.h ('k') | content/browser/speech/speech_recognizer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698