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

Unified Diff: android_webview/browser/aw_content_browser_client.cc

Issue 2496183002: Use GetDefaultLocaleListString for returning LocaleList (Closed)
Patch Set: extract setLocale method, since configuration.getLocales() returns the same as LocaleUtils.getDefau… Created 4 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
Index: android_webview/browser/aw_content_browser_client.cc
diff --git a/android_webview/browser/aw_content_browser_client.cc b/android_webview/browser/aw_content_browser_client.cc
index 5f695eac250afdf2930dc842556e68bf3916387b..37f3701a8a6ca89d0d3a98e83e2f56eafffa20d5 100644
--- a/android_webview/browser/aw_content_browser_client.cc
+++ b/android_webview/browser/aw_content_browser_client.cc
@@ -158,17 +158,20 @@ AwLocaleManager* g_locale_manager = NULL;
} // anonymous namespace
+// TODO(yirui): could use similar logic as in
+// PrependToAcceptLanguagesIfNecessary
+// in chrome/browser/android/preferences/pref_service_bridge.cc
// static
std::string AwContentBrowserClient::GetAcceptLangsImpl() {
Seigo Nonaka 2016/11/15 05:15:59 Question: Is there no unit tests for this function
Yirui Huang 2016/11/16 00:23:45 Done.
- // Start with the current locale.
- std::string langs = g_locale_manager->GetLocale();
+ // Start with the current locale(s).
+ std::string locales_string = g_locale_manager->GetLocales();
- // If we're not en-US, add in en-US which will be
+ // If accept languages do not contain en-US, add in en-US which will be
// used with a lower q-value.
- if (base::ToLowerASCII(langs) != "en-us") {
- langs += ",en-US";
- }
- return langs;
+ size_t found_enUS = locales_string.find("en-US");
Seigo Nonaka 2016/11/15 05:15:59 Question: do we no longer need to compare in case
Yirui Huang 2016/11/16 00:23:45 I thought locales_string that we got from here is
Seigo Nonaka 2016/11/16 01:26:14 Please note that developer can set accept language
Yirui Huang 2016/11/16 01:49:12 I see. Thanks for pointing this out. I wasn't awar
+ if (found_enUS == std::string::npos)
+ locales_string += ",en-US";
+ return locales_string;
}
// static

Powered by Google App Engine
This is Rietveld 408576698