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

Side by Side Diff: third_party/libaddressinput/chromium/has_all_required_fields.cc

Issue 298863012: Use upstream libaddressinput in Chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Work in progress for suggestions impl. Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698