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

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

Issue 1540423004: Add card details and legal message to Android save credit card infobar. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Initial draft Created 4 years, 11 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.h" 5 #include "components/autofill/core/browser/credit_card.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 base::string16 CreditCard::LastFourDigits() const { 479 base::string16 CreditCard::LastFourDigits() const {
480 static const size_t kNumLastDigits = 4; 480 static const size_t kNumLastDigits = 4;
481 481
482 base::string16 number = StripSeparators(number_); 482 base::string16 number = StripSeparators(number_);
483 if (number.size() <= kNumLastDigits) 483 if (number.size() <= kNumLastDigits)
484 return number; 484 return number;
485 485
486 return number.substr(number.size() - kNumLastDigits, kNumLastDigits); 486 return number.substr(number.size() - kNumLastDigits, kNumLastDigits);
487 } 487 }
488 488
489 base::string16 CreditCard::LastFourDigitsForDisplay() const {
490 base::string16 digits = LastFourDigits();
491 // Prepend the midline horizontal ellipsis (U+22EF).
492 // TODO(estade): i18n?
493 return digits.empty() ? base::string16()
494 : base::UTF8ToUTF16("\xE2\x8B\xAF") + digits;
495 }
496
489 base::string16 CreditCard::TypeForDisplay() const { 497 base::string16 CreditCard::TypeForDisplay() const {
490 return CreditCard::TypeForDisplay(type_); 498 return CreditCard::TypeForDisplay(type_);
491 } 499 }
492 500
493 base::string16 CreditCard::TypeAndLastFourDigits() const { 501 base::string16 CreditCard::TypeAndLastFourDigits() const {
Justin Donnelly 2015/12/30 18:06:37 Change to TypeAndLastFourDigitsForDisplay for cons
please use gerrit instead 2016/01/07 01:39:25 Done.
494 base::string16 type = TypeForDisplay(); 502 base::string16 type = TypeForDisplay();
495 503
496 base::string16 digits = LastFourDigits(); 504 base::string16 digits = LastFourDigitsForDisplay();
497 if (digits.empty()) 505 if (digits.empty())
498 return type; 506 return type;
499 507
500 // The separator character is a non breaking space and a horizontal midline 508 // The separator character is a non breaking space.
501 // ellipsis. 509 return type + base::UTF8ToUTF16("\xC2\xA0") + digits;
502 // TODO(estade): i18n? 510 }
503 return type + base::UTF8ToUTF16("\xC2\xA0\xE2\x8B\xAF") + digits; 511
512 base::string16 CreditCard::AbbreviatedExpirationDateForDisplay() const {
513 base::string16 month = ExpirationMonthAsString();
514 base::string16 year = Expiration2DigitYearAsString();
515 return month.empty() || year.empty()
516 ? base::string16()
517 : l10n_util::GetStringFUTF16(
518 IDS_AUTOFILL_CREDIT_CARD_EXPIRATION_DATE_ABBR, month, year);
504 } 519 }
505 520
506 void CreditCard::operator=(const CreditCard& credit_card) { 521 void CreditCard::operator=(const CreditCard& credit_card) {
507 set_use_count(credit_card.use_count()); 522 set_use_count(credit_card.use_count());
508 set_use_date(credit_card.use_date()); 523 set_use_date(credit_card.use_date());
509 set_modification_date(credit_card.modification_date()); 524 set_modification_date(credit_card.modification_date());
510 525
511 if (this == &credit_card) 526 if (this == &credit_card)
512 return; 527 return;
513 528
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 const char kAmericanExpressCard[] = "americanExpressCC"; 805 const char kAmericanExpressCard[] = "americanExpressCC";
791 const char kDinersCard[] = "dinersCC"; 806 const char kDinersCard[] = "dinersCC";
792 const char kDiscoverCard[] = "discoverCC"; 807 const char kDiscoverCard[] = "discoverCC";
793 const char kGenericCard[] = "genericCC"; 808 const char kGenericCard[] = "genericCC";
794 const char kJCBCard[] = "jcbCC"; 809 const char kJCBCard[] = "jcbCC";
795 const char kMasterCard[] = "masterCardCC"; 810 const char kMasterCard[] = "masterCardCC";
796 const char kUnionPay[] = "unionPayCC"; 811 const char kUnionPay[] = "unionPayCC";
797 const char kVisaCard[] = "visaCC"; 812 const char kVisaCard[] = "visaCC";
798 813
799 } // namespace autofill 814 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698