| 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/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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 DCHECK(!url_fetcher_.get()); | 164 DCHECK(!url_fetcher_.get()); |
| 165 std::string lang_param = config_.language; | 165 std::string lang_param = config_.language; |
| 166 | 166 |
| 167 if (lang_param.empty() && url_context_) { | 167 if (lang_param.empty() && url_context_) { |
| 168 // If no language is provided then we use the first from the accepted | 168 // If no language is provided then we use the first from the accepted |
| 169 // language list. If this list is empty then it defaults to "en-US". | 169 // language list. If this list is empty then it defaults to "en-US". |
| 170 // Example of the contents of this list: "es,en-GB;q=0.8", "" | 170 // Example of the contents of this list: "es,en-GB;q=0.8", "" |
| 171 net::URLRequestContext* request_context = | 171 net::URLRequestContext* request_context = |
| 172 url_context_->GetURLRequestContext(); | 172 url_context_->GetURLRequestContext(); |
| 173 DCHECK(request_context); | 173 DCHECK(request_context); |
| 174 std::string accepted_language_list = request_context->accept_language(); | 174 // TODO(pauljensen): GoogleOneShotRemoteEngine should be constructed with |
| 175 // a reference to the HttpUserAgentSettings rather than accessing the |
| 176 // accept language through the URLRequestContext. |
| 177 std::string accepted_language_list = request_context->GetAcceptLanguage(); |
| 175 size_t separator = accepted_language_list.find_first_of(",;"); | 178 size_t separator = accepted_language_list.find_first_of(",;"); |
| 176 lang_param = accepted_language_list.substr(0, separator); | 179 lang_param = accepted_language_list.substr(0, separator); |
| 177 } | 180 } |
| 178 | 181 |
| 179 if (lang_param.empty()) | 182 if (lang_param.empty()) |
| 180 lang_param = "en-US"; | 183 lang_param = "en-US"; |
| 181 | 184 |
| 182 std::vector<std::string> parts; | 185 std::vector<std::string> parts; |
| 183 parts.push_back("lang=" + net::EscapeQueryParamValue(lang_param, true)); | 186 parts.push_back("lang=" + net::EscapeQueryParamValue(lang_param, true)); |
| 184 | 187 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 | 284 |
| 282 bool GoogleOneShotRemoteEngine::IsRecognitionPending() const { | 285 bool GoogleOneShotRemoteEngine::IsRecognitionPending() const { |
| 283 return url_fetcher_ != NULL; | 286 return url_fetcher_ != NULL; |
| 284 } | 287 } |
| 285 | 288 |
| 286 int GoogleOneShotRemoteEngine::GetDesiredAudioChunkDurationMs() const { | 289 int GoogleOneShotRemoteEngine::GetDesiredAudioChunkDurationMs() const { |
| 287 return kAudioPacketIntervalMs; | 290 return kAudioPacketIntervalMs; |
| 288 } | 291 } |
| 289 | 292 |
| 290 } // namespace content | 293 } // namespace content |
| OLD | NEW |