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

Side by Side Diff: components/autofill/content/browser/wallet/instrument.cc

Issue 772253003: Create an autofill Suggestion class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 6 years 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
« no previous file with comments | « components/autofill.gypi ('k') | components/autofill/content/browser/wallet/wallet_items.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « components/autofill.gypi ('k') | components/autofill/content/browser/wallet/wallet_items.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698