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

Unified Diff: chrome/browser/speech/speech_recognition_request.cc

Issue 4896001: Locale access from the IO thread for null language tags in speech. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: now using the first of the accepted languages. Created 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/speech/speech_recognition_request.cc
diff --git a/chrome/browser/speech/speech_recognition_request.cc b/chrome/browser/speech/speech_recognition_request.cc
index e17f69b1f09c2275cb31f54d1e97647c00602773..a4d01a2413efaf06ac674c808d175c987138681e 100644
--- a/chrome/browser/speech/speech_recognition_request.cc
+++ b/chrome/browser/speech/speech_recognition_request.cc
@@ -12,6 +12,7 @@
#include "chrome/common/net/url_request_context_getter.h"
#include "net/base/escape.h"
#include "net/base/load_flags.h"
+#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_status.h"
namespace {
@@ -128,8 +129,14 @@ bool SpeechRecognitionRequest::Send(const std::string& language,
if (!language.empty()) {
parts.push_back("lang=" + EscapeQueryParamValue(language, true));
} else {
- std::string app_locale = l10n_util::GetApplicationLocale("");
- parts.push_back("lang=" + EscapeQueryParamValue(app_locale, true));
+ // If no language is provided then we use the 1st from the accepted language list.
Leandro GraciĆ” Gil 2010/11/15 16:57:07 Just noticed the line length. I'll fix this.
+ // If this list is empty then we default to "en-US".
+ // Example of the contents of this list: "es,en-GB;q=0.8" , ""
+ std::string list = url_context_->GetURLRequestContext()->accept_language();
+ size_t separator = list.find_first_of(",;");
+ std::string lang = list.substr(0, separator);
+ if (lang.empty()) lang = "en-US";
+ parts.push_back("lang=" + EscapeQueryParamValue(lang, true));
}
if (!grammar.empty())
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698