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

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

Issue 447903003: Autofill: improve GetCreditCardSuggestions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ah so there were tests after all Created 6 years, 4 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 | Annotate | Revision Log
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/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 653 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 CreditCard* credit_card = *iter; 664 CreditCard* credit_card = *iter;
665 665
666 // The value of the stored data for this field type in the |credit_card|. 666 // The value of the stored data for this field type in the |credit_card|.
667 base::string16 creditcard_field_value = 667 base::string16 creditcard_field_value =
668 credit_card->GetInfo(type, app_locale_); 668 credit_card->GetInfo(type, app_locale_);
669 if (!creditcard_field_value.empty() && 669 if (!creditcard_field_value.empty() &&
670 StartsWith(creditcard_field_value, field_contents, false)) { 670 StartsWith(creditcard_field_value, field_contents, false)) {
671 if (type.GetStorableType() == CREDIT_CARD_NUMBER) 671 if (type.GetStorableType() == CREDIT_CARD_NUMBER)
672 creditcard_field_value = credit_card->ObfuscatedNumber(); 672 creditcard_field_value = credit_card->ObfuscatedNumber();
673 673
674 // 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
676 // cardholder name. The label should never repeat the value.
674 base::string16 label; 677 base::string16 label;
675 if (credit_card->number().empty()) { 678 if (type.GetStorableType() == CREDIT_CARD_NUMBER) {
676 // If there is no CC number, return name to show something. 679 label = credit_card->GetInfo(
677 label = 680 AutofillType(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR), app_locale_);
678 credit_card->GetInfo(AutofillType(CREDIT_CARD_NAME), app_locale_); 681 } else if (credit_card->number().empty()) {
682 if (type.GetStorableType() != CREDIT_CARD_NAME) {
683 label =
684 credit_card->GetInfo(AutofillType(CREDIT_CARD_NAME), app_locale_);
685 }
679 } else { 686 } else {
680 label = kCreditCardPrefix; 687 label = kCreditCardPrefix;
681 label.append(credit_card->LastFourDigits()); 688 label.append(credit_card->LastFourDigits());
682 } 689 }
683 690
684 values->push_back(creditcard_field_value); 691 values->push_back(creditcard_field_value);
685 labels->push_back(label); 692 labels->push_back(label);
686 icons->push_back(base::UTF8ToUTF16(credit_card->type())); 693 icons->push_back(base::UTF8ToUTF16(credit_card->type()));
687 guid_pairs->push_back(GUIDPair(credit_card->guid(), 0)); 694 guid_pairs->push_back(GUIDPair(credit_card->guid(), 0));
688 } 695 }
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
1102 // Populates |auxiliary_profiles_|. 1109 // Populates |auxiliary_profiles_|.
1103 LoadAuxiliaryProfiles(record_metrics); 1110 LoadAuxiliaryProfiles(record_metrics);
1104 1111
1105 profiles_.insert(profiles_.end(), web_profiles_.begin(), web_profiles_.end()); 1112 profiles_.insert(profiles_.end(), web_profiles_.begin(), web_profiles_.end());
1106 profiles_.insert( 1113 profiles_.insert(
1107 profiles_.end(), auxiliary_profiles_.begin(), auxiliary_profiles_.end()); 1114 profiles_.end(), auxiliary_profiles_.begin(), auxiliary_profiles_.end());
1108 return profiles_; 1115 return profiles_;
1109 } 1116 }
1110 1117
1111 } // namespace autofill 1118 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698