1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/components/passwordmgr/nsLoginInfo.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,104 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 + 1.9 +const Cc = Components.classes; 1.10 +const Ci = Components.interfaces; 1.11 + 1.12 +Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); 1.13 + 1.14 +function nsLoginInfo() {} 1.15 + 1.16 +nsLoginInfo.prototype = { 1.17 + 1.18 + classID : Components.ID("{0f2f347c-1e4f-40cc-8efd-792dea70a85e}"), 1.19 + QueryInterface: XPCOMUtils.generateQI([Ci.nsILoginInfo, Ci.nsILoginMetaInfo]), 1.20 + 1.21 + // 1.22 + // nsILoginInfo interfaces... 1.23 + // 1.24 + 1.25 + hostname : null, 1.26 + formSubmitURL : null, 1.27 + httpRealm : null, 1.28 + username : null, 1.29 + password : null, 1.30 + usernameField : null, 1.31 + passwordField : null, 1.32 + 1.33 + init : function (aHostname, aFormSubmitURL, aHttpRealm, 1.34 + aUsername, aPassword, 1.35 + aUsernameField, aPasswordField) { 1.36 + this.hostname = aHostname; 1.37 + this.formSubmitURL = aFormSubmitURL; 1.38 + this.httpRealm = aHttpRealm; 1.39 + this.username = aUsername; 1.40 + this.password = aPassword; 1.41 + this.usernameField = aUsernameField; 1.42 + this.passwordField = aPasswordField; 1.43 + }, 1.44 + 1.45 + matches : function (aLogin, ignorePassword) { 1.46 + if (this.hostname != aLogin.hostname || 1.47 + this.httpRealm != aLogin.httpRealm || 1.48 + this.username != aLogin.username) 1.49 + return false; 1.50 + 1.51 + if (!ignorePassword && this.password != aLogin.password) 1.52 + return false; 1.53 + 1.54 + // If either formSubmitURL is blank (but not null), then match. 1.55 + if (this.formSubmitURL != "" && aLogin.formSubmitURL != "" && 1.56 + this.formSubmitURL != aLogin.formSubmitURL) 1.57 + return false; 1.58 + 1.59 + // The .usernameField and .passwordField values are ignored. 1.60 + 1.61 + return true; 1.62 + }, 1.63 + 1.64 + equals : function (aLogin) { 1.65 + if (this.hostname != aLogin.hostname || 1.66 + this.formSubmitURL != aLogin.formSubmitURL || 1.67 + this.httpRealm != aLogin.httpRealm || 1.68 + this.username != aLogin.username || 1.69 + this.password != aLogin.password || 1.70 + this.usernameField != aLogin.usernameField || 1.71 + this.passwordField != aLogin.passwordField) 1.72 + return false; 1.73 + 1.74 + return true; 1.75 + }, 1.76 + 1.77 + clone : function() { 1.78 + let clone = Cc["@mozilla.org/login-manager/loginInfo;1"]. 1.79 + createInstance(Ci.nsILoginInfo); 1.80 + clone.init(this.hostname, this.formSubmitURL, this.httpRealm, 1.81 + this.username, this.password, 1.82 + this.usernameField, this.passwordField); 1.83 + 1.84 + // Copy nsILoginMetaInfo props 1.85 + clone.QueryInterface(Ci.nsILoginMetaInfo); 1.86 + clone.guid = this.guid; 1.87 + clone.timeCreated = this.timeCreated; 1.88 + clone.timeLastUsed = this.timeLastUsed; 1.89 + clone.timePasswordChanged = this.timePasswordChanged; 1.90 + clone.timesUsed = this.timesUsed; 1.91 + 1.92 + return clone; 1.93 + }, 1.94 + 1.95 + // 1.96 + // nsILoginMetaInfo interfaces... 1.97 + // 1.98 + 1.99 + guid : null, 1.100 + timeCreated : null, 1.101 + timeLastUsed : null, 1.102 + timePasswordChanged : null, 1.103 + timesUsed : null 1.104 + 1.105 +}; // end of nsLoginInfo implementation 1.106 + 1.107 +this.NSGetFactory = XPCOMUtils.generateNSGetFactory([nsLoginInfo]);