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

Unified Diff: chrome/browser/android/preferences/autofill/autofill_profile_bridge.cc

Issue 882123003: Use/save language code for autofill profiles. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove poor use of statics Created 5 years, 11 months 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 | « chrome/android/java/src/org/chromium/chrome/browser/preferences/autofill/AutofillProfileEditor.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/preferences/autofill/autofill_profile_bridge.cc
diff --git a/chrome/browser/android/preferences/autofill/autofill_profile_bridge.cc b/chrome/browser/android/preferences/autofill/autofill_profile_bridge.cc
index b4ffde31f71df60eff21f9757fbb7a85a69d376c..d284d5d06f1dce9e0da59c304057c6f9f270dabf 100644
--- a/chrome/browser/android/preferences/autofill/autofill_profile_bridge.cc
+++ b/chrome/browser/android/preferences/autofill/autofill_profile_bridge.cc
@@ -47,10 +47,10 @@ enum AddressField {
static jstring GetDefaultCountryCode(JNIEnv* env,
jclass clazz) {
- std::string defaultCountryCode =
+ std::string default_country_code =
autofill::AutofillCountry::CountryCodeForLocale(
g_browser_process->GetApplicationLocale());
- return ConvertUTF8ToJavaString(env, defaultCountryCode).Release();
+ return ConvertUTF8ToJavaString(env, default_country_code).Release();
}
static void GetSupportedCountries(JNIEnv* env,
@@ -76,9 +76,10 @@ static void GetSupportedCountries(JNIEnv* env,
j_country_name_list);
}
-static void GetAddressUiComponents(JNIEnv* env,
+static jstring GetAddressUiComponents(JNIEnv* env,
jclass clazz,
jstring j_country_code,
+ jstring j_language_code,
jobject j_id_list,
jobject j_name_list) {
std::string best_language_tag;
@@ -87,10 +88,18 @@ static void GetAddressUiComponents(JNIEnv* env,
::i18n::addressinput::Localization localization;
localization.SetGetter(l10n_util::GetStringUTF8);
+ std::string language_code;
+ if (j_language_code != NULL) {
+ language_code = ConvertJavaStringToUTF8(env, j_language_code);
+ }
+ if (language_code.empty()) {
+ language_code = g_browser_process->GetApplicationLocale();
+ }
+
std::vector<::i18n::addressinput::AddressUiComponent> ui_components =
::i18n::addressinput::BuildComponents(
ConvertJavaStringToUTF8(env, j_country_code), localization,
- g_browser_process->GetApplicationLocale(), &best_language_tag);
+ language_code, &best_language_tag);
for (auto ui_component : ui_components) {
component_labels.push_back(ui_component.name);
@@ -136,6 +145,8 @@ static void GetAddressUiComponents(JNIEnv* env,
ToJavaArrayOfStrings(
env, component_labels).obj(),
j_name_list);
+
+ return ConvertUTF8ToJavaString(env, best_language_tag).Release();
}
// static
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/preferences/autofill/AutofillProfileEditor.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698