Chromium Code Reviews| 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 std::string accepted_language_list = request_context->GetAcceptLanguage(); |
|
willchan no longer on Chromium
2012/10/06 19:32:49
Long-term, I think we should construct this guy wi
| |
| 181 size_t separator = accepted_language_list.find_first_of(",;"); | 181 size_t separator = accepted_language_list.find_first_of(",;"); |
| 182 lang_param = accepted_language_list.substr(0, separator); | 182 lang_param = accepted_language_list.substr(0, separator); |
| 183 } | 183 } |
| 184 | 184 |
| 185 if (lang_param.empty()) | 185 if (lang_param.empty()) |
| 186 lang_param = "en-US"; | 186 lang_param = "en-US"; |
| 187 | 187 |
| 188 std::vector<std::string> parts; | 188 std::vector<std::string> parts; |
| 189 parts.push_back("lang=" + net::EscapeQueryParamValue(lang_param, true)); | 189 parts.push_back("lang=" + net::EscapeQueryParamValue(lang_param, true)); |
| 190 | 190 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 287 | 287 |
| 288 bool GoogleOneShotRemoteEngine::IsRecognitionPending() const { | 288 bool GoogleOneShotRemoteEngine::IsRecognitionPending() const { |
| 289 return url_fetcher_ != NULL; | 289 return url_fetcher_ != NULL; |
| 290 } | 290 } |
| 291 | 291 |
| 292 int GoogleOneShotRemoteEngine::GetDesiredAudioChunkDurationMs() const { | 292 int GoogleOneShotRemoteEngine::GetDesiredAudioChunkDurationMs() const { |
| 293 return kAudioPacketIntervalMs; | 293 return kAudioPacketIntervalMs; |
| 294 } | 294 } |
| 295 | 295 |
| 296 } // namespace speech | 296 } // namespace speech |
| OLD | NEW |