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

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

Issue 10918279: Provide mutable members of UrlRequestContext via pure-virtual interface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add TODO Created 8 years, 1 month 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) 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/browser/speech/google_one_shot_remote_engine.h" 5 #include "content/browser/speech/google_one_shot_remote_engine.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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 DCHECK(!url_fetcher_.get()); 170 DCHECK(!url_fetcher_.get());
171 std::string lang_param = config_.language; 171 std::string lang_param = config_.language;
172 172
173 if (lang_param.empty() && url_context_) { 173 if (lang_param.empty() && url_context_) {
174 // If no language is provided then we use the first from the accepted 174 // If no language is provided then we use the first from the accepted
175 // language list. If this list is empty then it defaults to "en-US". 175 // language list. If this list is empty then it defaults to "en-US".
176 // Example of the contents of this list: "es,en-GB;q=0.8", "" 176 // Example of the contents of this list: "es,en-GB;q=0.8", ""
177 net::URLRequestContext* request_context = 177 net::URLRequestContext* request_context =
178 url_context_->GetURLRequestContext(); 178 url_context_->GetURLRequestContext();
179 DCHECK(request_context); 179 DCHECK(request_context);
180 std::string accepted_language_list = request_context->accept_language(); 180 // TODO(pauljensen): GoogleOneShotRemoteEngine should be constructed with
181 // a reference to the HttpUserAgentSettings rather than accessing the
182 // accept language through the URLRequestContext.
183 std::string accepted_language_list = request_context->GetAcceptLanguage();
181 size_t separator = accepted_language_list.find_first_of(",;"); 184 size_t separator = accepted_language_list.find_first_of(",;");
182 lang_param = accepted_language_list.substr(0, separator); 185 lang_param = accepted_language_list.substr(0, separator);
183 } 186 }
184 187
185 if (lang_param.empty()) 188 if (lang_param.empty())
186 lang_param = "en-US"; 189 lang_param = "en-US";
187 190
188 std::vector<std::string> parts; 191 std::vector<std::string> parts;
189 parts.push_back("lang=" + net::EscapeQueryParamValue(lang_param, true)); 192 parts.push_back("lang=" + net::EscapeQueryParamValue(lang_param, true));
190 193
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 290
288 bool GoogleOneShotRemoteEngine::IsRecognitionPending() const { 291 bool GoogleOneShotRemoteEngine::IsRecognitionPending() const {
289 return url_fetcher_ != NULL; 292 return url_fetcher_ != NULL;
290 } 293 }
291 294
292 int GoogleOneShotRemoteEngine::GetDesiredAudioChunkDurationMs() const { 295 int GoogleOneShotRemoteEngine::GetDesiredAudioChunkDurationMs() const {
293 return kAudioPacketIntervalMs; 296 return kAudioPacketIntervalMs;
294 } 297 }
295 298
296 } // namespace speech 299 } // namespace speech
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698