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

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

Issue 952993003: [android] Handle unknown country codes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: known_country_names Created 5 years, 10 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 | « no previous file | components/autofill/core/browser/autofill_country.cc » ('j') | 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 d284d5d06f1dce9e0da59c304057c6f9f270dabf..42903337cb004536fe7b811b3d9c51380e1eeeb0 100644
--- a/chrome/browser/android/preferences/autofill/autofill_profile_bridge.cc
+++ b/chrome/browser/android/preferences/autofill/autofill_profile_bridge.cc
@@ -10,6 +10,7 @@
#include "base/android/jni_array.h"
#include "base/android/jni_string.h"
#include "base/bind.h"
+#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/browser_process.h"
#include "components/autofill/core/browser/autofill_country.h"
#include "jni/AutofillProfileBridge_jni.h"
@@ -59,21 +60,25 @@ static void GetSupportedCountries(JNIEnv* env,
jobject j_country_name_list) {
std::vector<std::string> country_codes =
::i18n::addressinput::GetRegionCodes();
- std::vector<base::string16> country_names;
+ std::vector<std::string> known_country_codes;
+ std::vector<base::string16> known_country_names;
std::string locale = g_browser_process->GetApplicationLocale();
for (auto country_code : country_codes) {
- country_names.push_back(l10n_util::GetDisplayNameForCountry(country_code,
- locale));
+ const base::string16& country_name =
+ l10n_util::GetDisplayNameForCountry(country_code, locale);
+ // Don't display a country code for which a name is not known yet.
+ if (country_name != base::UTF8ToUTF16(country_code)) {
+ known_country_codes.push_back(country_code);
+ known_country_names.push_back(country_name);
+ }
}
- Java_AutofillProfileBridge_stringArrayToList(env,
- ToJavaArrayOfStrings(
- env, country_codes).obj(),
- j_country_code_list);
- Java_AutofillProfileBridge_stringArrayToList(env,
- ToJavaArrayOfStrings(
- env, country_names).obj(),
- j_country_name_list);
+ Java_AutofillProfileBridge_stringArrayToList(
+ env, ToJavaArrayOfStrings(env, known_country_codes).obj(),
+ j_country_code_list);
+ Java_AutofillProfileBridge_stringArrayToList(
+ env, ToJavaArrayOfStrings(env, known_country_names).obj(),
+ j_country_name_list);
}
static jstring GetAddressUiComponents(JNIEnv* env,
« no previous file with comments | « no previous file | components/autofill/core/browser/autofill_country.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698