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

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 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 797
797 void AutofillManager::OnDidEndTextFieldEditing() { 798 void AutofillManager::OnDidEndTextFieldEditing() {
798 external_delegate_->DidEndTextFieldEditing(); 799 external_delegate_->DidEndTextFieldEditing();
799 } 800 }
800 801
801 bool AutofillManager::IsAutofillEnabled() const { 802 bool AutofillManager::IsAutofillEnabled() const {
802 return ::autofill::IsAutofillEnabled(client_->GetPrefs()); 803 return ::autofill::IsAutofillEnabled(client_->GetPrefs());
803 } 804 }
804 805
805 bool AutofillManager::ShouldUploadForm(const FormStructure& form) { 806 bool AutofillManager::ShouldUploadForm(const FormStructure& form) {
806 if (!IsAutofillEnabled()) 807 return IsAutofillEnabled() && !driver_->IsOffTheRecord() &&
807 return false; 808 form.ShouldBeParsed() &&
808 809 form.active_field_count() >= kRequiredFieldsForUpload;
809 if (driver_->IsOffTheRecord())
810 return false;
811
812 // Disregard forms that we wouldn't ever autofill in the first place.
813 if (!form.ShouldBeParsed())
814 return false;
815
816 return true;
817 } 810 }
818 811
819 void AutofillManager::ImportFormData(const FormStructure& submitted_form) { 812 void AutofillManager::ImportFormData(const FormStructure& submitted_form) {
820 scoped_ptr<CreditCard> imported_credit_card; 813 scoped_ptr<CreditCard> imported_credit_card;
821 if (!personal_data_->ImportFormData(submitted_form, &imported_credit_card)) 814 if (!personal_data_->ImportFormData(submitted_form, &imported_credit_card))
822 return; 815 return;
823 816
824 #ifdef ENABLE_FORM_DEBUG_DUMP 817 #ifdef ENABLE_FORM_DEBUG_DUMP
825 // Debug code for research on what autofill Chrome extracts from the last few 818 // Debug code for research on what autofill Chrome extracts from the last few
826 // forms when submitting credit card data. See DumpAutofillData(). 819 // forms when submitting credit card data. See DumpAutofillData().
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
1352 } 1345 }
1353 1346
1354 void AutofillManager::ParseForms(const std::vector<FormData>& forms) { 1347 void AutofillManager::ParseForms(const std::vector<FormData>& forms) {
1355 if (forms.empty()) 1348 if (forms.empty())
1356 return; 1349 return;
1357 1350
1358 std::vector<FormStructure*> non_queryable_forms; 1351 std::vector<FormStructure*> non_queryable_forms;
1359 std::vector<FormStructure*> queryable_forms; 1352 std::vector<FormStructure*> queryable_forms;
1360 for (const FormData& form : forms) { 1353 for (const FormData& form : forms) {
1361 scoped_ptr<FormStructure> form_structure(new FormStructure(form)); 1354 scoped_ptr<FormStructure> form_structure(new FormStructure(form));
1362 1355
Evan Stade 2015/11/18 22:59:15 ^H
sebsg 2015/11/19 19:25:03 Done.
1356 form_structure->ParseFieldTypesFromAutocompleteAttributes();
1357
1363 if (!form_structure->ShouldBeParsed()) { 1358 if (!form_structure->ShouldBeParsed()) {
1364 if (form_structure->has_password_field()) { 1359 if (form_structure->has_password_field()) {
1365 AutofillMetrics::LogPasswordFormQueryVolume( 1360 AutofillMetrics::LogPasswordFormQueryVolume(
1366 AutofillMetrics::NEW_PASSWORD_QUERY); 1361 AutofillMetrics::NEW_PASSWORD_QUERY);
1367 } 1362 }
1368 continue; 1363 continue;
1369 } 1364 }
1370 1365
1371 form_structure->DetermineHeuristicTypes(); 1366 form_structure->DetermineHeuristicTypes();
1372 1367
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1507 if (i > 0) 1502 if (i > 0)
1508 fputs("Next oldest form:\n", file); 1503 fputs("Next oldest form:\n", file);
1509 } 1504 }
1510 fputs("\n", file); 1505 fputs("\n", file);
1511 1506
1512 fclose(file); 1507 fclose(file);
1513 } 1508 }
1514 #endif // ENABLE_FORM_DEBUG_DUMP 1509 #endif // ENABLE_FORM_DEBUG_DUMP
1515 1510
1516 } // namespace autofill 1511 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698