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

Unified Diff: chrome/browser/ui/autofill/country_combobox_model.cc

Issue 178263004: rAc - Only show countries we're able to fill in. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 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
Index: chrome/browser/ui/autofill/country_combobox_model.cc
diff --git a/chrome/browser/ui/autofill/country_combobox_model.cc b/chrome/browser/ui/autofill/country_combobox_model.cc
index 66e5567e0e68081db9386090e8b031e1be1a2454..318a5307d7c7f658eeccf4e1fc32e8d968593706 100644
--- a/chrome/browser/ui/autofill/country_combobox_model.cc
+++ b/chrome/browser/ui/autofill/country_combobox_model.cc
@@ -22,27 +22,42 @@ namespace autofill {
namespace {
-bool ShouldShowCountry(const std::string& country_code) {
+bool ShouldShowCountry(const std::string& country_code,
+ bool show_partially_supported_countries,
+ const std::set<base::string16> candidate_countries) {
Dan Beam 2014/03/01 03:38:10 nit: const-ref
Evan Stade 2014/03/04 00:11:30 good catch, done.
#if defined(ENABLE_AUTOFILL_DIALOG)
- return i18ninput::CountryIsFullySupported(country_code);
-#else
- return true;
+ if (!show_partially_supported_countries &&
+ !i18ninput::CountryIsFullySupported(country_code)) {
+ return false;
+ }
#endif
+
Dan Beam 2014/03/01 03:38:10 if (candidate_countries.empty()) return true; /
Evan Stade 2014/03/04 00:11:30 not really an improvement, but done
Dan Beam 2014/03/04 00:19:50 doesn't construct an AutofillCountry needlessly...
+ AutofillCountry country(country_code,
+ g_browser_process->GetApplicationLocale());
+ if (!candidate_countries.empty() &&
+ !candidate_countries.count(base::ASCIIToUTF16(country_code)) &&
+ !candidate_countries.count(country.name())) {
+ return false;
+ }
Ilya Sherman 2014/03/03 23:55:54 What happens if the <select> dropdown includes loc
Evan Stade 2014/03/04 00:11:30 what happens is that requestAutocomplete won't wor
Dan Beam 2014/03/04 00:19:50 in general i think this was a cool idea, but +1 to
Ilya Sherman 2014/03/04 00:53:57 IMO we should either only support country codes, o
+
+ return true;
}
} // namespace
CountryComboboxModel::CountryComboboxModel(
const PersonalDataManager& manager,
+ const std::set<base::string16>& country_filter,
bool show_partially_supported_countries) {
// Insert the default country at the top as well as in the ordered list.
- const std::string& app_locale = g_browser_process->GetApplicationLocale();
std::string default_country_code =
manager.GetDefaultCountryCodeForNewAddress();
DCHECK(!default_country_code.empty());
- if (show_partially_supported_countries ||
- ShouldShowCountry(default_country_code)) {
+ const std::string& app_locale = g_browser_process->GetApplicationLocale();
+ if (ShouldShowCountry(default_country_code,
+ show_partially_supported_countries,
+ country_filter)) {
countries_.push_back(new AutofillCountry(default_country_code, app_locale));
// The separator item.
countries_.push_back(NULL);
@@ -60,8 +75,11 @@ CountryComboboxModel::CountryComboboxModel(
std::vector<AutofillCountry*> sorted_countries;
for (std::vector<std::string>::const_iterator it =
available_countries.begin(); it != available_countries.end(); ++it) {
- if (show_partially_supported_countries || ShouldShowCountry(*it))
+ if (ShouldShowCountry(*it,
+ show_partially_supported_countries,
+ country_filter)) {
sorted_countries.push_back(new AutofillCountry(*it, app_locale));
+ }
}
l10n_util::SortStringsUsingMethod(app_locale,

Powered by Google App Engine
This is Rietveld 408576698