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

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: Addressing comments. 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 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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698