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 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
803 } | 804 } |
804 | 805 |
805 bool AutofillManager::ShouldUploadForm(const FormStructure& form) { | 806 bool AutofillManager::ShouldUploadForm(const FormStructure& form) { |
806 if (!IsAutofillEnabled()) | 807 if (!IsAutofillEnabled()) |
807 return false; | 808 return false; |
808 | 809 |
809 if (driver_->IsOffTheRecord()) | 810 if (driver_->IsOffTheRecord()) |
810 return false; | 811 return false; |
811 | 812 |
812 // Disregard forms that we wouldn't ever autofill in the first place. | 813 // Disregard forms that we wouldn't ever autofill in the first place. |
813 if (!form.ShouldBeParsed()) | 814 // ShouldBeParsed can return true for small forms in certain situations so a |
815 // specific check for the number of active fields is necessary to avoid | |
816 // uploading very small forms. | |
817 if (!form.ShouldBeParsed() || | |
818 form.active_field_count() < kRequiredAutofillFields) | |
Evan Stade
2015/11/04 17:15:19
kRequiredAutofillFields needs updating (its commen
Evan Stade
2015/11/04 17:15:19
nit: Curlies
sebsg
2015/11/10 19:04:51
Done.
sebsg
2015/11/10 19:04:51
Done.
| |
814 return false; | 819 return false; |
815 | 820 |
816 return true; | 821 return true; |
817 } | 822 } |
818 | 823 |
819 void AutofillManager::ImportFormData(const FormStructure& submitted_form) { | 824 void AutofillManager::ImportFormData(const FormStructure& submitted_form) { |
820 scoped_ptr<CreditCard> imported_credit_card; | 825 scoped_ptr<CreditCard> imported_credit_card; |
821 if (!personal_data_->ImportFormData(submitted_form, &imported_credit_card)) | 826 if (!personal_data_->ImportFormData(submitted_form, &imported_credit_card)) |
822 return; | 827 return; |
823 | 828 |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1353 | 1358 |
1354 void AutofillManager::ParseForms(const std::vector<FormData>& forms) { | 1359 void AutofillManager::ParseForms(const std::vector<FormData>& forms) { |
1355 if (forms.empty()) | 1360 if (forms.empty()) |
1356 return; | 1361 return; |
1357 | 1362 |
1358 std::vector<FormStructure*> non_queryable_forms; | 1363 std::vector<FormStructure*> non_queryable_forms; |
1359 std::vector<FormStructure*> queryable_forms; | 1364 std::vector<FormStructure*> queryable_forms; |
1360 for (const FormData& form : forms) { | 1365 for (const FormData& form : forms) { |
1361 scoped_ptr<FormStructure> form_structure(new FormStructure(form)); | 1366 scoped_ptr<FormStructure> form_structure(new FormStructure(form)); |
1362 | 1367 |
1368 form_structure->ParseFieldTypesFromAutocompleteAttributes(); | |
1369 | |
1363 if (!form_structure->ShouldBeParsed()) { | 1370 if (!form_structure->ShouldBeParsed()) { |
1364 if (form_structure->has_password_field()) { | 1371 if (form_structure->has_password_field()) { |
1365 AutofillMetrics::LogPasswordFormQueryVolume( | 1372 AutofillMetrics::LogPasswordFormQueryVolume( |
1366 AutofillMetrics::NEW_PASSWORD_QUERY); | 1373 AutofillMetrics::NEW_PASSWORD_QUERY); |
1367 } | 1374 } |
1368 continue; | 1375 continue; |
1369 } | 1376 } |
1370 | 1377 |
1371 form_structure->DetermineHeuristicTypes(); | 1378 form_structure->DetermineHeuristicTypes(); |
1372 | 1379 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1507 if (i > 0) | 1514 if (i > 0) |
1508 fputs("Next oldest form:\n", file); | 1515 fputs("Next oldest form:\n", file); |
1509 } | 1516 } |
1510 fputs("\n", file); | 1517 fputs("\n", file); |
1511 | 1518 |
1512 fclose(file); | 1519 fclose(file); |
1513 } | 1520 } |
1514 #endif // ENABLE_FORM_DEBUG_DUMP | 1521 #endif // ENABLE_FORM_DEBUG_DUMP |
1515 | 1522 |
1516 } // namespace autofill | 1523 } // namespace autofill |
OLD | NEW |