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

Side by Side Diff: components/autofill/core/browser/credit_card_field.cc

Issue 681843002: Autofill - improve Macy's and Best Buy checkout by parsing input type="tel" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 | « chrome/test/data/autofill/heuristics/output/21_checkout_m_macys.com.out ('k') | no next file » | 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/core/browser/credit_card_field.h" 5 #include "components/autofill/core/browser/credit_card_field.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/string16.h" 10 #include "base/strings/string16.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 &credit_card_field->type_)) { 81 &credit_card_field->type_)) {
82 continue; 82 continue;
83 } 83 }
84 84
85 // We look for a card security code before we look for a credit 85 // We look for a card security code before we look for a credit
86 // card number and match the general term "number". The security code 86 // card number and match the general term "number". The security code
87 // has a plethora of names; we've seen "verification #", 87 // has a plethora of names; we've seen "verification #",
88 // "verification number", "card identification number" and others listed 88 // "verification number", "card identification number" and others listed
89 // in the |pattern| below. 89 // in the |pattern| below.
90 base::string16 pattern = base::UTF8ToUTF16(autofill::kCardCvcRe); 90 base::string16 pattern = base::UTF8ToUTF16(autofill::kCardCvcRe);
91 // Some sites use type="tel" for numerical inputs.
91 if (!credit_card_field->verification_ && 92 if (!credit_card_field->verification_ &&
92 ParseField(scanner, pattern, &credit_card_field->verification_)) { 93 ParseFieldSpecifics(scanner,
94 pattern,
95 MATCH_DEFAULT | MATCH_TELEPHONE,
96 &credit_card_field->verification_)) {
93 continue; 97 continue;
94 } 98 }
95 99
96 pattern = base::UTF8ToUTF16(autofill::kCardNumberRe); 100 pattern = base::UTF8ToUTF16(autofill::kCardNumberRe);
97 AutofillField* current_number_field; 101 AutofillField* current_number_field;
98 if (ParseField(scanner, pattern, &current_number_field)) { 102 if (ParseFieldSpecifics(scanner,
103 pattern,
104 MATCH_DEFAULT | MATCH_TELEPHONE,
105 &current_number_field)) {
99 // Avoid autofilling any credit card number field having very low or high 106 // Avoid autofilling any credit card number field having very low or high
100 // |start_index| on the HTML form. 107 // |start_index| on the HTML form.
101 size_t start_index = 0; 108 size_t start_index = 0;
102 if (!credit_card_field->numbers_.empty()) { 109 if (!credit_card_field->numbers_.empty()) {
103 size_t last_number_field_size = 110 size_t last_number_field_size =
104 credit_card_field->numbers_.back()->credit_card_number_offset() + 111 credit_card_field->numbers_.back()->credit_card_number_offset() +
105 credit_card_field->numbers_.back()->max_length; 112 credit_card_field->numbers_.back()->max_length;
106 113
107 // Distinguish between 114 // Distinguish between
108 // (a) one card split across multiple fields 115 // (a) one card split across multiple fields
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 261
255 ServerFieldType CreditCardField::GetExpirationYearType() const { 262 ServerFieldType CreditCardField::GetExpirationYearType() const {
256 return (expiration_date_ 263 return (expiration_date_
257 ? exp_year_type_ 264 ? exp_year_type_
258 : ((expiration_year_ && expiration_year_->max_length == 2) 265 : ((expiration_year_ && expiration_year_->max_length == 2)
259 ? CREDIT_CARD_EXP_2_DIGIT_YEAR 266 ? CREDIT_CARD_EXP_2_DIGIT_YEAR
260 : CREDIT_CARD_EXP_4_DIGIT_YEAR)); 267 : CREDIT_CARD_EXP_4_DIGIT_YEAR));
261 } 268 }
262 269
263 } // namespace autofill 270 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/test/data/autofill/heuristics/output/21_checkout_m_macys.com.out ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698