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 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 1642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1653 std::vector<FormStructure*> forms(1, *updated_form); | 1653 std::vector<FormStructure*> forms(1, *updated_form); |
1654 driver_->SendAutofillTypePredictionsToRenderer(forms); | 1654 driver_->SendAutofillTypePredictionsToRenderer(forms); |
1655 | 1655 |
1656 return true; | 1656 return true; |
1657 } | 1657 } |
1658 | 1658 |
1659 std::vector<Suggestion> AutofillManager::GetProfileSuggestions( | 1659 std::vector<Suggestion> AutofillManager::GetProfileSuggestions( |
1660 const FormStructure& form, | 1660 const FormStructure& form, |
1661 const FormFieldData& field, | 1661 const FormFieldData& field, |
1662 const AutofillField& autofill_field) const { | 1662 const AutofillField& autofill_field) const { |
1663 address_form_event_logger_->OnDidPollSuggestions(); | 1663 address_form_event_logger_->OnDidPollSuggestions(field); |
1664 | 1664 |
1665 std::vector<ServerFieldType> field_types(form.field_count()); | 1665 std::vector<ServerFieldType> field_types(form.field_count()); |
1666 for (size_t i = 0; i < form.field_count(); ++i) { | 1666 for (size_t i = 0; i < form.field_count(); ++i) { |
1667 field_types.push_back(form.field(i)->Type().GetStorableType()); | 1667 field_types.push_back(form.field(i)->Type().GetStorableType()); |
1668 } | 1668 } |
1669 | 1669 |
1670 std::vector<Suggestion> suggestions = personal_data_->GetProfileSuggestions( | 1670 std::vector<Suggestion> suggestions = personal_data_->GetProfileSuggestions( |
1671 autofill_field.Type(), field.value, field.is_autofilled, field_types); | 1671 autofill_field.Type(), field.value, field.is_autofilled, field_types); |
1672 | 1672 |
1673 // Adjust phone number to display in prefix/suffix case. | 1673 // Adjust phone number to display in prefix/suffix case. |
1674 if (autofill_field.Type().GetStorableType() == PHONE_HOME_NUMBER) { | 1674 if (autofill_field.Type().GetStorableType() == PHONE_HOME_NUMBER) { |
1675 for (size_t i = 0; i < suggestions.size(); ++i) { | 1675 for (size_t i = 0; i < suggestions.size(); ++i) { |
1676 suggestions[i].value = AutofillField::GetPhoneNumberValue( | 1676 suggestions[i].value = AutofillField::GetPhoneNumberValue( |
1677 autofill_field, suggestions[i].value, field); | 1677 autofill_field, suggestions[i].value, field); |
1678 } | 1678 } |
1679 } | 1679 } |
1680 | 1680 |
1681 for (size_t i = 0; i < suggestions.size(); ++i) { | 1681 for (size_t i = 0; i < suggestions.size(); ++i) { |
1682 suggestions[i].frontend_id = | 1682 suggestions[i].frontend_id = |
1683 MakeFrontendID(std::string(), suggestions[i].backend_id); | 1683 MakeFrontendID(std::string(), suggestions[i].backend_id); |
1684 } | 1684 } |
1685 return suggestions; | 1685 return suggestions; |
1686 } | 1686 } |
1687 | 1687 |
1688 std::vector<Suggestion> AutofillManager::GetCreditCardSuggestions( | 1688 std::vector<Suggestion> AutofillManager::GetCreditCardSuggestions( |
1689 const FormFieldData& field, | 1689 const FormFieldData& field, |
1690 const AutofillType& type) const { | 1690 const AutofillType& type) const { |
1691 credit_card_form_event_logger_->OnDidPollSuggestions(); | 1691 credit_card_form_event_logger_->OnDidPollSuggestions(field); |
1692 | 1692 |
1693 // The field value is sanitized before attempting to match it to the user's | 1693 // The field value is sanitized before attempting to match it to the user's |
1694 // data. | 1694 // data. |
1695 std::vector<Suggestion> suggestions = | 1695 std::vector<Suggestion> suggestions = |
1696 personal_data_->GetCreditCardSuggestions( | 1696 personal_data_->GetCreditCardSuggestions( |
1697 type, SanitizeCreditCardFieldValue(field.value)); | 1697 type, SanitizeCreditCardFieldValue(field.value)); |
1698 for (size_t i = 0; i < suggestions.size(); i++) { | 1698 for (size_t i = 0; i < suggestions.size(); i++) { |
1699 suggestions[i].frontend_id = | 1699 suggestions[i].frontend_id = |
1700 MakeFrontendID(suggestions[i].backend_id, std::string()); | 1700 MakeFrontendID(suggestions[i].backend_id, std::string()); |
1701 } | 1701 } |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2016 if (i > 0) | 2016 if (i > 0) |
2017 fputs("Next oldest form:\n", file); | 2017 fputs("Next oldest form:\n", file); |
2018 } | 2018 } |
2019 fputs("\n", file); | 2019 fputs("\n", file); |
2020 | 2020 |
2021 fclose(file); | 2021 fclose(file); |
2022 } | 2022 } |
2023 #endif // ENABLE_FORM_DEBUG_DUMP | 2023 #endif // ENABLE_FORM_DEBUG_DUMP |
2024 | 2024 |
2025 } // namespace autofill | 2025 } // namespace autofill |
OLD | NEW |