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

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

Issue 386873002: Reland "Use upstream libaddressinput in Chrome." (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix iOS compile. Created 6 years, 5 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 a5d9f62c282b05b70f652a31a0939936d72b1f22..fda64cb4407d06e7e507e3f2c62be4a13dfa2154 100644
--- a/chrome/browser/ui/autofill/country_combobox_model.cc
+++ b/chrome/browser/ui/autofill/country_combobox_model.cc
@@ -4,6 +4,9 @@
#include "chrome/browser/ui/autofill/country_combobox_model.h"
+#include <algorithm>
+#include <iterator>
+
#include "base/logging.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/browser_process.h"
@@ -14,7 +17,7 @@
// TODO(rouslan): Remove this check. http://crbug.com/337587
#if defined(ENABLE_AUTOFILL_DIALOG)
-#include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/address_ui.h"
+#include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_ui.h"
#endif
namespace autofill {
@@ -41,12 +44,22 @@ void CountryComboboxModel::SetCountries(
}
// The sorted list of countries.
-#if defined(ENABLE_AUTOFILL_DIALOG)
- const std::vector<std::string>& available_countries =
- ::i18n::addressinput::GetRegionCodes();
-#else
std::vector<std::string> available_countries;
AutofillCountry::GetAvailableCountries(&available_countries);
+
+#if defined(ENABLE_AUTOFILL_DIALOG)
+ // Filter out the countries that do not have rules for address input and
+ // validation.
+ const std::vector<std::string>& addressinput_countries =
+ ::i18n::addressinput::GetRegionCodes();
+ std::vector<std::string> filtered_countries;
+ filtered_countries.reserve(available_countries.size());
+ std::set_intersection(available_countries.begin(),
+ available_countries.end(),
+ addressinput_countries.begin(),
+ addressinput_countries.end(),
+ std::back_inserter(filtered_countries));
+ available_countries.swap(filtered_countries);
#endif
std::vector<AutofillCountry*> sorted_countries;

Powered by Google App Engine
This is Rietveld 408576698