Skip to content

Commit

Permalink
Bug 1339731 - Refactor FormAutofillHandler to support multiple sectio…
Browse files Browse the repository at this point in the history
…n machanism. r=lchang,ralin

MozReview-Commit-ID: D9g5fKTeTaL

--HG--
extra : rebase_source : ef5a572e5038dfe6746d99e683c53625d6c45d9a
  • Loading branch information
weilonge committed Nov 20, 2017
1 parent ef3c08c commit bc4a3d7
Show file tree
Hide file tree
Showing 10 changed files with 483 additions and 299 deletions.
1 change: 1 addition & 0 deletions browser/app/profile/firefox.js
Original file line number Diff line number Diff line change
Expand Up @@ -1709,6 +1709,7 @@ pref("extensions.formautofill.creditCards.enabled", true);
pref("extensions.formautofill.creditCards.used", 0);
pref("extensions.formautofill.firstTimeUse", true);
pref("extensions.formautofill.heuristics.enabled", true);
pref("extensions.formautofill.section.enabled", true);
pref("extensions.formautofill.loglevel", "Warn");

// Whether or not to restore a session with lazy-browser tabs.
Expand Down
9 changes: 5 additions & 4 deletions browser/extensions/formautofill/FormAutofillContent.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,9 @@ AutofillProfileAutoCompleteSearch.prototype = {
let info = FormAutofillContent.getInputDetails(focusedInput);
let isAddressField = FormAutofillUtils.isAddressField(info.fieldName);
let handler = FormAutofillContent.getFormHandler(focusedInput);
let allFieldNames = handler.allFieldNames;
let filledRecordGUID = isAddressField ? handler.address.filledRecordGUID : handler.creditCard.filledRecordGUID;
let section = handler.getSectionByElement(focusedInput);
let allFieldNames = section.allFieldNames;
let filledRecordGUID = isAddressField ? section.address.filledRecordGUID : section.creditCard.filledRecordGUID;
let searchPermitted = isAddressField ?
FormAutofillUtils.isAutofillAddressesEnabled :
FormAutofillUtils.isAutofillCreditCardsEnabled;
Expand Down Expand Up @@ -149,7 +150,7 @@ AutofillProfileAutoCompleteSearch.prototype = {
// Sort addresses by timeLastUsed for showing the lastest used address at top.
records.sort((a, b) => b.timeLastUsed - a.timeLastUsed);

let adaptedRecords = handler.getAdaptedProfiles(records);
let adaptedRecords = handler.getAdaptedProfiles(records, focusedInput);
let result = null;
if (isAddressField) {
result = new AddressResult(searchString,
Expand Down Expand Up @@ -481,7 +482,7 @@ var FormAutofillContent = {

getAllFieldNames(element) {
let formHandler = this.getFormHandler(element);
return formHandler ? formHandler.allFieldNames : null;
return formHandler ? formHandler.getAllFieldNames(element) : null;
},

identifyAutofillFields(element) {
Expand Down
Loading

0 comments on commit bc4a3d7

Please sign in to comment.