summaryrefslogtreecommitdiffstats
path: root/third_party
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-06 11:12:47 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-06 11:12:47 +0000
commitb847dd7c6e63ac1ebed2912635b7227aeab3b445 (patch)
treeaeee33cc6bca296cac98aec1f74f636742190ea1 /third_party
parent94cda63b191b7f4546acaca1af8e50928df528b0 (diff)
downloadchromium_src-b847dd7c6e63ac1ebed2912635b7227aeab3b445.zip
chromium_src-b847dd7c6e63ac1ebed2912635b7227aeab3b445.tar.gz
chromium_src-b847dd7c6e63ac1ebed2912635b7227aeab3b445.tar.bz2
Canonicalize non-US administrative areas when creating new wallet addresses
Also fix address input validation of street address (we were failing to copy the street address into the AddressData struct before validating). BUG=340905 Review URL: https://codereview.chromium.org/154423004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@249354 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party')
-rw-r--r--third_party/libaddressinput/chromium/cpp/include/libaddressinput/address_validator.h6
-rw-r--r--third_party/libaddressinput/chromium/cpp/src/address_validator.cc13
2 files changed, 19 insertions, 0 deletions
diff --git a/third_party/libaddressinput/chromium/cpp/include/libaddressinput/address_validator.h b/third_party/libaddressinput/chromium/cpp/include/libaddressinput/address_validator.h
index a23684d..50f7726 100644
--- a/third_party/libaddressinput/chromium/cpp/include/libaddressinput/address_validator.h
+++ b/third_party/libaddressinput/chromium/cpp/include/libaddressinput/address_validator.h
@@ -119,6 +119,12 @@ class AddressValidator {
virtual Status ValidateAddress(const AddressData& address,
const AddressProblemFilter& filter,
AddressProblems* problems) const = 0;
+
+ // Canonicalizes the administrative area in |address_data|. For example,
+ // "texas" changes to "TX". Returns true on success, otherwise leaves
+ // |address_data| alone and returns false.
+ virtual bool CanonicalizeAdministrativeArea(AddressData* address_data)
+ const = 0;
};
} // namespace addressinput
diff --git a/third_party/libaddressinput/chromium/cpp/src/address_validator.cc b/third_party/libaddressinput/chromium/cpp/src/address_validator.cc
index fe1b7502..33453fb 100644
--- a/third_party/libaddressinput/chromium/cpp/src/address_validator.cc
+++ b/third_party/libaddressinput/chromium/cpp/src/address_validator.cc
@@ -188,6 +188,19 @@ class AddressValidatorImpl : public AddressValidator {
return SUCCESS;
}
+ virtual bool CanonicalizeAdministrativeArea(AddressData* address_data) const {
+ std::map<std::string, const Ruleset*>::const_iterator ruleset_it =
+ rules_.find(address_data->country_code);
+ if (ruleset_it == rules_.end()) {
+ return false;
+ }
+ const Rule& rule =
+ ruleset_it->second->GetLanguageCodeRule(address_data->language_code);
+
+ return rule.CanonicalizeSubKey(address_data->administrative_area,
+ &address_data->administrative_area);
+ }
+
private:
// Called when CountryRulesAggregator::AggregateRules loads the |ruleset| for
// the |country_code|.