Bug 1341569 - Part 1: Make the formfill executable for metrics when exerimental pref is off, r?MattN draft
authorsteveck-chung <schung@mozilla.com>
Mon, 13 Mar 2017 16:17:27 +0800
changeset 504531 c69ec9bc99b261756b37f0348b216f34bfbfae46
parent 501295 1b9293be51637f841275541d8991314ca56561a5
child 504532 094f422ff4e88e3b4e626c24205090c7ee185f59
push id50814
push userbmo:schung@mozilla.com
push dateFri, 24 Mar 2017 10:42:38 +0000
reviewersMattN
bugs1341569
milestone55.0a1
Bug 1341569 - Part 1: Make the formfill executable for metrics when exerimental pref is off, r?MattN MozReview-Commit-ID: LlDGsrkQJzL
browser/extensions/formautofill/FormAutofillParent.jsm
browser/extensions/formautofill/bootstrap.js
--- 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);