[Bug 620716] Observer error when switching the value of the 'Remember password' pref [r=mfinkle]
authorVivien Nicolas <21@vingtetun.org>
Tue, 21 Dec 2010 19:33:19 +0100
changeset 67150 b8cd409005013b52b9affda4d1d97332223c62a0
parent 67149 43dc8694c2da174065cd0168c97bff3ea8da0800
child 67151 ac4824435f189be0bec1eaa0230b163947e231cc
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs620716
[Bug 620716] Observer error when switching the value of the 'Remember password' pref [r=mfinkle]
mobile/chrome/content/LoginManagerChild.js
--- a/mobile/chrome/content/LoginManagerChild.js
+++ b/mobile/chrome/content/LoginManagerChild.js
@@ -375,17 +375,17 @@ var loginManager = {
         var pwFields = this._getPasswordFields(form, isSubmission);
         if (!pwFields)
             return [null, null, null];
 
 
         // Locate the username field in the form by searching backwards
         // from the first passwordfield, assume the first text field is the
         // username. We might not find a username field if the user is
-        // already logged in to the site. 
+        // already logged in to the site.
         for (var i = pwFields[0].index - 1; i >= 0; i--) {
             if (form.elements[i].type == "text") {
                 usernameField = form.elements[i];
                 break;
             }
         }
 
         if (!usernameField)
@@ -438,17 +438,17 @@ var loginManager = {
                 newPasswordField = pwFields[1].element;
             }
         }
 
         return [usernameField, newPasswordField, oldPasswordField];
     },
 
 
-    /* ---------- Private methods ---------- */ 
+    /* ---------- Private methods ---------- */
 
 
     /*
      * _getPasswordFields
      *
      * Returns an array of password field elements for the specified form.
      * If no pw fields are found, or if more than 3 are found, then null
      * is returned.
@@ -703,17 +703,18 @@ var loginManager = {
      * _observer object
      *
      * Internal utility object, implements the nsIObserver interface.
      * Used to receive notification for: form submission, preference changes.
      */
     _observer : {
         _pwmgr : null,
 
-        QueryInterface : XPCOMUtils.generateQI([Ci.nsIFormSubmitObserver,
+        QueryInterface : XPCOMUtils.generateQI([Ci.nsIObserver,
+                                                Ci.nsIFormSubmitObserver,
                                                 Ci.nsISupportsWeakReference]),
 
 
         // nsFormSubmitObserver
         notify : function (formElement, aWindow, actionURI) {
             // Counterintuitively, form submit observers fire for content that 
             // may not be the content in this context.
             if (aWindow.top != content)
@@ -727,16 +728,21 @@ var loginManager = {
             try {
                 this._pwmgr._onFormSubmit(formElement);
             } catch (e) {
                 this._pwmgr.log("Caught error in onFormSubmit: " + e);
             }
 
             return true; // Always return true, or form submit will be canceled.
         },
+
+        observe : function (aSubject, aTopic, aData) {
+          this._pwmgr._debug    = Services.prefs.getBoolPref("signon.debug");
+          this._pwmgr._remember = Services.prefs.getBoolPref("signon.rememberSignons");
+        }
     },
 
 
     /*
      * _webProgressListener object
      *
      * Internal utility object, implements nsIWebProgressListener interface.
      * This is attached to the document loader service, so we get