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/autofill_manager.h" | 5 #include "components/autofill/core/browser/autofill_manager.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <limits> | 9 #include <limits> |
10 #include <map> | 10 #include <map> |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
466 AutofillField* autofill_field = NULL; | 466 AutofillField* autofill_field = NULL; |
467 if (RefreshDataModels() && | 467 if (RefreshDataModels() && |
468 driver_->RendererIsAvailable() && | 468 driver_->RendererIsAvailable() && |
469 GetCachedFormAndField(form, field, &form_structure, &autofill_field) && | 469 GetCachedFormAndField(form, field, &form_structure, &autofill_field) && |
470 // Don't send suggestions for forms that aren't auto-fillable. | 470 // Don't send suggestions for forms that aren't auto-fillable. |
471 form_structure->IsAutofillable()) { | 471 form_structure->IsAutofillable()) { |
472 AutofillType type = autofill_field->Type(); | 472 AutofillType type = autofill_field->Type(); |
473 bool is_filling_credit_card = (type.group() == CREDIT_CARD); | 473 bool is_filling_credit_card = (type.group() == CREDIT_CARD); |
474 if (is_filling_credit_card) { | 474 if (is_filling_credit_card) { |
475 GetCreditCardSuggestions( | 475 GetCreditCardSuggestions( |
476 field, type, &values, &labels, &icons, &unique_ids); | 476 field, *autofill_field, &values, &labels, &icons, &unique_ids); |
477 } else { | 477 } else { |
478 GetProfileSuggestions(*form_structure, | 478 GetProfileSuggestions(*form_structure, |
479 field, | 479 field, |
480 *autofill_field, | 480 *autofill_field, |
481 &values, | 481 &values, |
482 &labels, | 482 &labels, |
483 &icons, | 483 &icons, |
484 &unique_ids); | 484 &unique_ids); |
485 } | 485 } |
486 | 486 |
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1106 std::vector<GUIDPair> guid_pairs; | 1106 std::vector<GUIDPair> guid_pairs; |
1107 | 1107 |
1108 personal_data_->GetProfileSuggestions( | 1108 personal_data_->GetProfileSuggestions( |
1109 autofill_field.Type(), field.value, field.is_autofilled, field_types, | 1109 autofill_field.Type(), field.value, field.is_autofilled, field_types, |
1110 base::Callback<bool(const AutofillProfile&)>(), | 1110 base::Callback<bool(const AutofillProfile&)>(), |
1111 values, labels, icons, &guid_pairs); | 1111 values, labels, icons, &guid_pairs); |
1112 | 1112 |
1113 // Adjust phone number to display in prefix/suffix case. | 1113 // Adjust phone number to display in prefix/suffix case. |
1114 if (autofill_field.Type().GetStorableType() == PHONE_HOME_NUMBER) { | 1114 if (autofill_field.Type().GetStorableType() == PHONE_HOME_NUMBER) { |
1115 for (size_t i = 0; i < values->size(); ++i) { | 1115 for (size_t i = 0; i < values->size(); ++i) { |
1116 (*values)[i] = AutofillField::GetPhoneNumberValue( | 1116 (*values)[i] = |
1117 autofill_field, (*values)[i], field); | 1117 AutofillField::GetPhoneNumberValue(autofill_field, (*values)[i]); |
1118 } | 1118 } |
1119 } | 1119 } |
1120 | 1120 |
1121 for (size_t i = 0; i < guid_pairs.size(); ++i) { | 1121 for (size_t i = 0; i < guid_pairs.size(); ++i) { |
1122 unique_ids->push_back(PackGUIDs(GUIDPair(std::string(), 0), | 1122 unique_ids->push_back(PackGUIDs(GUIDPair(std::string(), 0), |
1123 guid_pairs[i])); | 1123 guid_pairs[i])); |
1124 } | 1124 } |
1125 } | 1125 } |
1126 | 1126 |
1127 void AutofillManager::GetCreditCardSuggestions( | 1127 void AutofillManager::GetCreditCardSuggestions( |
1128 const FormFieldData& field, | 1128 const FormFieldData& field, |
1129 const AutofillType& type, | 1129 const AutofillField& autofill_field, |
Ilya Sherman
2014/10/28 21:48:40
It looks like you can revert this change, since yo
Pritam Nikam
2014/10/29 08:38:16
Done.
| |
1130 std::vector<base::string16>* values, | 1130 std::vector<base::string16>* values, |
1131 std::vector<base::string16>* labels, | 1131 std::vector<base::string16>* labels, |
1132 std::vector<base::string16>* icons, | 1132 std::vector<base::string16>* icons, |
1133 std::vector<int>* unique_ids) const { | 1133 std::vector<int>* unique_ids) const { |
1134 std::vector<GUIDPair> guid_pairs; | 1134 std::vector<GUIDPair> guid_pairs; |
1135 AutofillType type = autofill_field.Type(); | |
1135 personal_data_->GetCreditCardSuggestions( | 1136 personal_data_->GetCreditCardSuggestions( |
1136 type, field.value, values, labels, icons, &guid_pairs); | 1137 type, field.value, values, labels, icons, &guid_pairs); |
1137 | 1138 |
1138 for (size_t i = 0; i < guid_pairs.size(); ++i) { | 1139 for (size_t i = 0; i < guid_pairs.size(); ++i) { |
1139 unique_ids->push_back(PackGUIDs(guid_pairs[i], GUIDPair(std::string(), 0))); | 1140 unique_ids->push_back(PackGUIDs(guid_pairs[i], GUIDPair(std::string(), 0))); |
1140 } | 1141 } |
1141 } | 1142 } |
1142 | 1143 |
1143 void AutofillManager::ParseForms(const std::vector<FormData>& forms) { | 1144 void AutofillManager::ParseForms(const std::vector<FormData>& forms) { |
1144 std::vector<FormStructure*> non_queryable_forms; | 1145 std::vector<FormStructure*> non_queryable_forms; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1251 return false; | 1252 return false; |
1252 | 1253 |
1253 // Disregard forms that we wouldn't ever autofill in the first place. | 1254 // Disregard forms that we wouldn't ever autofill in the first place. |
1254 if (!form.ShouldBeParsed()) | 1255 if (!form.ShouldBeParsed()) |
1255 return false; | 1256 return false; |
1256 | 1257 |
1257 return true; | 1258 return true; |
1258 } | 1259 } |
1259 | 1260 |
1260 } // namespace autofill | 1261 } // namespace autofill |
OLD | NEW |