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/personal_data_manager.h" | 5 #include "components/autofill/core/browser/personal_data_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 #include <iterator> | 9 #include <iterator> |
10 | 10 |
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
645 // No icons for profile suggestions. | 645 // No icons for profile suggestions. |
646 icons->resize(values->size()); | 646 icons->resize(values->size()); |
647 } | 647 } |
648 | 648 |
649 void PersonalDataManager::GetCreditCardSuggestions( | 649 void PersonalDataManager::GetCreditCardSuggestions( |
650 const AutofillType& type, | 650 const AutofillType& type, |
651 const base::string16& field_contents, | 651 const base::string16& field_contents, |
652 std::vector<base::string16>* values, | 652 std::vector<base::string16>* values, |
653 std::vector<base::string16>* labels, | 653 std::vector<base::string16>* labels, |
654 std::vector<base::string16>* icons, | 654 std::vector<base::string16>* icons, |
655 std::vector<GUIDPair>* guid_pairs) { | 655 std::vector<GUIDPair>* guid_pairs, |
656 bool obfuscate_number) { | |
656 values->clear(); | 657 values->clear(); |
657 labels->clear(); | 658 labels->clear(); |
658 icons->clear(); | 659 icons->clear(); |
659 guid_pairs->clear(); | 660 guid_pairs->clear(); |
660 | 661 |
661 const std::vector<CreditCard*>& credit_cards = GetCreditCards(); | 662 const std::vector<CreditCard*>& credit_cards = GetCreditCards(); |
662 for (std::vector<CreditCard*>::const_iterator iter = credit_cards.begin(); | 663 for (std::vector<CreditCard*>::const_iterator iter = credit_cards.begin(); |
663 iter != credit_cards.end(); ++iter) { | 664 iter != credit_cards.end(); ++iter) { |
664 CreditCard* credit_card = *iter; | 665 CreditCard* credit_card = *iter; |
665 | 666 |
666 // The value of the stored data for this field type in the |credit_card|. | 667 // The value of the stored data for this field type in the |credit_card|. |
667 base::string16 creditcard_field_value = | 668 base::string16 creditcard_field_value = |
668 credit_card->GetInfo(type, app_locale_); | 669 credit_card->GetInfo(type, app_locale_); |
669 if (!creditcard_field_value.empty() && | |
670 StartsWith(creditcard_field_value, field_contents, false)) { | |
671 if (type.GetStorableType() == CREDIT_CARD_NUMBER) | |
672 creditcard_field_value = credit_card->ObfuscatedNumber(); | |
673 | 670 |
671 bool match_found = !creditcard_field_value.empty(); | |
672 if (match_found && (type.GetStorableType() == CREDIT_CARD_NUMBER)) { | |
673 match_found = | |
674 (base::string16::npos != creditcard_field_value.find(field_contents)); | |
675 } else if (match_found) { | |
676 match_found = StartsWith(creditcard_field_value, field_contents, false); | |
677 } | |
678 | |
679 if (match_found) { | |
Ilya Sherman
2014/10/13 23:33:37
nit: Please write this more like how it was previo
Pritam Nikam
2014/10/15 09:12:11
Done.
| |
674 // If the value is the card number, the label is the expiration date. | 680 // If the value is the card number, the label is the expiration date. |
675 // Otherwise the label is the card number, or if that is empty the | 681 // Otherwise the label is the card number, or if that is empty the |
676 // cardholder name. The label should never repeat the value. | 682 // cardholder name. The label should never repeat the value. |
677 base::string16 label; | 683 base::string16 label; |
678 if (type.GetStorableType() == CREDIT_CARD_NUMBER) { | 684 if (type.GetStorableType() == CREDIT_CARD_NUMBER) { |
685 if (obfuscate_number) | |
686 creditcard_field_value = credit_card->ObfuscatedNumber(); | |
687 | |
679 label = credit_card->GetInfo( | 688 label = credit_card->GetInfo( |
680 AutofillType(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR), app_locale_); | 689 AutofillType(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR), app_locale_); |
681 } else if (credit_card->number().empty()) { | 690 } else if (credit_card->number().empty()) { |
682 if (type.GetStorableType() != CREDIT_CARD_NAME) { | 691 if (type.GetStorableType() != CREDIT_CARD_NAME) { |
683 label = | 692 label = |
684 credit_card->GetInfo(AutofillType(CREDIT_CARD_NAME), app_locale_); | 693 credit_card->GetInfo(AutofillType(CREDIT_CARD_NAME), app_locale_); |
685 } | 694 } |
686 } else { | 695 } else { |
687 label = kCreditCardPrefix; | 696 label = kCreditCardPrefix; |
688 label.append(credit_card->LastFourDigits()); | 697 label.append(credit_card->LastFourDigits()); |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1110 // Populates |auxiliary_profiles_|. | 1119 // Populates |auxiliary_profiles_|. |
1111 LoadAuxiliaryProfiles(record_metrics); | 1120 LoadAuxiliaryProfiles(record_metrics); |
1112 | 1121 |
1113 profiles_.insert(profiles_.end(), web_profiles_.begin(), web_profiles_.end()); | 1122 profiles_.insert(profiles_.end(), web_profiles_.begin(), web_profiles_.end()); |
1114 profiles_.insert( | 1123 profiles_.insert( |
1115 profiles_.end(), auxiliary_profiles_.begin(), auxiliary_profiles_.end()); | 1124 profiles_.end(), auxiliary_profiles_.begin(), auxiliary_profiles_.end()); |
1116 return profiles_; | 1125 return profiles_; |
1117 } | 1126 } |
1118 | 1127 |
1119 } // namespace autofill | 1128 } // namespace autofill |
OLD | NEW |