[
Bug 620716] Observer error when switching the value of the 'Remember password' pref [r=mfinkle]
--- 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