OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "third_party/libaddressinput/chromium/has_all_required_fields.h" |
| 6 |
| 7 #include "base/macros.h" |
| 8 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_da
ta.h" |
| 9 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_fi
eld.h" |
| 10 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_me
tadata.h" |
| 11 |
| 12 namespace autofill { |
| 13 namespace addressinput { |
| 14 |
| 15 using ::i18n::addressinput::AddressData; |
| 16 using ::i18n::addressinput::AddressField; |
| 17 using ::i18n::addressinput::IsFieldRequired; |
| 18 |
| 19 bool HasAllRequiredFields(const AddressData& address_to_check) { |
| 20 static const AddressField kFields[] = { |
| 21 ::i18n::addressinput::COUNTRY, |
| 22 ::i18n::addressinput::ADMIN_AREA, |
| 23 ::i18n::addressinput::LOCALITY, |
| 24 ::i18n::addressinput::DEPENDENT_LOCALITY, |
| 25 ::i18n::addressinput::SORTING_CODE, |
| 26 ::i18n::addressinput::POSTAL_CODE, |
| 27 ::i18n::addressinput::STREET_ADDRESS, |
| 28 ::i18n::addressinput::RECIPIENT |
| 29 }; |
| 30 |
| 31 for (size_t i = 0; i < arraysize(kFields); ++i) { |
| 32 AddressField field = kFields[i]; |
| 33 if (address_to_check.IsFieldEmpty(field) && |
| 34 IsFieldRequired(field, address_to_check.region_code)) { |
| 35 return false; |
| 36 } |
| 37 } |
| 38 |
| 39 return true; |
| 40 } |
| 41 |
| 42 } // namespace addressinput |
| 43 } // namespace autofill |
OLD | NEW |