Bug 1341569 - Part 1: Make the formfill executable for metrics when exerimental pref is off, r?MattN
MozReview-Commit-ID: LlDGsrkQJzL
--- a/browser/extensions/formautofill/FormAutofillParent.jsm
+++ b/browser/extensions/formautofill/FormAutofillParent.jsm
@@ -46,16 +46,17 @@ XPCOMUtils.defineLazyModuleGetter(this,
XPCOMUtils.defineLazyModuleGetter(this, "FormAutofillPreferences",
"resource://formautofill/FormAutofillPreferences.jsm");
this.log = null;
FormAutofillUtils.defineLazyLogGetter(this, this.EXPORTED_SYMBOLS[0]);
const PROFILE_JSON_FILE_NAME = "autofill-profiles.json";
const ENABLED_PREF = "browser.formautofill.enabled";
+const EXPERIMENT_PREF="browser.formautofill.experimental";
function FormAutofillParent() {
}
FormAutofillParent.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports, Ci.nsIObserver]),
_profileStore: null,
@@ -150,17 +151,18 @@ FormAutofillParent.prototype = {
/**
* Query pref and storage status to determine the overall status for
* form autofill feature.
*
* @returns {boolean} status of form autofill feature
*/
_getStatus() {
- if (!Services.prefs.getBoolPref(ENABLED_PREF)) {
+ if (!Services.prefs.getBoolPref(ENABLED_PREF) ||
+ !Services.prefs.getBoolPref(EXPERIMENT_PREF)) {
return false;
}
return this._profileStore.getAll().length > 0;
},
/**
* Set status and trigger _onStatusChanged.
--- a/browser/extensions/formautofill/bootstrap.js
+++ b/browser/extensions/formautofill/bootstrap.js
@@ -38,37 +38,40 @@ let windowListener = {
insertStyleSheet(domWindow, STYLESHEET_URI);
}, {once: true});
},
};
function startup() {
// Besides this pref, we'll need dom.forms.autocomplete.experimental enabled
// as well to make sure form autocomplete works correctly.
- if (!Services.prefs.getBoolPref("browser.formautofill.experimental")) {
- return;
+ if (Services.prefs.getBoolPref("browser.formautofill.experimental")) {
+ let enumerator = Services.wm.getEnumerator("navigator:browser");
+ // Load stylesheet to already opened windows
+ while (enumerator.hasMoreElements()) {
+ let win = enumerator.getNext();
+ let domWindow = win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindow);
+
+ insertStyleSheet(domWindow, STYLESHEET_URI);
+ }
+
+ Services.wm.addListener(windowListener);
}
let parent = new FormAutofillParent();
- let enumerator = Services.wm.getEnumerator("navigator:browser");
- // Load stylesheet to already opened windows
- while (enumerator.hasMoreElements()) {
- let win = enumerator.getNext();
- let domWindow = win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindow);
-
- insertStyleSheet(domWindow, STYLESHEET_URI);
- }
-
- Services.wm.addListener(windowListener);
parent.init();
Services.mm.loadFrameScript("chrome://formautofill/content/FormAutofillFrameScript.js", true);
}
function shutdown() {
+ if (!Services.prefs.getBoolPref("browser.formautofill.experimental")) {
+ return;
+ }
+
Services.wm.removeListener(windowListener);
let enumerator = Services.wm.getEnumerator("navigator:browser");
while (enumerator.hasMoreElements()) {
let win = enumerator.getNext();
let domWindow = win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindow);
let cachedStyleSheets = CACHED_STYLESHEETS.get(domWindow);