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