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 |