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 // Ownership is transferred to |form_structures_| which maintains it until |
| 1416 // the manager is Reset() or destroyed. It is safe to use references below |
| 1417 // as long as receivers don't take ownership. |
| 1418 form_structures_.push_back(form_structure.Pass()); |
| 1419 |
| 1420 if (form_structures_.back()->ShouldBeCrowdsourced()) { |
1415 AutofillMetrics::LogPasswordFormQueryVolume( | 1421 AutofillMetrics::LogPasswordFormQueryVolume( |
1416 AutofillMetrics::CURRENT_QUERY); | 1422 AutofillMetrics::CURRENT_QUERY); |
1417 form_structures_.push_back(form_structure.release()); | 1423 queryable_forms.push_back(form_structures_.back()); |
1418 } else { | 1424 } else { |
1419 non_queryable_forms.push_back(form_structure.release()); | 1425 non_queryable_forms.push_back(form_structures_.back()); |
1420 } | 1426 } |
1421 } | 1427 } |
1422 | 1428 |
1423 if (!form_structures_.empty() && download_manager_) { | 1429 if (!queryable_forms.empty() && download_manager_) { |
1424 // Query the server if at least one of the forms was parsed. | 1430 // Query the server if at least one of the forms was parsed. |
1425 download_manager_->StartQueryRequest(form_structures_.get()); | 1431 download_manager_->StartQueryRequest(queryable_forms); |
1426 } | 1432 } |
1427 | 1433 |
1428 for (FormStructure* structure : non_queryable_forms) | 1434 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); | 1435 AutofillMetrics::LogUserHappinessMetric(AutofillMetrics::FORMS_LOADED); |
1433 #if defined(OS_IOS) | 1436 #if defined(OS_IOS) |
1434 // Log this from same location as AutofillMetrics::FORMS_LOADED to ensure | 1437 // Log this from same location as AutofillMetrics::FORMS_LOADED to ensure |
1435 // that KeyboardAccessoryButtonsIOS and UserHappiness UMA metrics will be | 1438 // that KeyboardAccessoryButtonsIOS and UserHappiness UMA metrics will be |
1436 // directly comparable. | 1439 // directly comparable. |
1437 KeyboardAccessoryMetricsLogger::OnFormsLoaded(); | 1440 KeyboardAccessoryMetricsLogger::OnFormsLoaded(); |
1438 #endif | 1441 #endif |
1439 } | 1442 } |
1440 | 1443 |
1441 // For the |non_queryable_forms|, we have all the field type info we're ever | 1444 // 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) | 1563 if (i > 0) |
1561 fputs("Next oldest form:\n", file); | 1564 fputs("Next oldest form:\n", file); |
1562 } | 1565 } |
1563 fputs("\n", file); | 1566 fputs("\n", file); |
1564 | 1567 |
1565 fclose(file); | 1568 fclose(file); |
1566 } | 1569 } |
1567 #endif // ENABLE_FORM_DEBUG_DUMP | 1570 #endif // ENABLE_FORM_DEBUG_DUMP |
1568 | 1571 |
1569 } // namespace autofill | 1572 } // namespace autofill |
OLD | NEW |