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

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

Issue 2680143002: Use dropdown list for admin areas in pr form. (Closed)
Patch Set: The one where I fixed a line (an error from sync!) Created 3 years, 9 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..aaa4b3fa0fa72acff09b2037f568968c588b1a90 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,23 @@ 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()) {
Mathieu 2017/03/24 17:24:33 if (rule_iterator != rules.end() && rule_iterator-
Parastoo 2017/03/24 22:42:23 Done.
+ if (rule_iterator->second)
+ return (rule_iterator->second)->GetSubKeys();
+ return std::vector<std::string>();
+ } else {
+ return std::vector<std::string>();
+ }
+}
+
AddressValidator::Status AddressValidator::ValidateAddress(
const AddressData& address,
const FieldProblemMap* filter,
@@ -141,7 +160,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