Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: components/autofill/core/browser/autofill_manager.cc

Issue 1411363003: [Autofill] Always show available data when encountering autocomplete attributes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
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() < kRequiredFieldsForPredictionRoutines) {
Evan Stade 2015/11/17 19:13:36 nit: this function now looks like if (a) return
sebsg 2015/11/18 16:40:27 Done.
814 return false; 819 return false;
820 }
815 821
816 return true; 822 return true;
817 } 823 }
818 824
819 void AutofillManager::ImportFormData(const FormStructure& submitted_form) { 825 void AutofillManager::ImportFormData(const FormStructure& submitted_form) {
820 scoped_ptr<CreditCard> imported_credit_card; 826 scoped_ptr<CreditCard> imported_credit_card;
821 if (!personal_data_->ImportFormData(submitted_form, &imported_credit_card)) 827 if (!personal_data_->ImportFormData(submitted_form, &imported_credit_card))
822 return; 828 return;
823 829
824 #ifdef ENABLE_FORM_DEBUG_DUMP 830 #ifdef ENABLE_FORM_DEBUG_DUMP
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
1353 1359
1354 void AutofillManager::ParseForms(const std::vector<FormData>& forms) { 1360 void AutofillManager::ParseForms(const std::vector<FormData>& forms) {
1355 if (forms.empty()) 1361 if (forms.empty())
1356 return; 1362 return;
1357 1363
1358 std::vector<FormStructure*> non_queryable_forms; 1364 std::vector<FormStructure*> non_queryable_forms;
1359 std::vector<FormStructure*> queryable_forms; 1365 std::vector<FormStructure*> queryable_forms;
1360 for (const FormData& form : forms) { 1366 for (const FormData& form : forms) {
1361 scoped_ptr<FormStructure> form_structure(new FormStructure(form)); 1367 scoped_ptr<FormStructure> form_structure(new FormStructure(form));
1362 1368
1369 form_structure->ParseFieldTypesFromAutocompleteAttributes();
1370
1363 if (!form_structure->ShouldBeParsed()) { 1371 if (!form_structure->ShouldBeParsed()) {
1364 if (form_structure->has_password_field()) { 1372 if (form_structure->has_password_field()) {
1365 AutofillMetrics::LogPasswordFormQueryVolume( 1373 AutofillMetrics::LogPasswordFormQueryVolume(
1366 AutofillMetrics::NEW_PASSWORD_QUERY); 1374 AutofillMetrics::NEW_PASSWORD_QUERY);
1367 } 1375 }
1368 continue; 1376 continue;
1369 } 1377 }
1370 1378
1371 form_structure->DetermineHeuristicTypes(); 1379 form_structure->DetermineHeuristicTypes();
1372 1380
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1507 if (i > 0) 1515 if (i > 0)
1508 fputs("Next oldest form:\n", file); 1516 fputs("Next oldest form:\n", file);
1509 } 1517 }
1510 fputs("\n", file); 1518 fputs("\n", file);
1511 1519
1512 fclose(file); 1520 fclose(file);
1513 } 1521 }
1514 #endif // ENABLE_FORM_DEBUG_DUMP 1522 #endif // ENABLE_FORM_DEBUG_DUMP
1515 1523
1516 } // namespace autofill 1524 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698