1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 * Form Autofill content process module.
9 /* eslint-disable no-use-before-define */
13 ChromeUtils.defineESModuleGetters(lazy, {
14 FormAutofill: "resource://autofill/FormAutofill.sys.mjs",
17 const formFillController = Cc[
18 "@mozilla.org/satchel/form-fill-controller;1"
19 ].getService(Ci.nsIFormFillController);
22 * Handles content's interactions for the process.
25 export var FormAutofillContent = {
27 * @type {Set} Set of the fields with usable values in any saved profile.
29 get savedFieldNames() {
30 return Services.cpmm.sharedData.get("FormAutofill:savedFieldNames");
34 return formFillController.focusedInput;
38 * @type {boolean} Flag indicating whether a focus action requiring
39 * the popup to be active is pending.
44 this.log = lazy.FormAutofill.defineLogGetter(this, "FormAutofillContent");
47 // eslint-disable-next-line mozilla/balanced-listeners
48 Services.cpmm.sharedData.addEventListener("change", this);
52 if (Services.cpmm.sharedData.get("FormAutofill:enabled")) {
53 this.debug("updateActiveElement: opening pop up");
54 formFillController.showPopup();
57 "updateActiveElement: Deferring pop-up until Autofill is ready"
59 this._popupPending = true;
66 if (!evt.changedKeys.includes("FormAutofill:enabled")) {
69 if (Services.cpmm.sharedData.get("FormAutofill:enabled")) {
70 if (this._popupPending) {
71 this._popupPending = false;
72 this.debug("handleEvent: Opening deferred popup");
73 formFillController.showPopup();
82 FormAutofillContent.init();