From fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:14:29 +0200 Subject: Merging upstream version 125.0.1. Signed-off-by: Daniel Baumann --- .../formautofill/ProfileAutoCompleteResult.sys.mjs | 62 ++++++++++++++++------ 1 file changed, 46 insertions(+), 16 deletions(-) (limited to 'toolkit/components/formautofill/ProfileAutoCompleteResult.sys.mjs') diff --git a/toolkit/components/formautofill/ProfileAutoCompleteResult.sys.mjs b/toolkit/components/formautofill/ProfileAutoCompleteResult.sys.mjs index 15fc1a520c..52ed8bed03 100644 --- a/toolkit/components/formautofill/ProfileAutoCompleteResult.sys.mjs +++ b/toolkit/components/formautofill/ProfileAutoCompleteResult.sys.mjs @@ -12,7 +12,7 @@ ChromeUtils.defineESModuleGetters(lazy, { ChromeUtils.defineLazyGetter( lazy, "l10n", - () => new Localization(["browser/preferences/formAutofill.ftl"], true) + () => new Localization(["toolkit/formautofill/formAutofill.ftl"], true) ); class ProfileAutoCompleteResult { @@ -100,16 +100,16 @@ class ProfileAutoCompleteResult { * Get the secondary label based on the focused field name and related field names * in the same form. * - * @param {string} focusedFieldName The field name of the focused input - * @param {Array} allFieldNames The field names in the same section - * @param {object} profile The profile providing the labels to show. + * @param {string} _focusedFieldName The field name of the focused input + * @param {Array} _allFieldNames The field names in the same section + * @param {object} _profile The profile providing the labels to show. * @returns {string} The secondary label */ - _getSecondaryLabel(focusedFieldName, allFieldNames, profile) { + _getSecondaryLabel(_focusedFieldName, _allFieldNames, _profile) { return ""; } - _generateLabels(focusedFieldName, allFieldNames, profiles) {} + _generateLabels(_focusedFieldName, _allFieldNames, _profiles) {} /** * Get the value of the result at the given index. @@ -190,19 +190,19 @@ class ProfileAutoCompleteResult { /** * Returns true if the value at the given index is removable * - * @param {number} index The index of the result to remove + * @param {number} _index The index of the result to remove * @returns {boolean} True if the value is removable */ - isRemovableAt(index) { + isRemovableAt(_index) { return false; } /** * Removes a result from the resultset * - * @param {number} index The index of the result to remove + * @param {number} _index The index of the result to remove */ - removeValueAt(index) { + removeValueAt(_index) { // There is no plan to support removing profiles via autocomplete. } } @@ -277,10 +277,19 @@ export class AddressResult extends ProfileAutoCompleteResult { } _generateLabels(focusedFieldName, allFieldNames, profiles) { + const manageLabel = lazy.l10n.formatValueSync( + "autofill-manage-addresses-label" + ); + if (this._isInputAutofilled) { return [ { primary: "", secondary: "" }, // Clear button - { primary: "", secondary: "" }, // Footer + // Footer + { + primary: "", + secondary: "", + manageLabel, + }, ]; } @@ -306,6 +315,10 @@ export class AddressResult extends ProfileAutoCompleteResult { ), }; }); + + const focusedCategory = + lazy.FormAutofillUtils.getCategoryFromFieldName(focusedFieldName); + // Add an empty result entry for footer. Its content will come from // the footer binding, so don't assign any value to it. // The additional properties: categories and focusedCategory are required of @@ -313,12 +326,11 @@ export class AddressResult extends ProfileAutoCompleteResult { labels.push({ primary: "", secondary: "", + manageLabel, categories: lazy.FormAutofillUtils.getCategoriesFromFieldNames( this._allFieldNames ), - focusedCategory: lazy.FormAutofillUtils.getCategoryFromFieldName( - this._focusedFieldName - ), + focusedCategory, }); return labels; @@ -385,10 +397,19 @@ export class CreditCardResult extends ProfileAutoCompleteResult { ]; } + const manageLabel = lazy.l10n.formatValueSync( + "autofill-manage-payment-methods-label" + ); + if (this._isInputAutofilled) { return [ { primary: "", secondary: "" }, // Clear button - { primary: "", secondary: "" }, // Footer + // Footer + { + primary: "", + secondary: "", + manageLabel, + }, ]; } @@ -431,8 +452,17 @@ export class CreditCardResult extends ProfileAutoCompleteResult { image, }; }); + + const focusedCategory = + lazy.FormAutofillUtils.getCategoryFromFieldName(focusedFieldName); + // Add an empty result entry for footer. - labels.push({ primary: "", secondary: "" }); + labels.push({ + primary: "", + secondary: "", + manageLabel, + focusedCategory, + }); return labels; } -- cgit v1.2.3