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

Side by Side Diff: chrome/browser/autofill/credit_card_field.cc

Issue 2818033: AutoFill: Aggregate profile data. Remove the AutoFill InfoBar. (Closed)
Patch Set: Comment. Created 10 years, 5 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/browser/autofill/credit_card_field.h" 5 #include "chrome/browser/autofill/credit_card_field.h"
6 6
7 #include "base/scoped_ptr.h" 7 #include "base/scoped_ptr.h"
8 #include "base/string16.h" 8 #include "base/string16.h"
9 #include "chrome/browser/autofill/autofill_field.h" 9 #include "chrome/browser/autofill/autofill_field.h"
10 10
(...skipping 12 matching lines...) Expand all
23 23
24 Add(field_type_map, type_, AutoFillType(CREDIT_CARD_TYPE)); 24 Add(field_type_map, type_, AutoFillType(CREDIT_CARD_TYPE));
25 25
26 ok = ok && Add(field_type_map, expiration_month_, 26 ok = ok && Add(field_type_map, expiration_month_,
27 AutoFillType(CREDIT_CARD_EXP_MONTH)); 27 AutoFillType(CREDIT_CARD_EXP_MONTH));
28 DCHECK(ok); 28 DCHECK(ok);
29 ok = ok && Add(field_type_map, expiration_year_, 29 ok = ok && Add(field_type_map, expiration_year_,
30 AutoFillType(CREDIT_CARD_EXP_4_DIGIT_YEAR)); 30 AutoFillType(CREDIT_CARD_EXP_4_DIGIT_YEAR));
31 DCHECK(ok); 31 DCHECK(ok);
32 32
33 Add(field_type_map, verification_,
34 AutoFillType(CREDIT_CARD_VERIFICATION_CODE));
35
36 return ok; 33 return ok;
37 } 34 }
38 35
39 // static 36 // static
40 CreditCardField* CreditCardField::Parse( 37 CreditCardField* CreditCardField::Parse(
41 std::vector<AutoFillField*>::const_iterator* iter, 38 std::vector<AutoFillField*>::const_iterator* iter,
42 bool is_ecml) { 39 bool is_ecml) {
43 scoped_ptr<CreditCardField> credit_card_field(new CreditCardField); 40 scoped_ptr<CreditCardField> credit_card_field(new CreditCardField);
44 std::vector<AutoFillField*>::const_iterator q = *iter; 41 std::vector<AutoFillField*>::const_iterator q = *iter;
45 string16 pattern; 42 string16 pattern;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 ParseText(&p, ASCIIToUTF16("^clnm"), 78 ParseText(&p, ASCIIToUTF16("^clnm"),
82 &credit_card_field->cardholder_last_)) { 79 &credit_card_field->cardholder_last_)) {
83 credit_card_field->cardholder_ = first; 80 credit_card_field->cardholder_ = first;
84 q = p; 81 q = p;
85 continue; 82 continue;
86 } 83 }
87 } 84 }
88 85
89 // TODO(jhawkins): Parse the type select control. 86 // TODO(jhawkins): Parse the type select control.
90 87
91 // We look for a card security code before we look for a credit card number
92 // and match the general term "number". The security code has a plethora of
93 // names; we've seen "verification #", "verification number",
94 // "card identification number" and others listed in the ParseText() call
95 // below.
96 if (is_ecml) {
97 pattern = GetEcmlPattern(kEcmlCardVerification);
98 } else {
99 pattern = ASCIIToUTF16(
100 "verification|card identification|cvn|security code|cvv code|cvc");
101 }
102
103 if (credit_card_field->verification_ == NULL &&
104 ParseText(&q, pattern, &credit_card_field->verification_)) {
105 continue;
106 }
107
108 if (is_ecml) 88 if (is_ecml)
109 pattern = GetEcmlPattern(kEcmlCardNumber); 89 pattern = GetEcmlPattern(kEcmlCardNumber);
110 else 90 else
111 pattern = ASCIIToUTF16("number|card #|card no.|card_number|card number"); 91 pattern = ASCIIToUTF16("number|card #|card no.|card_number|card number");
112 92
113 if (credit_card_field->number_ == NULL && ParseText(&q, pattern, 93 if (credit_card_field->number_ == NULL && ParseText(&q, pattern,
114 &credit_card_field->number_)) 94 &credit_card_field->number_))
115 continue; 95 continue;
116 96
117 // "Expiration date" is the most common label here, but some pages have 97 // "Expiration date" is the most common label here, but some pages have
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 } 150 }
171 151
172 return NULL; 152 return NULL;
173 } 153 }
174 154
175 CreditCardField::CreditCardField() 155 CreditCardField::CreditCardField()
176 : cardholder_(NULL), 156 : cardholder_(NULL),
177 cardholder_last_(NULL), 157 cardholder_last_(NULL),
178 type_(NULL), 158 type_(NULL),
179 number_(NULL), 159 number_(NULL),
180 verification_(NULL),
181 expiration_month_(NULL), 160 expiration_month_(NULL),
182 expiration_year_(NULL) { 161 expiration_year_(NULL) {
183 } 162 }
OLDNEW
« no previous file with comments | « chrome/browser/autofill/credit_card_field.h ('k') | chrome/browser/autofill/credit_card_field_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698