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 |
| 14 using ::i18n::addressinput::AddressData; |
| 15 using ::i18n::addressinput::AddressField; |
| 16 using ::i18n::addressinput::IsFieldRequired; |
| 17 |
| 18 bool HasAllRequiredFields(const AddressData& address_to_check) { |
| 19 static const AddressField kFields[] = { |
| 20 ::i18n::addressinput::COUNTRY, |
| 21 ::i18n::addressinput::ADMIN_AREA, |
| 22 ::i18n::addressinput::LOCALITY, |
| 23 ::i18n::addressinput::DEPENDENT_LOCALITY, |
| 24 ::i18n::addressinput::SORTING_CODE, |
| 25 ::i18n::addressinput::POSTAL_CODE, |
| 26 ::i18n::addressinput::STREET_ADDRESS, |
| 27 ::i18n::addressinput::RECIPIENT |
| 28 }; |
| 29 |
| 30 for (size_t i = 0; i < arraysize(kFields); ++i) { |
| 31 AddressField field = kFields[i]; |
| 32 if (address_to_check.IsFieldEmpty(field) && |
| 33 IsFieldRequired(field, address_to_check.region_code)) { |
| 34 return false; |
| 35 } |
| 36 } |
| 37 |
| 38 return true; |
| 39 } |
| 40 |
| 41 } // namespace autofill |
OLD | NEW |