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

Unified Diff: third_party/libaddressinput/chromium/chrome_address_validator.cc

Issue 2680143002: Use dropdown list for admin areas in pr form. (Closed)
Patch Set: Supress error-- suggested by clank team Created 3 years, 8 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: third_party/libaddressinput/chromium/chrome_address_validator.cc
diff --git a/third_party/libaddressinput/chromium/chrome_address_validator.cc b/third_party/libaddressinput/chromium/chrome_address_validator.cc
index b0bd189d8f0542de34bc185ab102e1cee1d2b28d..320451b6d71a86e956219db03ee0cc8756921fca 100644
--- a/third_party/libaddressinput/chromium/chrome_address_validator.cc
+++ b/third_party/libaddressinput/chromium/chrome_address_validator.cc
@@ -17,6 +17,7 @@
#include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_normalizer.h"
#include "third_party/libaddressinput/src/cpp/include/libaddressinput/source.h"
#include "third_party/libaddressinput/src/cpp/include/libaddressinput/storage.h"
+#include "third_party/libaddressinput/src/cpp/src/rule.h"
namespace autofill {
namespace {
@@ -27,6 +28,7 @@ using ::i18n::addressinput::AddressNormalizer;
using ::i18n::addressinput::BuildCallback;
using ::i18n::addressinput::FieldProblemMap;
using ::i18n::addressinput::PreloadSupplier;
+using ::i18n::addressinput::Rule;
using ::i18n::addressinput::Source;
using ::i18n::addressinput::Storage;
@@ -58,6 +60,20 @@ void AddressValidator::LoadRules(const std::string& region_code) {
supplier_->LoadRules(region_code, *rules_loaded_);
}
+std::vector<std::string> AddressValidator::GetRegionSubKeys(
+ const std::string& region_code) {
+ if (!AreRulesLoadedForRegion(region_code))
+ return std::vector<std::string>();
+
+ auto rules = supplier_->GetRulesForRegion(region_code);
+ auto rule_iterator = rules.find("data/" + region_code);
+
+ if (rule_iterator == rules.end() || !rule_iterator->second)
+ return std::vector<std::string>();
+
+ return rule_iterator->second->GetSubKeys();
+}
+
AddressValidator::Status AddressValidator::ValidateAddress(
const AddressData& address,
const FieldProblemMap* filter,
@@ -141,7 +157,7 @@ void AddressValidator::RulesLoaded(bool success,
const std::string& region_code,
int) {
if (load_rules_listener_)
- load_rules_listener_->OnAddressValidationRulesLoaded(region_code, success);
+ load_rules_listener_->OnAddressRulesLoaded(region_code, success);
// Count the first failed attempt to load rules as well.
if (success || attempts_number_[region_code] + 1 >= kMaxAttemptsNumber)

Powered by Google App Engine
This is Rietveld 408576698