| 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_); |
| 670 |
| 669 if (!creditcard_field_value.empty() && | 671 if (!creditcard_field_value.empty() && |
| 670 StartsWith(creditcard_field_value, field_contents, false)) { | 672 (StartsWith(creditcard_field_value, field_contents, false) || |
| 671 if (type.GetStorableType() == CREDIT_CARD_NUMBER) | 673 (type.GetStorableType() == CREDIT_CARD_NUMBER && |
| 672 creditcard_field_value = credit_card->ObfuscatedNumber(); | 674 base::string16::npos != |
| 673 | 675 creditcard_field_value.find(field_contents)))) { |
| 674 // If the value is the card number, the label is the expiration date. | 676 // 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 | 677 // Otherwise the label is the card number, or if that is empty the |
| 676 // cardholder name. The label should never repeat the value. | 678 // cardholder name. The label should never repeat the value. |
| 677 base::string16 label; | 679 base::string16 label; |
| 678 if (type.GetStorableType() == CREDIT_CARD_NUMBER) { | 680 if (type.GetStorableType() == CREDIT_CARD_NUMBER) { |
| 681 if (obfuscate_number) |
| 682 creditcard_field_value = credit_card->ObfuscatedNumber(); |
| 683 |
| 679 label = credit_card->GetInfo( | 684 label = credit_card->GetInfo( |
| 680 AutofillType(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR), app_locale_); | 685 AutofillType(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR), app_locale_); |
| 681 } else if (credit_card->number().empty()) { | 686 } else if (credit_card->number().empty()) { |
| 682 if (type.GetStorableType() != CREDIT_CARD_NAME) { | 687 if (type.GetStorableType() != CREDIT_CARD_NAME) { |
| 683 label = | 688 label = |
| 684 credit_card->GetInfo(AutofillType(CREDIT_CARD_NAME), app_locale_); | 689 credit_card->GetInfo(AutofillType(CREDIT_CARD_NAME), app_locale_); |
| 685 } | 690 } |
| 686 } else { | 691 } else { |
| 687 label = kCreditCardPrefix; | 692 label = kCreditCardPrefix; |
| 688 label.append(credit_card->LastFourDigits()); | 693 label.append(credit_card->LastFourDigits()); |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1110 // Populates |auxiliary_profiles_|. | 1115 // Populates |auxiliary_profiles_|. |
| 1111 LoadAuxiliaryProfiles(record_metrics); | 1116 LoadAuxiliaryProfiles(record_metrics); |
| 1112 | 1117 |
| 1113 profiles_.insert(profiles_.end(), web_profiles_.begin(), web_profiles_.end()); | 1118 profiles_.insert(profiles_.end(), web_profiles_.begin(), web_profiles_.end()); |
| 1114 profiles_.insert( | 1119 profiles_.insert( |
| 1115 profiles_.end(), auxiliary_profiles_.begin(), auxiliary_profiles_.end()); | 1120 profiles_.end(), auxiliary_profiles_.begin(), auxiliary_profiles_.end()); |
| 1116 return profiles_; | 1121 return profiles_; |
| 1117 } | 1122 } |
| 1118 | 1123 |
| 1119 } // namespace autofill | 1124 } // namespace autofill |
| OLD | NEW |