| Index: third_party/libaddressinput/chromium/has_all_required_fields.cc
|
| diff --git a/third_party/libaddressinput/chromium/has_all_required_fields.cc b/third_party/libaddressinput/chromium/has_all_required_fields.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..3e0e637f567bda083c3aabaa8f8965b43c2a1805
|
| --- /dev/null
|
| +++ b/third_party/libaddressinput/chromium/has_all_required_fields.cc
|
| @@ -0,0 +1,41 @@
|
| +// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "third_party/libaddressinput/chromium/has_all_required_fields.h"
|
| +
|
| +#include "base/macros.h"
|
| +#include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_data.h"
|
| +#include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_field.h"
|
| +#include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_metadata.h"
|
| +
|
| +namespace autofill {
|
| +
|
| +using ::i18n::addressinput::AddressData;
|
| +using ::i18n::addressinput::AddressField;
|
| +using ::i18n::addressinput::IsFieldRequired;
|
| +
|
| +bool HasAllRequiredFields(const AddressData& address_to_check) {
|
| + static const AddressField kFields[] = {
|
| + ::i18n::addressinput::COUNTRY,
|
| + ::i18n::addressinput::ADMIN_AREA,
|
| + ::i18n::addressinput::LOCALITY,
|
| + ::i18n::addressinput::DEPENDENT_LOCALITY,
|
| + ::i18n::addressinput::SORTING_CODE,
|
| + ::i18n::addressinput::POSTAL_CODE,
|
| + ::i18n::addressinput::STREET_ADDRESS,
|
| + ::i18n::addressinput::RECIPIENT
|
| + };
|
| +
|
| + for (size_t i = 0; i < arraysize(kFields); ++i) {
|
| + AddressField field = kFields[i];
|
| + if (address_to_check.IsFieldEmpty(field) &&
|
| + IsFieldRequired(field, address_to_check.region_code)) {
|
| + return false;
|
| + }
|
| + }
|
| +
|
| + return true;
|
| +}
|
| +
|
| +} // namespace autofill
|
|
|