OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/autofill/core/browser/autofill_data_util.h" | 5 #include "components/autofill/core/browser/autofill_data_util.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/i18n/char_iterator.h" | 10 #include "base/i18n/char_iterator.h" |
11 #include "base/strings/string_split.h" | 11 #include "base/strings/string_split.h" |
12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "components/autofill/core/browser/field_types.h" | 14 #include "components/autofill/core/browser/field_types.h" |
15 #include "third_party/icu/source/common/unicode/uscript.h" | 15 #include "third_party/icu/source/common/unicode/uscript.h" |
16 | 16 |
17 namespace autofill { | 17 namespace autofill { |
18 namespace data_util { | 18 namespace data_util { |
19 | 19 |
20 namespace { | 20 namespace { |
21 // Mappings from Chrome card types to Payment Request API basic card payment | |
22 // spec types and icons. Note that "generic" is not in the spec. | |
23 // https://w3c.github.io/webpayments-methods-card/#method-id | |
24 const PaymentRequestData kPaymentRequestData[]{ | |
25 {"americanExpressCC", "amex", IDR_AUTOFILL_PR_AMEX}, | |
26 {"dinersCC", "diners", IDR_AUTOFILL_PR_DINERS}, | |
27 {"discoverCC", "discover", IDR_AUTOFILL_PR_DISCOVER}, | |
28 {"jcbCC", "jcb", IDR_AUTOFILL_PR_JCB}, | |
29 {"masterCardCC", "mastercard", IDR_AUTOFILL_PR_MASTERCARD}, | |
30 {"unionPayCC", "unionpay", IDR_AUTOFILL_PR_UNIONPAY}, | |
31 {"visaCC", "visa", IDR_AUTOFILL_PR_VISA}, | |
32 }; | |
33 const PaymentRequestData kGenericPaymentRequestData = {"genericCC", "generic", | |
34 IDR_AUTOFILL_PR_GENERIC}; | |
35 | |
36 const char* const name_prefixes[] = { | 21 const char* const name_prefixes[] = { |
37 "1lt", "1st", "2lt", "2nd", "3rd", "admiral", "capt", | 22 "1lt", "1st", "2lt", "2nd", "3rd", "admiral", "capt", |
38 "captain", "col", "cpt", "dr", "gen", "general", "lcdr", | 23 "captain", "col", "cpt", "dr", "gen", "general", "lcdr", |
39 "lt", "ltc", "ltg", "ltjg", "maj", "major", "mg", | 24 "lt", "ltc", "ltg", "ltjg", "maj", "major", "mg", |
40 "mr", "mrs", "ms", "pastor", "prof", "rep", "reverend", | 25 "mr", "mrs", "ms", "pastor", "prof", "rep", "reverend", |
41 "rev", "sen", "st"}; | 26 "rev", "sen", "st"}; |
42 | 27 |
43 const char* const name_suffixes[] = {"b.a", "ba", "d.d.s", "dds", "i", "ii", | 28 const char* const name_suffixes[] = {"b.a", "ba", "d.d.s", "dds", "i", "ii", |
44 "iii", "iv", "ix", "jr", "m.a", "m.d", | 29 "iii", "iv", "ix", "jr", "m.a", "m.d", |
45 "ma", "md", "ms", "ph.d", "phd", "sr", | 30 "ma", "md", "ms", "ph.d", "phd", "sr", |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 // LastFirst | 376 // LastFirst |
392 candidate = profile.GetRawInfo(autofill::NAME_LAST) + | 377 candidate = profile.GetRawInfo(autofill::NAME_LAST) + |
393 profile.GetRawInfo(autofill::NAME_FIRST); | 378 profile.GetRawInfo(autofill::NAME_FIRST); |
394 if (!full_name.compare(candidate)) { | 379 if (!full_name.compare(candidate)) { |
395 return true; | 380 return true; |
396 } | 381 } |
397 | 382 |
398 return false; | 383 return false; |
399 } | 384 } |
400 | 385 |
401 const PaymentRequestData& GetPaymentRequestData(const std::string& type) { | |
402 for (size_t i = 0; i < arraysize(kPaymentRequestData); ++i) { | |
403 if (type == kPaymentRequestData[i].card_type) | |
404 return kPaymentRequestData[i]; | |
405 } | |
406 return kGenericPaymentRequestData; | |
407 } | |
408 | |
409 const char* GetCardTypeForBasicCardPaymentType( | |
410 const std::string& basic_card_payment_type) { | |
411 for (size_t i = 0; i < arraysize(kPaymentRequestData); ++i) { | |
412 if (basic_card_payment_type == | |
413 kPaymentRequestData[i].basic_card_payment_type) { | |
414 return kPaymentRequestData[i].card_type; | |
415 } | |
416 } | |
417 return kGenericPaymentRequestData.card_type; | |
418 } | |
419 | |
420 } // namespace data_util | 386 } // namespace data_util |
421 } // namespace autofill | 387 } // namespace autofill |
OLD | NEW |