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

Unified Diff: third_party/libaddressinput/chromium/cpp/src/address_data.cc

Issue 261013010: autocomplete: add ability to get full address (hidden behind a flag). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rouslan review Created 6 years, 7 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/cpp/src/address_data.cc
diff --git a/third_party/libaddressinput/chromium/cpp/src/address_data.cc b/third_party/libaddressinput/chromium/cpp/src/address_data.cc
index 08da6ca153507e543ff5af83d100f3008bc052ee..444db413b4f354a67c22cf9031fe418e6dcba59d 100644
--- a/third_party/libaddressinput/chromium/cpp/src/address_data.cc
+++ b/third_party/libaddressinput/chromium/cpp/src/address_data.cc
@@ -50,10 +50,12 @@ const std::string* GetMemberForField(const AddressData& address,
return &address.organization;
case RECIPIENT:
return &address.recipient;
- default:
- assert(false);
- return NULL;
+ case STREET_ADDRESS:
+ break;
}
+
+ assert(false);
+ return NULL;
}
} // namespace
@@ -117,5 +119,32 @@ void AddressData::SetFieldValue(AddressField field, const std::string& value) {
}
}
+bool AddressData::HasAllRequiredFields() const {
+ if (country_code.empty())
+ return false;
+
+ Rule rule;
+ rule.CopyFrom(Rule::GetDefault());
+ if (!rule.ParseSerializedRule(
+ RegionDataConstants::GetRegionData(country_code))) {
+ return false;
+ }
+
+ std::vector< ::i18n::addressinput::AddressField> required_fields =
+ rule.GetRequired();
+ for (size_t i = 0; i < required_fields.size(); ++i) {
+ if (required_fields[i] == STREET_ADDRESS &&
+ (address_lines.empty() || address_lines[0].empty())) {
please use gerrit instead 2014/05/09 23:38:55 Please avoid hitting GetFieldValue(STREET_ADDRESS)
+ return false;
+ }
+
+ if (GetFieldValue(required_fields[i]).empty()) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
} // namespace addressinput
} // namespace i18n

Powered by Google App Engine
This is Rietveld 408576698