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 <limits> | 10 #include <limits> |
10 #include <map> | 11 #include <map> |
11 #include <set> | 12 #include <set> |
12 #include <utility> | 13 #include <utility> |
13 | 14 |
14 #include "base/bind.h" | 15 #include "base/bind.h" |
15 #include "base/command_line.h" | 16 #include "base/command_line.h" |
16 #include "base/containers/adapters.h" | 17 #include "base/containers/adapters.h" |
17 #include "base/files/file_util.h" | 18 #include "base/files/file_util.h" |
18 #include "base/guid.h" | 19 #include "base/guid.h" |
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
738 return; | 739 return; |
739 | 740 |
740 external_delegate_->SetCurrentDataListValues(values, labels); | 741 external_delegate_->SetCurrentDataListValues(values, labels); |
741 } | 742 } |
742 | 743 |
743 void AutofillManager::OnLoadedServerPredictions( | 744 void AutofillManager::OnLoadedServerPredictions( |
744 const std::string& response_xml, | 745 const std::string& response_xml, |
745 const std::vector<std::string>& form_signatures) { | 746 const std::vector<std::string>& form_signatures) { |
746 // We obtain the current valid FormStructures represented by | 747 // We obtain the current valid FormStructures represented by |
747 // |form_signatures|. We invert both lists because most recent forms are at | 748 // |form_signatures|. We invert both lists because most recent forms are at |
748 // the end of the list. | 749 // the end of the list (and reverse the resulting pointer vector). |
749 std::vector<FormStructure*> queried_forms; | 750 std::vector<FormStructure*> queried_forms; |
750 for (const std::string& signature : base::Reversed(form_signatures)) { | 751 for (const std::string& signature : base::Reversed(form_signatures)) { |
751 for (FormStructure* cur_form : base::Reversed(form_structures_)) { | 752 for (FormStructure* cur_form : base::Reversed(form_structures_)) { |
752 if (cur_form->FormSignature() == signature) { | 753 if (cur_form->FormSignature() == signature) { |
753 queried_forms.push_back(cur_form); | 754 queried_forms.push_back(cur_form); |
754 continue; | 755 break; |
755 } | 756 } |
756 } | 757 } |
757 } | 758 } |
| 759 std::reverse(queried_forms.begin(), queried_forms.end()); |
| 760 |
758 // If there are no current forms corresponding to the queried signatures, drop | 761 // If there are no current forms corresponding to the queried signatures, drop |
759 // the query response. | 762 // the query response. |
760 if (queried_forms.empty()) | 763 if (queried_forms.empty()) |
761 return; | 764 return; |
762 | 765 |
763 // Parse and store the server predictions. | 766 // Parse and store the server predictions. |
764 FormStructure::ParseQueryResponse(response_xml, queried_forms, | 767 FormStructure::ParseQueryResponse(response_xml, queried_forms, |
765 client_->GetRapporService()); | 768 client_->GetRapporService()); |
766 | 769 |
767 // Forward form structures to the password generation manager to detect | 770 // Forward form structures to the password generation manager to detect |
(...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1634 if (i > 0) | 1637 if (i > 0) |
1635 fputs("Next oldest form:\n", file); | 1638 fputs("Next oldest form:\n", file); |
1636 } | 1639 } |
1637 fputs("\n", file); | 1640 fputs("\n", file); |
1638 | 1641 |
1639 fclose(file); | 1642 fclose(file); |
1640 } | 1643 } |
1641 #endif // ENABLE_FORM_DEBUG_DUMP | 1644 #endif // ENABLE_FORM_DEBUG_DUMP |
1642 | 1645 |
1643 } // namespace autofill | 1646 } // namespace autofill |
OLD | NEW |