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 26 matching lines...) Expand all Loading... | |
37 #include "components/autofill/core/browser/autofill_metrics.h" | 37 #include "components/autofill/core/browser/autofill_metrics.h" |
38 #include "components/autofill/core/browser/autofill_profile.h" | 38 #include "components/autofill/core/browser/autofill_profile.h" |
39 #include "components/autofill/core/browser/autofill_type.h" | 39 #include "components/autofill/core/browser/autofill_type.h" |
40 #include "components/autofill/core/browser/credit_card.h" | 40 #include "components/autofill/core/browser/credit_card.h" |
41 #include "components/autofill/core/browser/field_types.h" | 41 #include "components/autofill/core/browser/field_types.h" |
42 #include "components/autofill/core/browser/form_structure.h" | 42 #include "components/autofill/core/browser/form_structure.h" |
43 #include "components/autofill/core/browser/personal_data_manager.h" | 43 #include "components/autofill/core/browser/personal_data_manager.h" |
44 #include "components/autofill/core/browser/phone_number.h" | 44 #include "components/autofill/core/browser/phone_number.h" |
45 #include "components/autofill/core/browser/phone_number_i18n.h" | 45 #include "components/autofill/core/browser/phone_number_i18n.h" |
46 #include "components/autofill/core/browser/popup_item_ids.h" | 46 #include "components/autofill/core/browser/popup_item_ids.h" |
47 #include "components/autofill/core/common/autofill_constants.h" | |
47 #include "components/autofill/core/common/autofill_data_validation.h" | 48 #include "components/autofill/core/common/autofill_data_validation.h" |
48 #include "components/autofill/core/common/autofill_pref_names.h" | 49 #include "components/autofill/core/common/autofill_pref_names.h" |
49 #include "components/autofill/core/common/autofill_switches.h" | 50 #include "components/autofill/core/common/autofill_switches.h" |
50 #include "components/autofill/core/common/form_data.h" | 51 #include "components/autofill/core/common/form_data.h" |
51 #include "components/autofill/core/common/form_data_predictions.h" | 52 #include "components/autofill/core/common/form_data_predictions.h" |
52 #include "components/autofill/core/common/form_field_data.h" | 53 #include "components/autofill/core/common/form_field_data.h" |
53 #include "components/autofill/core/common/password_form_fill_data.h" | 54 #include "components/autofill/core/common/password_form_fill_data.h" |
54 #include "components/pref_registry/pref_registry_syncable.h" | 55 #include "components/pref_registry/pref_registry_syncable.h" |
55 #include "grit/components_strings.h" | 56 #include "grit/components_strings.h" |
56 #include "ui/base/l10n/l10n_util.h" | 57 #include "ui/base/l10n/l10n_util.h" |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
379 | 380 |
380 external_delegate_->OnQuery(query_id, form, field, bounding_box); | 381 external_delegate_->OnQuery(query_id, form, field, bounding_box); |
381 | 382 |
382 // Need to refresh models before using the form_event_loggers. | 383 // Need to refresh models before using the form_event_loggers. |
383 bool is_autofill_possible = RefreshDataModels(); | 384 bool is_autofill_possible = RefreshDataModels(); |
384 | 385 |
385 FormStructure* form_structure = NULL; | 386 FormStructure* form_structure = NULL; |
386 AutofillField* autofill_field = NULL; | 387 AutofillField* autofill_field = NULL; |
387 bool got_autofillable_form = | 388 bool got_autofillable_form = |
388 GetCachedFormAndField(form, field, &form_structure, &autofill_field) && | 389 GetCachedFormAndField(form, field, &form_structure, &autofill_field) && |
389 // Don't send suggestions or track forms that aren't auto-fillable. | 390 // Don't send suggestions or track forms that should not be parsed. |
390 form_structure->IsAutofillable(); | 391 form_structure->ShouldBeParsed(); |
391 | 392 |
392 // Logging interactions of forms that are autofillable. | 393 // Logging interactions of forms that are autofillable. |
393 if (got_autofillable_form) { | 394 if (got_autofillable_form) { |
394 if (autofill_field->Type().group() == CREDIT_CARD) | 395 if (autofill_field->Type().group() == CREDIT_CARD) |
395 credit_card_form_event_logger_->OnDidInteractWithAutofillableForm(); | 396 credit_card_form_event_logger_->OnDidInteractWithAutofillableForm(); |
396 else | 397 else |
397 address_form_event_logger_->OnDidInteractWithAutofillableForm(); | 398 address_form_event_logger_->OnDidInteractWithAutofillableForm(); |
398 } | 399 } |
399 | 400 |
400 if (is_autofill_possible && | 401 if (is_autofill_possible && |
(...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1393 | 1394 |
1394 void AutofillManager::ParseForms(const std::vector<FormData>& forms) { | 1395 void AutofillManager::ParseForms(const std::vector<FormData>& forms) { |
1395 if (forms.empty()) | 1396 if (forms.empty()) |
1396 return; | 1397 return; |
1397 | 1398 |
1398 std::vector<FormStructure*> non_queryable_forms; | 1399 std::vector<FormStructure*> non_queryable_forms; |
1399 std::vector<FormStructure*> queryable_forms; | 1400 std::vector<FormStructure*> queryable_forms; |
1400 for (const FormData& form : forms) { | 1401 for (const FormData& form : forms) { |
1401 scoped_ptr<FormStructure> form_structure(new FormStructure(form)); | 1402 scoped_ptr<FormStructure> form_structure(new FormStructure(form)); |
1402 | 1403 |
1404 form_structure->ParseFieldTypesFromAutocompleteAttributes(); | |
1405 | |
1403 if (!form_structure->ShouldBeParsed()) { | 1406 if (!form_structure->ShouldBeParsed()) { |
1404 if (form_structure->has_password_field()) { | 1407 if (form_structure->has_password_field()) { |
1405 AutofillMetrics::LogPasswordFormQueryVolume( | 1408 AutofillMetrics::LogPasswordFormQueryVolume( |
1406 AutofillMetrics::NEW_PASSWORD_QUERY); | 1409 AutofillMetrics::NEW_PASSWORD_QUERY); |
1407 } | 1410 } |
1408 continue; | 1411 continue; |
1409 } | 1412 } |
1410 | 1413 |
1411 form_structure->DetermineHeuristicTypes(); | 1414 form_structure->DetermineHeuristicTypes(); |
1412 | 1415 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1514 } | 1517 } |
1515 | 1518 |
1516 bool AutofillManager::ShouldUploadForm(const FormStructure& form) { | 1519 bool AutofillManager::ShouldUploadForm(const FormStructure& form) { |
1517 if (!IsAutofillEnabled()) | 1520 if (!IsAutofillEnabled()) |
1518 return false; | 1521 return false; |
1519 | 1522 |
1520 if (driver_->IsOffTheRecord()) | 1523 if (driver_->IsOffTheRecord()) |
1521 return false; | 1524 return false; |
1522 | 1525 |
1523 // Disregard forms that we wouldn't ever autofill in the first place. | 1526 // Disregard forms that we wouldn't ever autofill in the first place. |
1524 if (!form.ShouldBeParsed()) | 1527 // ShouldBeParsed can return true for small forms in certain situations so a |
1528 // specific check for the number of active fields is necessary to avoid | |
1529 // uploading very small forms. | |
1530 if (!form.ShouldBeParsed() && | |
Evan Stade
2015/10/21 19:12:31
shouldn't this be an or not an and?
sebsg
2015/10/26 15:57:56
Done.
Evan Stade
2015/10/27 17:08:37
does one of the tests you added verify the correct
sebsg
2015/11/10 19:04:50
Done.
| |
1531 form.active_field_count() < kRequiredAutofillFields) | |
1525 return false; | 1532 return false; |
1526 | 1533 |
1527 return true; | 1534 return true; |
1528 } | 1535 } |
1529 | 1536 |
1530 #ifdef ENABLE_FORM_DEBUG_DUMP | 1537 #ifdef ENABLE_FORM_DEBUG_DUMP |
1531 void AutofillManager::DumpAutofillData(bool imported_cc) const { | 1538 void AutofillManager::DumpAutofillData(bool imported_cc) const { |
1532 base::ThreadRestrictions::ScopedAllowIO allow_id; | 1539 base::ThreadRestrictions::ScopedAllowIO allow_id; |
1533 | 1540 |
1534 // This code dumps the last few forms seen on the current tab to a file on | 1541 // This code dumps the last few forms seen on the current tab to a file on |
(...skipping 26 matching lines...) Expand all Loading... | |
1561 if (i > 0) | 1568 if (i > 0) |
1562 fputs("Next oldest form:\n", file); | 1569 fputs("Next oldest form:\n", file); |
1563 } | 1570 } |
1564 fputs("\n", file); | 1571 fputs("\n", file); |
1565 | 1572 |
1566 fclose(file); | 1573 fclose(file); |
1567 } | 1574 } |
1568 #endif // ENABLE_FORM_DEBUG_DUMP | 1575 #endif // ENABLE_FORM_DEBUG_DUMP |
1569 | 1576 |
1570 } // namespace autofill | 1577 } // namespace autofill |
OLD | NEW |