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

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

Issue 2819183004: [Autofill] Change MasterCard to Mastercard in UI and related tests (Closed)
Patch Set: Resolved conflict Created 3 years, 7 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 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 <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 // execute it only after we have found a valid credit card (first) name 119 // execute it only after we have found a valid credit card (first) name
120 // and haven't yet parsed the expiration date (which usually appears at 120 // and haven't yet parsed the expiration date (which usually appears at
121 // the end). 121 // the end).
122 if (!credit_card_field->expiration_month_ && 122 if (!credit_card_field->expiration_month_ &&
123 ParseField(scanner, base::UTF8ToUTF16(kLastNameRe), 123 ParseField(scanner, base::UTF8ToUTF16(kLastNameRe),
124 &credit_card_field->cardholder_last_)) { 124 &credit_card_field->cardholder_last_)) {
125 continue; 125 continue;
126 } 126 }
127 } 127 }
128 128
129 // Check for a credit card type (Visa, MasterCard, etc.) field. 129 // Check for a credit card type (Visa, Mastercard, etc.) field.
130 // All CC type fields encountered so far have been of type select. 130 // All CC type fields encountered so far have been of type select.
131 if (!credit_card_field->type_ && LikelyCardTypeSelectField(scanner)) { 131 if (!credit_card_field->type_ && LikelyCardTypeSelectField(scanner)) {
132 credit_card_field->type_ = scanner->Cursor(); 132 credit_card_field->type_ = scanner->Cursor();
133 scanner->Advance(); 133 scanner->Advance();
134 continue; 134 continue;
135 } 135 }
136 136
137 // We look for a card security code before we look for a credit card number 137 // We look for a card security code before we look for a credit card number
138 // and match the general term "number". The security code has a plethora of 138 // and match the general term "number". The security code has a plethora of
139 // names; we've seen "verification #", "verification number", "card 139 // names; we've seen "verification #", "verification number", "card
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 bool CreditCardField::LikelyCardTypeSelectField(AutofillScanner* scanner) { 305 bool CreditCardField::LikelyCardTypeSelectField(AutofillScanner* scanner) {
306 if (scanner->IsEnd()) 306 if (scanner->IsEnd())
307 return false; 307 return false;
308 308
309 AutofillField* field = scanner->Cursor(); 309 AutofillField* field = scanner->Cursor();
310 310
311 if (!MatchesFormControlType(field->form_control_type, MATCH_SELECT)) 311 if (!MatchesFormControlType(field->form_control_type, MATCH_SELECT))
312 return false; 312 return false;
313 313
314 // We set |ignore_whitespace| to true on these calls because this is actually 314 // We set |ignore_whitespace| to true on these calls because this is actually
315 // a pretty common mistake; e.g., "Master Card" instead of "MasterCard". 315 // a pretty common mistake; e.g., "Master card" instead of "Mastercard".
316 bool isSelect = (AutofillField::FindShortestSubstringMatchInSelect( 316 bool isSelect = (AutofillField::FindShortestSubstringMatchInSelect(
317 l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_VISA), true, 317 l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_VISA), true,
318 field) >= 0) || 318 field) >= 0) ||
319 (AutofillField::FindShortestSubstringMatchInSelect( 319 (AutofillField::FindShortestSubstringMatchInSelect(
320 l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_MASTERCARD), 320 l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_MASTERCARD),
321 true, field) >= 0); 321 true, field) >= 0);
322 return isSelect; 322 return isSelect;
323 } 323 }
324 324
325 // static 325 // static
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 : ((expiration_year_ && expiration_year_->max_length == 2) 507 : ((expiration_year_ && expiration_year_->max_length == 2)
508 ? CREDIT_CARD_EXP_2_DIGIT_YEAR 508 ? CREDIT_CARD_EXP_2_DIGIT_YEAR
509 : CREDIT_CARD_EXP_4_DIGIT_YEAR)); 509 : CREDIT_CARD_EXP_4_DIGIT_YEAR));
510 } 510 }
511 511
512 bool CreditCardField::HasExpiration() const { 512 bool CreditCardField::HasExpiration() const {
513 return expiration_date_ || (expiration_month_ && expiration_year_); 513 return expiration_date_ || (expiration_month_ && expiration_year_);
514 } 514 }
515 515
516 } // namespace autofill 516 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/credit_card.cc ('k') | components/autofill/core/browser/credit_card_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698