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/core/browser/credit_card.h" | 5 #include "components/autofill/core/browser/credit_card.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <ostream> | 10 #include <ostream> |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
404 if (!card_number.empty() && StripSeparators(text) == card_number) | 404 if (!card_number.empty() && StripSeparators(text) == card_number) |
405 matching_types->insert(CREDIT_CARD_NUMBER); | 405 matching_types->insert(CREDIT_CARD_NUMBER); |
406 | 406 |
407 int month; | 407 int month; |
408 if (ConvertMonth(text, app_locale, &month) && month != 0 && | 408 if (ConvertMonth(text, app_locale, &month) && month != 0 && |
409 month == expiration_month_) { | 409 month == expiration_month_) { |
410 matching_types->insert(CREDIT_CARD_EXP_MONTH); | 410 matching_types->insert(CREDIT_CARD_EXP_MONTH); |
411 } | 411 } |
412 } | 412 } |
413 | 413 |
414 const base::string16 CreditCard::Label() const { | 414 const base::string16& CreditCard::Label() const { |
415 base::string16 label; | 415 base::string16 label; |
416 if (number().empty()) | 416 if (number().empty()) |
417 return name_on_card_; // No CC number, return name only. | 417 return name_on_card_; // No CC number, return name only. |
418 | 418 |
419 base::string16 obfuscated_cc_number = ObfuscatedNumber(); | 419 base::string16 obfuscated_cc_number = ObfuscatedNumber(); |
420 if (!expiration_month_ || !expiration_year_) | 420 if (!expiration_month_ || !expiration_year_) |
421 return obfuscated_cc_number; // No expiration date set. | 421 return obfuscated_cc_number; // No expiration date set. |
422 | 422 |
423 // TODO(georgey): Internationalize date. | 423 // TODO(georgey): Internationalize date. |
424 base::string16 formatted_date(ExpirationMonthAsString()); | 424 base::string16 formatted_date(ExpirationMonthAsString()); |
425 formatted_date.append(base::ASCIIToUTF16("/")); | 425 formatted_date.append(base::ASCIIToUTF16("/")); |
426 formatted_date.append(Expiration4DigitYearAsString()); | 426 formatted_date.append(Expiration4DigitYearAsString()); |
427 | 427 |
428 label = l10n_util::GetStringFUTF16(IDS_CREDIT_CARD_NUMBER_PREVIEW_FORMAT, | 428 label = l10n_util::GetStringFUTF16(IDS_CREDIT_CARD_NUMBER_PREVIEW_FORMAT, |
429 obfuscated_cc_number, | 429 obfuscated_cc_number, |
430 formatted_date); | 430 formatted_date); |
431 return label; | 431 return label; |
vabr (Chromium)
2014/07/11 13:37:43
And here as well, the returned object is local, so
| |
432 } | 432 } |
433 | 433 |
434 void CreditCard::SetInfoForMonthInputType(const base::string16& value) { | 434 void CreditCard::SetInfoForMonthInputType(const base::string16& value) { |
435 // Check if |text| is "yyyy-mm" format first, and check normal month format. | 435 // Check if |text| is "yyyy-mm" format first, and check normal month format. |
436 if (!autofill::MatchesPattern(value, | 436 if (!autofill::MatchesPattern(value, |
437 base::UTF8ToUTF16("^[0-9]{4}-[0-9]{1,2}$"))) { | 437 base::UTF8ToUTF16("^[0-9]{4}-[0-9]{1,2}$"))) { |
438 return; | 438 return; |
439 } | 439 } |
440 | 440 |
441 std::vector<base::string16> year_month; | 441 std::vector<base::string16> year_month; |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
685 const char* const kAmericanExpressCard = "americanExpressCC"; | 685 const char* const kAmericanExpressCard = "americanExpressCC"; |
686 const char* const kDinersCard = "dinersCC"; | 686 const char* const kDinersCard = "dinersCC"; |
687 const char* const kDiscoverCard = "discoverCC"; | 687 const char* const kDiscoverCard = "discoverCC"; |
688 const char* const kGenericCard = "genericCC"; | 688 const char* const kGenericCard = "genericCC"; |
689 const char* const kJCBCard = "jcbCC"; | 689 const char* const kJCBCard = "jcbCC"; |
690 const char* const kMasterCard = "masterCardCC"; | 690 const char* const kMasterCard = "masterCardCC"; |
691 const char* const kUnionPay = "unionPayCC"; | 691 const char* const kUnionPay = "unionPayCC"; |
692 const char* const kVisaCard = "visaCC"; | 692 const char* const kVisaCard = "visaCC"; |
693 | 693 |
694 } // namespace autofill | 694 } // namespace autofill |
OLD | NEW |