Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(394)

Side by Side Diff: components/autofill/core/browser/autofill_manager.cc

Issue 1472723003: [Autofill] OnLoadedServerPredictions correctly supplies FormStructure to ParseQueryResponse. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | components/autofill/core/browser/autofill_manager_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 718 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 values.size() != labels.size()) 738 values.size() != labels.size())
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
vabr (Chromium) 2015/11/23 16:59:25 Just curious -- was this meant to improve performa
Mathieu 2015/11/23 17:27:07 Yes it's meant to improve performance. With <form>
vabr (Chromium) 2015/11/23 17:47:07 Acknowledged.
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)) {
752 bool found_signature = false;
751 for (FormStructure* cur_form : base::Reversed(form_structures_)) { 753 for (FormStructure* cur_form : base::Reversed(form_structures_)) {
754 if (found_signature)
755 break;
752 if (cur_form->FormSignature() == signature) { 756 if (cur_form->FormSignature() == signature) {
753 queried_forms.push_back(cur_form); 757 queried_forms.push_back(cur_form);
754 continue; 758 found_signature = true;
vabr (Chromium) 2015/11/23 16:59:25 Could you just execute "break;" here and remove |f
Mathieu 2015/11/23 17:27:07 Of course, I did this too quickly, brain fart.
755 } 759 }
756 } 760 }
757 } 761 }
762 std::reverse(queried_forms.begin(), queried_forms.end());
763
758 // If there are no current forms corresponding to the queried signatures, drop 764 // If there are no current forms corresponding to the queried signatures, drop
759 // the query response. 765 // the query response.
760 if (queried_forms.empty()) 766 if (queried_forms.empty())
761 return; 767 return;
762 768
763 // Parse and store the server predictions. 769 // Parse and store the server predictions.
764 FormStructure::ParseQueryResponse(response_xml, queried_forms, 770 FormStructure::ParseQueryResponse(response_xml, queried_forms,
765 client_->GetRapporService()); 771 client_->GetRapporService());
766 772
767 // Forward form structures to the password generation manager to detect 773 // Forward form structures to the password generation manager to detect
(...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after
1634 if (i > 0) 1640 if (i > 0)
1635 fputs("Next oldest form:\n", file); 1641 fputs("Next oldest form:\n", file);
1636 } 1642 }
1637 fputs("\n", file); 1643 fputs("\n", file);
1638 1644
1639 fclose(file); 1645 fclose(file);
1640 } 1646 }
1641 #endif // ENABLE_FORM_DEBUG_DUMP 1647 #endif // ENABLE_FORM_DEBUG_DUMP
1642 1648
1643 } // namespace autofill 1649 } // namespace autofill
OLDNEW
« no previous file with comments | « no previous file | components/autofill/core/browser/autofill_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698