| 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 <algorithm> | 9 #include <algorithm> |
| 10 #include <limits> | 10 #include <limits> |
| (...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 736 const std::vector<base::string16>& labels) { | 736 const std::vector<base::string16>& labels) { |
| 737 if (!IsValidString16Vector(values) || | 737 if (!IsValidString16Vector(values) || |
| 738 !IsValidString16Vector(labels) || | 738 !IsValidString16Vector(labels) || |
| 739 values.size() != labels.size()) | 739 values.size() != labels.size()) |
| 740 return; | 740 return; |
| 741 | 741 |
| 742 external_delegate_->SetCurrentDataListValues(values, labels); | 742 external_delegate_->SetCurrentDataListValues(values, labels); |
| 743 } | 743 } |
| 744 | 744 |
| 745 void AutofillManager::OnLoadedServerPredictions( | 745 void AutofillManager::OnLoadedServerPredictions( |
| 746 const std::string& response_xml, | 746 std::string response_xml, |
| 747 const std::vector<std::string>& form_signatures) { | 747 const std::vector<std::string>& form_signatures) { |
| 748 // We obtain the current valid FormStructures represented by | 748 // We obtain the current valid FormStructures represented by |
| 749 // |form_signatures|. We invert both lists because most recent forms are at | 749 // |form_signatures|. We invert both lists because most recent forms are at |
| 750 // the end of the list (and reverse the resulting pointer vector). | 750 // the end of the list (and reverse the resulting pointer vector). |
| 751 std::vector<FormStructure*> queried_forms; | 751 std::vector<FormStructure*> queried_forms; |
| 752 for (const std::string& signature : base::Reversed(form_signatures)) { | 752 for (const std::string& signature : base::Reversed(form_signatures)) { |
| 753 for (FormStructure* cur_form : base::Reversed(form_structures_)) { | 753 for (FormStructure* cur_form : base::Reversed(form_structures_)) { |
| 754 if (cur_form->FormSignature() == signature) { | 754 if (cur_form->FormSignature() == signature) { |
| 755 queried_forms.push_back(cur_form); | 755 queried_forms.push_back(cur_form); |
| 756 break; | 756 break; |
| 757 } | 757 } |
| 758 } | 758 } |
| 759 } | 759 } |
| 760 std::reverse(queried_forms.begin(), queried_forms.end()); | 760 std::reverse(queried_forms.begin(), queried_forms.end()); |
| 761 | 761 |
| 762 // If there are no current forms corresponding to the queried signatures, drop | 762 // If there are no current forms corresponding to the queried signatures, drop |
| 763 // the query response. | 763 // the query response. |
| 764 if (queried_forms.empty()) | 764 if (queried_forms.empty()) |
| 765 return; | 765 return; |
| 766 | 766 |
| 767 // Parse and store the server predictions. | 767 // Parse and store the server predictions. |
| 768 FormStructure::ParseQueryResponse(response_xml, queried_forms, | 768 FormStructure::ParseQueryResponse(std::move(response_xml), queried_forms, |
| 769 client_->GetRapporService()); | 769 client_->GetRapporService()); |
| 770 | 770 |
| 771 // Forward form structures to the password generation manager to detect | 771 // Forward form structures to the password generation manager to detect |
| 772 // account creation forms. | 772 // account creation forms. |
| 773 driver_->PropagateAutofillPredictions(queried_forms); | 773 driver_->PropagateAutofillPredictions(queried_forms); |
| 774 | 774 |
| 775 // If the corresponding flag is set, annotate forms with the predicted types. | 775 // If the corresponding flag is set, annotate forms with the predicted types. |
| 776 driver_->SendAutofillTypePredictionsToRenderer(queried_forms); | 776 driver_->SendAutofillTypePredictionsToRenderer(queried_forms); |
| 777 } | 777 } |
| 778 | 778 |
| (...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1631 if (i > 0) | 1631 if (i > 0) |
| 1632 fputs("Next oldest form:\n", file); | 1632 fputs("Next oldest form:\n", file); |
| 1633 } | 1633 } |
| 1634 fputs("\n", file); | 1634 fputs("\n", file); |
| 1635 | 1635 |
| 1636 fclose(file); | 1636 fclose(file); |
| 1637 } | 1637 } |
| 1638 #endif // ENABLE_FORM_DEBUG_DUMP | 1638 #endif // ENABLE_FORM_DEBUG_DUMP |
| 1639 | 1639 |
| 1640 } // namespace autofill | 1640 } // namespace autofill |
| OLD | NEW |