OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/content/browser/wallet/instrument.h" | 5 #include "components/autofill/content/browser/wallet/instrument.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 #include "components/autofill/content/browser/wallet/wallet_address.h" | 12 #include "components/autofill/content/browser/wallet/wallet_address.h" |
13 #include "components/autofill/core/browser/autofill_country.h" | 13 #include "components/autofill/core/browser/autofill_country.h" |
14 #include "components/autofill/core/browser/autofill_profile.h" | 14 #include "components/autofill/core/browser/autofill_profile.h" |
| 15 #include "components/autofill/core/browser/autofill_sync_constants.h" |
15 #include "components/autofill/core/browser/credit_card.h" | 16 #include "components/autofill/core/browser/credit_card.h" |
16 #include "components/autofill/core/browser/validation.h" | 17 #include "components/autofill/core/browser/validation.h" |
17 | 18 |
18 namespace autofill { | 19 namespace autofill { |
19 namespace wallet { | 20 namespace wallet { |
20 | 21 |
21 namespace { | 22 namespace { |
22 | 23 |
23 // Converts a known Autofill card type to a Instrument::FormOfPayment. | 24 // Converts a known Autofill card type to a Instrument::FormOfPayment. |
24 // Used for creating new Instruments. | 25 // Used for creating new Instruments. |
25 Instrument::FormOfPayment FormOfPaymentFromCardType(const std::string& type) { | 26 Instrument::FormOfPayment FormOfPaymentFromCardType(const std::string& type) { |
26 if (type == kAmericanExpressCard) | 27 if (type == kAmericanExpressCard) |
27 return Instrument::AMEX; | 28 return Instrument::AMEX; |
28 else if (type == kDiscoverCard) | 29 else if (type == kDiscoverCard) |
29 return Instrument::DISCOVER; | 30 return Instrument::DISCOVER; |
30 else if (type == kMasterCard) | 31 else if (type == kMasterCard) |
31 return Instrument::MASTER_CARD; | 32 return Instrument::MASTER_CARD; |
32 else if (type == kVisaCard) | 33 else if (type == kVisaCard) |
33 return Instrument::VISA; | 34 return Instrument::VISA; |
34 | 35 |
35 return Instrument::UNKNOWN; | 36 return Instrument::UNKNOWN; |
36 } | 37 } |
37 | 38 |
38 std::string FormOfPaymentToString(Instrument::FormOfPayment form_of_payment) { | 39 std::string FormOfPaymentToString(Instrument::FormOfPayment form_of_payment) { |
39 switch (form_of_payment) { | 40 switch (form_of_payment) { |
40 case Instrument::UNKNOWN: | 41 case Instrument::UNKNOWN: |
41 return "UNKNOWN"; | 42 return kSyncCardTypeUnknown; |
42 case Instrument::VISA: | 43 case Instrument::VISA: |
43 return "VISA"; | 44 return kSyncCardTypeVisa; |
44 case Instrument::MASTER_CARD: | 45 case Instrument::MASTER_CARD: |
45 return "MASTER_CARD"; | 46 return kSyncCardTypeMasterCard; |
46 case Instrument::AMEX: | 47 case Instrument::AMEX: |
47 return "AMEX"; | 48 return kSyncCardTypeAmex; |
48 case Instrument::DISCOVER: | 49 case Instrument::DISCOVER: |
49 return "DISCOVER"; | 50 return kSyncCardTypeDiscover; |
50 case Instrument::JCB: | 51 case Instrument::JCB: |
51 return "JCB"; | 52 return kSyncCardTypeJCB; |
52 } | 53 } |
53 NOTREACHED(); | 54 NOTREACHED(); |
54 return "NOT_POSSIBLE"; | 55 return "NOT_POSSIBLE"; |
55 } | 56 } |
56 | 57 |
57 } // namespace | 58 } // namespace |
58 | 59 |
59 Instrument::Instrument(const CreditCard& card, | 60 Instrument::Instrument(const CreditCard& card, |
60 const base::string16& card_verification_number, | 61 const base::string16& card_verification_number, |
61 const AutofillProfile& profile) | 62 const AutofillProfile& profile) |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 | 117 |
117 void Instrument::Init() { | 118 void Instrument::Init() { |
118 if (primary_account_number_.size() >= 4) { | 119 if (primary_account_number_.size() >= 4) { |
119 last_four_digits_ = | 120 last_four_digits_ = |
120 primary_account_number_.substr(primary_account_number_.size() - 4); | 121 primary_account_number_.substr(primary_account_number_.size() - 4); |
121 } | 122 } |
122 } | 123 } |
123 | 124 |
124 } // namespace wallet | 125 } // namespace wallet |
125 } // namespace autofill | 126 } // namespace autofill |
OLD | NEW |