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

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: . 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..604d1547cd222d3fd353338d7b4b49bdf1a7fe45 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,31 @@ 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) {
+ if (address_lines.empty() || address_lines[0].empty()) {
+ return false;
please use gerrit instead 2014/05/13 05:07:46 Thanks, lgtm.
+ }
+ } else if (GetFieldValue(required_fields[i]).empty()) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
} // namespace addressinput
} // namespace i18n

Powered by Google App Engine
This is Rietveld 408576698