diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js index 8d100ff4d3ac..ca987f373d84 100644 --- a/browser/app/profile/firefox.js +++ b/browser/app/profile/firefox.js @@ -1788,6 +1788,8 @@ pref("extensions.formautofill.reauth.enabled", false); pref("extensions.formautofill.section.enabled", true); pref("extensions.formautofill.loglevel", "Warn"); +pref("browser.osKeyStore.loglevel", "Warn"); + #ifdef NIGHTLY_BUILD // Comma separated list of countries Form Autofill is available in. pref("extensions.formautofill.supportedCountries", "US,CA,DE"); diff --git a/browser/extensions/formautofill/FormAutofillParent.jsm b/browser/extensions/formautofill/FormAutofillParent.jsm index b78cb37e19b6..091087a0917a 100644 --- a/browser/extensions/formautofill/FormAutofillParent.jsm +++ b/browser/extensions/formautofill/FormAutofillParent.jsm @@ -341,7 +341,7 @@ class FormAutofillParent extends JSWindowActorParent { break; } case "FormAutofill:SaveCreditCard": { - if (!(await OSKeyStore.ensureLoggedIn())) { + if (!(await FormAutofillUtils.ensureLoggedIn())) { log.warn("User canceled encryption login"); return undefined; } @@ -690,7 +690,7 @@ class FormAutofillParent extends JSWindowActorParent { return; } - if (!(await OSKeyStore.ensureLoggedIn())) { + if (!(await FormAutofillUtils.ensureLoggedIn())) { log.warn("User canceled encryption login"); return; } diff --git a/browser/extensions/formautofill/FormAutofillUtils.jsm b/browser/extensions/formautofill/FormAutofillUtils.jsm index ae512d4c5cc0..d907b9f80e05 100644 --- a/browser/extensions/formautofill/FormAutofillUtils.jsm +++ b/browser/extensions/formautofill/FormAutofillUtils.jsm @@ -63,11 +63,10 @@ const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); const { FormAutofill } = ChromeUtils.import( "resource://formautofill/FormAutofill.jsm" ); -ChromeUtils.defineModuleGetter( - this, - "CreditCard", - "resource://gre/modules/CreditCard.jsm" -); +XPCOMUtils.defineLazyModuleGetters(this, { + CreditCard: "resource://gre/modules/CreditCard.jsm", + OSKeyStore: "resource:///modules/OSKeyStore.jsm", +}); let AddressDataLoader = { // Status of address data loading. We'll load all the countries with basic level 1 @@ -275,6 +274,12 @@ this.FormAutofillUtils = { return CreditCard.isValidNumber(ccNumber); }, + ensureLoggedIn(promptMessage) { + return OSKeyStore.ensureLoggedIn( + this._reauthEnabledByUser && promptMessage ? promptMessage : false + ); + }, + /** * Get the array of credit card network ids ("types") we expect and offer as valid choices * @@ -1111,3 +1116,10 @@ XPCOMUtils.defineLazyGetter(FormAutofillUtils, "brandBundle", function() { "chrome://branding/locale/brand.properties" ); }); + +XPCOMUtils.defineLazyPreferenceGetter( + FormAutofillUtils, + "_reauthEnabledByUser", + "extensions.formautofill.reauth.enabled", + false +); diff --git a/browser/extensions/formautofill/content/manageDialog.js b/browser/extensions/formautofill/content/manageDialog.js index 010c9f3b7895..087ee4b5aa4f 100644 --- a/browser/extensions/formautofill/content/manageDialog.js +++ b/browser/extensions/formautofill/content/manageDialog.js @@ -371,7 +371,7 @@ class ManageCreditCards extends ManageRecords { // Ask for reauth if user is trying to edit an existing credit card. if ( !creditCard || - (await OSKeyStore.ensureLoggedIn(reauthPasswordPromptMessage)) + (await FormAutofillUtils.ensureLoggedIn(reauthPasswordPromptMessage)) ) { let decryptedCCNumObj = {}; if (creditCard && creditCard["cc-number-encrypted"]) { diff --git a/browser/modules/OSKeyStore.jsm b/browser/modules/OSKeyStore.jsm index 2bdb5a2e6c75..fce04ba4b337 100644 --- a/browser/modules/OSKeyStore.jsm +++ b/browser/modules/OSKeyStore.jsm @@ -34,8 +34,7 @@ XPCOMUtils.defineLazyServiceGetter( ); // Skip reauth during tests, only works in non-official builds. -const TEST_ONLY_REAUTH = - "extensions.formautofill.osKeyStore.unofficialBuildOnlyLogin"; +const TEST_ONLY_REAUTH = "browser.osKeyStore.unofficialBuildOnlyLogin"; var OSKeyStore = { /** @@ -139,7 +138,7 @@ var OSKeyStore = { let unlockPromise; // Decides who should handle reauth - if (!this._reauthEnabledByUser || (typeof reauth == "boolean" && !reauth)) { + if (typeof reauth == "boolean" && !reauth) { unlockPromise = Promise.resolve(); } else if (!AppConstants.MOZILLA_OFFICIAL && this._testReauth) { unlockPromise = this._reauthInTests(); @@ -293,7 +292,7 @@ XPCOMUtils.defineLazyGetter(this, "log", () => { let ConsoleAPI = ChromeUtils.import("resource://gre/modules/Console.jsm", {}) .ConsoleAPI; return new ConsoleAPI({ - maxLogLevelPref: "extensions.formautofill.loglevel", + maxLogLevelPref: "browser.osKeyStore.loglevel", prefix: "OSKeyStore", }); }); @@ -304,9 +303,3 @@ XPCOMUtils.defineLazyPreferenceGetter( TEST_ONLY_REAUTH, "" ); -XPCOMUtils.defineLazyPreferenceGetter( - OSKeyStore, - "_reauthEnabledByUser", - "extensions.formautofill.reauth.enabled", - false -); diff --git a/browser/modules/test/OSKeyStoreTestUtils.jsm b/browser/modules/test/OSKeyStoreTestUtils.jsm index c66347252986..339cef4f5f33 100644 --- a/browser/modules/test/OSKeyStoreTestUtils.jsm +++ b/browser/modules/test/OSKeyStoreTestUtils.jsm @@ -15,8 +15,7 @@ const { TestUtils } = ChromeUtils.import( ); var OSKeyStoreTestUtils = { - TEST_ONLY_REAUTH: - "extensions.formautofill.osKeyStore.unofficialBuildOnlyLogin", + TEST_ONLY_REAUTH: "browser.osKeyStore.unofficialBuildOnlyLogin", setup() { this.ORIGINAL_STORE_LABEL = OSKeyStore.STORE_LABEL; diff --git a/browser/modules/test/unit/test_osKeyStore.js b/browser/modules/test/unit/test_osKeyStore.js index 0896bc76b2ad..f634d64c922d 100644 --- a/browser/modules/test/unit/test_osKeyStore.js +++ b/browser/modules/test/unit/test_osKeyStore.js @@ -22,8 +22,6 @@ add_task(async function os_key_store_setup() { let OSKeyStore; add_task(async function setup() { - Services.prefs.setBoolPref("extensions.formautofill.reauth.enabled", true); - ({ OSKeyStore } = ChromeUtils.import("resource:///modules/OSKeyStore.jsm")); }); @@ -87,14 +85,6 @@ add_task(async function test_reauth() { "Reauth logged in." ); await reauthObserved; - - Services.prefs.setBoolPref("extensions.formautofill.reauth.enabled", false); - Assert.equal( - await OSKeyStore.ensureLoggedIn(true), - true, - "Reauth disabled so logged in without prompt" - ); - Services.prefs.setBoolPref("extensions.formautofill.reauth.enabled", true); }); add_task(async function test_decryption_failure() {