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 888 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
899 | 899 |
900 void AutofillManager::OnLoadedServerPredictions( | 900 void AutofillManager::OnLoadedServerPredictions( |
901 std::string response, | 901 std::string response, |
902 const std::vector<std::string>& form_signatures) { | 902 const std::vector<std::string>& form_signatures) { |
903 // We obtain the current valid FormStructures represented by | 903 // We obtain the current valid FormStructures represented by |
904 // |form_signatures|. We invert both lists because most recent forms are at | 904 // |form_signatures|. We invert both lists because most recent forms are at |
905 // the end of the list (and reverse the resulting pointer vector). | 905 // the end of the list (and reverse the resulting pointer vector). |
906 std::vector<FormStructure*> queried_forms; | 906 std::vector<FormStructure*> queried_forms; |
907 for (const std::string& signature : base::Reversed(form_signatures)) { | 907 for (const std::string& signature : base::Reversed(form_signatures)) { |
908 for (FormStructure* cur_form : base::Reversed(form_structures_)) { | 908 for (FormStructure* cur_form : base::Reversed(form_structures_)) { |
909 if (cur_form->FormSignature() == signature) { | 909 if (cur_form->FormSignatureAsStr() == signature) { |
910 queried_forms.push_back(cur_form); | 910 queried_forms.push_back(cur_form); |
911 break; | 911 break; |
912 } | 912 } |
913 } | 913 } |
914 } | 914 } |
915 std::reverse(queried_forms.begin(), queried_forms.end()); | 915 std::reverse(queried_forms.begin(), queried_forms.end()); |
916 | 916 |
917 // If there are no current forms corresponding to the queried signatures, drop | 917 // If there are no current forms corresponding to the queried signatures, drop |
918 // the query response. | 918 // the query response. |
919 if (queried_forms.empty()) | 919 if (queried_forms.empty()) |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1265 UploadFormData(*submitted_form, observed_submission); | 1265 UploadFormData(*submitted_form, observed_submission); |
1266 } | 1266 } |
1267 | 1267 |
1268 void AutofillManager::UploadFormData(const FormStructure& submitted_form, | 1268 void AutofillManager::UploadFormData(const FormStructure& submitted_form, |
1269 bool observed_submission) { | 1269 bool observed_submission) { |
1270 if (!download_manager_) | 1270 if (!download_manager_) |
1271 return; | 1271 return; |
1272 | 1272 |
1273 // Check if the form is among the forms that were recently auto-filled. | 1273 // Check if the form is among the forms that were recently auto-filled. |
1274 bool was_autofilled = false; | 1274 bool was_autofilled = false; |
1275 std::string form_signature = submitted_form.FormSignature(); | 1275 std::string form_signature = submitted_form.FormSignatureAsStr(); |
1276 for (const std::string& cur_sig : autofilled_form_signatures_) { | 1276 for (const std::string& cur_sig : autofilled_form_signatures_) { |
1277 if (cur_sig == form_signature) { | 1277 if (cur_sig == form_signature) { |
1278 was_autofilled = true; | 1278 was_autofilled = true; |
1279 break; | 1279 break; |
1280 } | 1280 } |
1281 } | 1281 } |
1282 | 1282 |
1283 ServerFieldTypeSet non_empty_types; | 1283 ServerFieldTypeSet non_empty_types; |
1284 personal_data_->GetNonEmptyTypes(&non_empty_types); | 1284 personal_data_->GetNonEmptyTypes(&non_empty_types); |
1285 | 1285 |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1532 // Mark the field as autofilled when a non-empty value is assigned to | 1532 // Mark the field as autofilled when a non-empty value is assigned to |
1533 // it. This allows the renderer to distinguish autofilled fields from | 1533 // it. This allows the renderer to distinguish autofilled fields from |
1534 // fields with non-empty values, such as select-one fields. | 1534 // fields with non-empty values, such as select-one fields. |
1535 result.fields[i].is_autofilled = true; | 1535 result.fields[i].is_autofilled = true; |
1536 | 1536 |
1537 if (should_notify) | 1537 if (should_notify) |
1538 client_->DidFillOrPreviewField(value, profile_full_name); | 1538 client_->DidFillOrPreviewField(value, profile_full_name); |
1539 } | 1539 } |
1540 } | 1540 } |
1541 | 1541 |
1542 autofilled_form_signatures_.push_front(form_structure->FormSignature()); | 1542 autofilled_form_signatures_.push_front(form_structure->FormSignatureAsStr()); |
1543 // Only remember the last few forms that we've seen, both to avoid false | 1543 // Only remember the last few forms that we've seen, both to avoid false |
1544 // positives and to avoid wasting memory. | 1544 // positives and to avoid wasting memory. |
1545 if (autofilled_form_signatures_.size() > kMaxRecentFormSignaturesToRemember) | 1545 if (autofilled_form_signatures_.size() > kMaxRecentFormSignaturesToRemember) |
1546 autofilled_form_signatures_.pop_back(); | 1546 autofilled_form_signatures_.pop_back(); |
1547 | 1547 |
1548 // Note that this may invalidate |data_model|, particularly if it is a Mac | 1548 // Note that this may invalidate |data_model|, particularly if it is a Mac |
1549 // address book entry. | 1549 // address book entry. |
1550 if (action == AutofillDriver::FORM_DATA_ACTION_FILL) | 1550 if (action == AutofillDriver::FORM_DATA_ACTION_FILL) |
1551 personal_data_->RecordUseOf(data_model); | 1551 personal_data_->RecordUseOf(data_model); |
1552 | 1552 |
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2075 if (i > 0) | 2075 if (i > 0) |
2076 fputs("Next oldest form:\n", file); | 2076 fputs("Next oldest form:\n", file); |
2077 } | 2077 } |
2078 fputs("\n", file); | 2078 fputs("\n", file); |
2079 | 2079 |
2080 fclose(file); | 2080 fclose(file); |
2081 } | 2081 } |
2082 #endif // ENABLE_FORM_DEBUG_DUMP | 2082 #endif // ENABLE_FORM_DEBUG_DUMP |
2083 | 2083 |
2084 } // namespace autofill | 2084 } // namespace autofill |
OLD | NEW |