michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: michael@0: const Cc = Components.classes; michael@0: const Ci = Components.interfaces; michael@0: michael@0: Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); michael@0: michael@0: function nsLoginInfo() {} michael@0: michael@0: nsLoginInfo.prototype = { michael@0: michael@0: classID : Components.ID("{0f2f347c-1e4f-40cc-8efd-792dea70a85e}"), michael@0: QueryInterface: XPCOMUtils.generateQI([Ci.nsILoginInfo, Ci.nsILoginMetaInfo]), michael@0: michael@0: // michael@0: // nsILoginInfo interfaces... michael@0: // michael@0: michael@0: hostname : null, michael@0: formSubmitURL : null, michael@0: httpRealm : null, michael@0: username : null, michael@0: password : null, michael@0: usernameField : null, michael@0: passwordField : null, michael@0: michael@0: init : function (aHostname, aFormSubmitURL, aHttpRealm, michael@0: aUsername, aPassword, michael@0: aUsernameField, aPasswordField) { michael@0: this.hostname = aHostname; michael@0: this.formSubmitURL = aFormSubmitURL; michael@0: this.httpRealm = aHttpRealm; michael@0: this.username = aUsername; michael@0: this.password = aPassword; michael@0: this.usernameField = aUsernameField; michael@0: this.passwordField = aPasswordField; michael@0: }, michael@0: michael@0: matches : function (aLogin, ignorePassword) { michael@0: if (this.hostname != aLogin.hostname || michael@0: this.httpRealm != aLogin.httpRealm || michael@0: this.username != aLogin.username) michael@0: return false; michael@0: michael@0: if (!ignorePassword && this.password != aLogin.password) michael@0: return false; michael@0: michael@0: // If either formSubmitURL is blank (but not null), then match. michael@0: if (this.formSubmitURL != "" && aLogin.formSubmitURL != "" && michael@0: this.formSubmitURL != aLogin.formSubmitURL) michael@0: return false; michael@0: michael@0: // The .usernameField and .passwordField values are ignored. michael@0: michael@0: return true; michael@0: }, michael@0: michael@0: equals : function (aLogin) { michael@0: if (this.hostname != aLogin.hostname || michael@0: this.formSubmitURL != aLogin.formSubmitURL || michael@0: this.httpRealm != aLogin.httpRealm || michael@0: this.username != aLogin.username || michael@0: this.password != aLogin.password || michael@0: this.usernameField != aLogin.usernameField || michael@0: this.passwordField != aLogin.passwordField) michael@0: return false; michael@0: michael@0: return true; michael@0: }, michael@0: michael@0: clone : function() { michael@0: let clone = Cc["@mozilla.org/login-manager/loginInfo;1"]. michael@0: createInstance(Ci.nsILoginInfo); michael@0: clone.init(this.hostname, this.formSubmitURL, this.httpRealm, michael@0: this.username, this.password, michael@0: this.usernameField, this.passwordField); michael@0: michael@0: // Copy nsILoginMetaInfo props michael@0: clone.QueryInterface(Ci.nsILoginMetaInfo); michael@0: clone.guid = this.guid; michael@0: clone.timeCreated = this.timeCreated; michael@0: clone.timeLastUsed = this.timeLastUsed; michael@0: clone.timePasswordChanged = this.timePasswordChanged; michael@0: clone.timesUsed = this.timesUsed; michael@0: michael@0: return clone; michael@0: }, michael@0: michael@0: // michael@0: // nsILoginMetaInfo interfaces... michael@0: // michael@0: michael@0: guid : null, michael@0: timeCreated : null, michael@0: timeLastUsed : null, michael@0: timePasswordChanged : null, michael@0: timesUsed : null michael@0: michael@0: }; // end of nsLoginInfo implementation michael@0: michael@0: this.NSGetFactory = XPCOMUtils.generateNSGetFactory([nsLoginInfo]);