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

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: Fixed bug Created 5 years 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 "google_apis/gaia/identity_provider.h" 56 #include "google_apis/gaia/identity_provider.h"
56 #include "grit/components_strings.h" 57 #include "grit/components_strings.h"
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 383
383 external_delegate_->OnQuery(query_id, form, field, bounding_box); 384 external_delegate_->OnQuery(query_id, form, field, bounding_box);
384 385
385 // Need to refresh models before using the form_event_loggers. 386 // Need to refresh models before using the form_event_loggers.
386 bool is_autofill_possible = RefreshDataModels(); 387 bool is_autofill_possible = RefreshDataModels();
387 388
388 FormStructure* form_structure = NULL; 389 FormStructure* form_structure = NULL;
389 AutofillField* autofill_field = NULL; 390 AutofillField* autofill_field = NULL;
390 bool got_autofillable_form = 391 bool got_autofillable_form =
391 GetCachedFormAndField(form, field, &form_structure, &autofill_field) && 392 GetCachedFormAndField(form, field, &form_structure, &autofill_field) &&
392 // Don't send suggestions or track forms that aren't auto-fillable. 393 // Don't send suggestions or track forms that should not be parsed.
393 form_structure->IsAutofillable(); 394 form_structure->ShouldBeParsed();
394 395
395 // Logging interactions of forms that are autofillable. 396 // Logging interactions of forms that are autofillable.
396 if (got_autofillable_form) { 397 if (got_autofillable_form) {
397 if (autofill_field->Type().group() == CREDIT_CARD) 398 if (autofill_field->Type().group() == CREDIT_CARD)
398 credit_card_form_event_logger_->OnDidInteractWithAutofillableForm(); 399 credit_card_form_event_logger_->OnDidInteractWithAutofillableForm();
399 else 400 else
400 address_form_event_logger_->OnDidInteractWithAutofillableForm(); 401 address_form_event_logger_->OnDidInteractWithAutofillableForm();
401 } 402 }
402 403
403 if (is_autofill_possible && 404 if (is_autofill_possible &&
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 bool AutofillManager::IsAutofillEnabled() const { 880 bool AutofillManager::IsAutofillEnabled() const {
880 return ::autofill::IsAutofillEnabled(client_->GetPrefs()); 881 return ::autofill::IsAutofillEnabled(client_->GetPrefs());
881 } 882 }
882 883
883 bool AutofillManager::IsCreditCardUploadEnabled() { 884 bool AutofillManager::IsCreditCardUploadEnabled() {
884 return ::autofill::IsCreditCardUploadEnabled( 885 return ::autofill::IsCreditCardUploadEnabled(
885 client_->GetPrefs(), GetIdentityProvider()->GetActiveUsername()); 886 client_->GetPrefs(), GetIdentityProvider()->GetActiveUsername());
886 } 887 }
887 888
888 bool AutofillManager::ShouldUploadForm(const FormStructure& form) { 889 bool AutofillManager::ShouldUploadForm(const FormStructure& form) {
889 if (!IsAutofillEnabled()) 890 return IsAutofillEnabled() && !driver_->IsOffTheRecord() &&
890 return false; 891 form.ShouldBeParsed() &&
891 892 form.active_field_count() >= kRequiredFieldsForUpload;
892 if (driver_->IsOffTheRecord())
893 return false;
894
895 // Disregard forms that we wouldn't ever autofill in the first place.
896 if (!form.ShouldBeParsed())
897 return false;
898
899 return true;
900 } 893 }
901 894
902 void AutofillManager::ImportFormData(const FormStructure& submitted_form) { 895 void AutofillManager::ImportFormData(const FormStructure& submitted_form) {
903 scoped_ptr<CreditCard> imported_credit_card; 896 scoped_ptr<CreditCard> imported_credit_card;
904 if (!personal_data_->ImportFormData(submitted_form, &imported_credit_card)) 897 if (!personal_data_->ImportFormData(submitted_form, &imported_credit_card))
905 return; 898 return;
906 899
907 #ifdef ENABLE_FORM_DEBUG_DUMP 900 #ifdef ENABLE_FORM_DEBUG_DUMP
908 // Debug code for research on what autofill Chrome extracts from the last few 901 // Debug code for research on what autofill Chrome extracts from the last few
909 // forms when submitting credit card data. See DumpAutofillData(). 902 // forms when submitting credit card data. See DumpAutofillData().
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
1487 } 1480 }
1488 1481
1489 void AutofillManager::ParseForms(const std::vector<FormData>& forms) { 1482 void AutofillManager::ParseForms(const std::vector<FormData>& forms) {
1490 if (forms.empty()) 1483 if (forms.empty())
1491 return; 1484 return;
1492 1485
1493 std::vector<FormStructure*> non_queryable_forms; 1486 std::vector<FormStructure*> non_queryable_forms;
1494 std::vector<FormStructure*> queryable_forms; 1487 std::vector<FormStructure*> queryable_forms;
1495 for (const FormData& form : forms) { 1488 for (const FormData& form : forms) {
1496 scoped_ptr<FormStructure> form_structure(new FormStructure(form)); 1489 scoped_ptr<FormStructure> form_structure(new FormStructure(form));
1490 form_structure->ParseFieldTypesFromAutocompleteAttributes();
1497 1491
1498 if (!form_structure->ShouldBeParsed()) 1492 if (!form_structure->ShouldBeParsed())
1499 continue; 1493 continue;
1500 1494
1501 form_structure->DetermineHeuristicTypes(); 1495 form_structure->DetermineHeuristicTypes();
1502 1496
1503 // Ownership is transferred to |form_structures_| which maintains it until 1497 // Ownership is transferred to |form_structures_| which maintains it until
1504 // the manager is Reset() or destroyed. It is safe to use references below 1498 // the manager is Reset() or destroyed. It is safe to use references below
1505 // as long as receivers don't take ownership. 1499 // as long as receivers don't take ownership.
1506 form_structures_.push_back(form_structure.Pass()); 1500 form_structures_.push_back(form_structure.Pass());
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
1634 if (i > 0) 1628 if (i > 0)
1635 fputs("Next oldest form:\n", file); 1629 fputs("Next oldest form:\n", file);
1636 } 1630 }
1637 fputs("\n", file); 1631 fputs("\n", file);
1638 1632
1639 fclose(file); 1633 fclose(file);
1640 } 1634 }
1641 #endif // ENABLE_FORM_DEBUG_DUMP 1635 #endif // ENABLE_FORM_DEBUG_DUMP
1642 1636
1643 } // namespace autofill 1637 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/autofill_manager.h ('k') | components/autofill/core/browser/autofill_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698