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 1380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1391 MakeFrontendID(suggestions[i].backend_id, std::string()); | 1391 MakeFrontendID(suggestions[i].backend_id, std::string()); |
1392 } | 1392 } |
1393 return suggestions; | 1393 return suggestions; |
1394 } | 1394 } |
1395 | 1395 |
1396 void AutofillManager::ParseForms(const std::vector<FormData>& forms) { | 1396 void AutofillManager::ParseForms(const std::vector<FormData>& forms) { |
1397 if (forms.empty()) | 1397 if (forms.empty()) |
1398 return; | 1398 return; |
1399 | 1399 |
1400 std::vector<FormStructure*> non_queryable_forms; | 1400 std::vector<FormStructure*> non_queryable_forms; |
1401 std::vector<FormStructure*> queryable_forms; | |
1401 for (const FormData& form : forms) { | 1402 for (const FormData& form : forms) { |
1402 scoped_ptr<FormStructure> form_structure(new FormStructure(form)); | 1403 scoped_ptr<FormStructure> form_structure(new FormStructure(form)); |
1403 | 1404 |
1404 if (!form_structure->ShouldBeParsed()) { | 1405 if (!form_structure->ShouldBeParsed()) { |
1405 if (form_structure->has_password_field()) { | 1406 if (form_structure->has_password_field()) { |
1406 AutofillMetrics::LogPasswordFormQueryVolume( | 1407 AutofillMetrics::LogPasswordFormQueryVolume( |
1407 AutofillMetrics::NEW_PASSWORD_QUERY); | 1408 AutofillMetrics::NEW_PASSWORD_QUERY); |
1408 } | 1409 } |
1409 continue; | 1410 continue; |
1410 } | 1411 } |
1411 | 1412 |
1412 form_structure->DetermineHeuristicTypes(); | 1413 form_structure->DetermineHeuristicTypes(); |
1413 | 1414 |
1414 if (form_structure->ShouldBeCrowdsourced()) { | 1415 FormStructure* structure = form_structure.release(); |
Evan Stade
2015/09/29 22:06:45
This ownership model is super brittle and needs to
Mathieu
2015/09/30 13:09:54
SendAutofillTypePredictionsToRenderer does not tak
| |
1416 form_structures_.push_back(structure); | |
1417 if (structure->ShouldBeCrowdsourced()) { | |
1415 AutofillMetrics::LogPasswordFormQueryVolume( | 1418 AutofillMetrics::LogPasswordFormQueryVolume( |
1416 AutofillMetrics::CURRENT_QUERY); | 1419 AutofillMetrics::CURRENT_QUERY); |
1417 form_structures_.push_back(form_structure.release()); | 1420 queryable_forms.push_back(structure); |
1418 } else { | 1421 } else { |
1419 non_queryable_forms.push_back(form_structure.release()); | 1422 non_queryable_forms.push_back(structure); |
1420 } | 1423 } |
1421 } | 1424 } |
1422 | 1425 |
1423 if (!form_structures_.empty() && download_manager_) { | 1426 if (!queryable_forms.empty() && download_manager_) { |
1424 // Query the server if at least one of the forms was parsed. | 1427 // Query the server if at least one of the forms was parsed. |
1425 download_manager_->StartQueryRequest(form_structures_.get()); | 1428 download_manager_->StartQueryRequest(queryable_forms); |
1426 } | 1429 } |
1427 | 1430 |
1428 for (FormStructure* structure : non_queryable_forms) | 1431 if (!queryable_forms.empty() || !non_queryable_forms.empty()) { |
1429 form_structures_.push_back(structure); | |
1430 | |
1431 if (!form_structures_.empty()) { | |
1432 AutofillMetrics::LogUserHappinessMetric(AutofillMetrics::FORMS_LOADED); | 1432 AutofillMetrics::LogUserHappinessMetric(AutofillMetrics::FORMS_LOADED); |
1433 #if defined(OS_IOS) | 1433 #if defined(OS_IOS) |
1434 // Log this from same location as AutofillMetrics::FORMS_LOADED to ensure | 1434 // Log this from same location as AutofillMetrics::FORMS_LOADED to ensure |
1435 // that KeyboardAccessoryButtonsIOS and UserHappiness UMA metrics will be | 1435 // that KeyboardAccessoryButtonsIOS and UserHappiness UMA metrics will be |
1436 // directly comparable. | 1436 // directly comparable. |
1437 KeyboardAccessoryMetricsLogger::OnFormsLoaded(); | 1437 KeyboardAccessoryMetricsLogger::OnFormsLoaded(); |
1438 #endif | 1438 #endif |
1439 } | 1439 } |
1440 | 1440 |
1441 // For the |non_queryable_forms|, we have all the field type info we're ever | 1441 // For the |non_queryable_forms|, we have all the field type info we're ever |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1560 if (i > 0) | 1560 if (i > 0) |
1561 fputs("Next oldest form:\n", file); | 1561 fputs("Next oldest form:\n", file); |
1562 } | 1562 } |
1563 fputs("\n", file); | 1563 fputs("\n", file); |
1564 | 1564 |
1565 fclose(file); | 1565 fclose(file); |
1566 } | 1566 } |
1567 #endif // ENABLE_FORM_DEBUG_DUMP | 1567 #endif // ENABLE_FORM_DEBUG_DUMP |
1568 | 1568 |
1569 } // namespace autofill | 1569 } // namespace autofill |
OLD | NEW |