Index: components/autofill/core/browser/autofill_manager.cc |
diff --git a/components/autofill/core/browser/autofill_manager.cc b/components/autofill/core/browser/autofill_manager.cc |
index 48cd5974c206b50c064630dace3cb85731b24497..7aceb1d0fe7f97c04a41f2c97c862f387e6ea458 100644 |
--- a/components/autofill/core/browser/autofill_manager.cc |
+++ b/components/autofill/core/browser/autofill_manager.cc |
@@ -156,6 +156,48 @@ void DeterminePossibleFieldTypesForUpload( |
} |
} |
+// Helper function to get the suggetions for |user_input| matching to |
+// |card_number_filed| split. |
+void GetCredtCardSuggetionsForNumberSplit( |
+ const base::string16& user_input, |
+ const AutofillField& card_number_filed, |
+ PersonalDataManager* personal_data, |
+ std::vector<base::string16>* values, |
+ std::vector<base::string16>* labels, |
+ std::vector<base::string16>* icons, |
+ std::vector<GUIDPair>* guid_pairs) { |
+ const std::vector<CreditCard*>& credit_cards = |
+ personal_data->GetCreditCards(); |
+ for (std::vector<CreditCard*>::const_iterator iter = credit_cards.begin(); |
+ iter != credit_cards.end(); |
+ ++iter) { |
+ CreditCard* credit_card = *iter; |
+ base::string16 stored_card_number = |
+ CreditCard::StripSeparators(credit_card->number()); |
+ |
+ // Exclude first split, as it would have already included in the |
+ // suggestions. |
+ if (!stored_card_number.empty() && |
+ !StartsWith(stored_card_number, user_input, false)) { |
+ |
+ // Make sure the suggetions get include for rest of the |
+ // |card_number_filed|s. |
+ stored_card_number = AutofillField::GetCreditCardNumberValue( |
+ card_number_filed, stored_card_number); |
+ if (StartsWith(stored_card_number, user_input, false)) { |
+ personal_data->AppendCreditCardSuggetions( |
+ credit_card, |
+ AutofillType(CREDIT_CARD_NUMBER), |
+ user_input, |
+ values, |
+ labels, |
+ icons, |
+ guid_pairs); |
+ } |
+ } |
+ } |
+} |
Ilya Sherman
2014/10/07 21:49:10
Can all of this logic be moved into the PersonalDa
Pritam Nikam
2014/10/08 05:17:17
In my opinion, we *cannot* move this logic to Pers
Ilya Sherman
2014/10/08 21:04:38
Phone numbers are also handled within the Personal
Pritam Nikam
2014/10/09 06:11:11
Acknowledged.
I'll align my changes along these l
Ilya Sherman
2014/10/09 21:35:12
That's true. It's such an edge case that I'm hone
Pritam Nikam
2014/10/13 04:33:52
Currently, *current field value* (i.e. const base:
|
+ |
} // namespace |
AutofillManager::AutofillManager( |
@@ -473,7 +515,7 @@ void AutofillManager::OnQueryFormFieldAutofill(int query_id, |
bool is_filling_credit_card = (type.group() == CREDIT_CARD); |
if (is_filling_credit_card) { |
GetCreditCardSuggestions( |
- field, type, &values, &labels, &icons, &unique_ids); |
+ field, *autofill_field, &values, &labels, &icons, &unique_ids); |
} else { |
GetProfileSuggestions(*form_structure, |
field, |
@@ -1117,15 +1159,27 @@ void AutofillManager::GetProfileSuggestions( |
void AutofillManager::GetCreditCardSuggestions( |
const FormFieldData& field, |
- const AutofillType& type, |
+ const AutofillField& autofill_field, |
std::vector<base::string16>* values, |
std::vector<base::string16>* labels, |
std::vector<base::string16>* icons, |
std::vector<int>* unique_ids) const { |
std::vector<GUIDPair> guid_pairs; |
+ AutofillType type = autofill_field.Type(); |
personal_data_->GetCreditCardSuggestions( |
type, field.value, values, labels, icons, &guid_pairs); |
+ // Populate suggetions for number split case (http://crbug.com/420323). |
+ if (!field.value.empty() && |
+ autofill_field.Type().GetStorableType() == CREDIT_CARD_NUMBER) |
+ GetCredtCardSuggetionsForNumberSplit(field.value, |
+ autofill_field, |
+ personal_data_, |
+ values, |
+ labels, |
+ icons, |
+ &guid_pairs); |
Ilya Sherman
2014/10/07 21:49:10
nit: Please add curly braces, since the body spans
Pritam Nikam
2014/10/08 05:17:17
Done.
|
+ |
for (size_t i = 0; i < guid_pairs.size(); ++i) { |
unique_ids->push_back(PackGUIDs(guid_pairs[i], GUIDPair(std::string(), 0))); |
} |