Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | |
michael@0 | 6 | const Cc = Components.classes; |
michael@0 | 7 | const Ci = Components.interfaces; |
michael@0 | 8 | |
michael@0 | 9 | Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); |
michael@0 | 10 | |
michael@0 | 11 | function nsLoginInfo() {} |
michael@0 | 12 | |
michael@0 | 13 | nsLoginInfo.prototype = { |
michael@0 | 14 | |
michael@0 | 15 | classID : Components.ID("{0f2f347c-1e4f-40cc-8efd-792dea70a85e}"), |
michael@0 | 16 | QueryInterface: XPCOMUtils.generateQI([Ci.nsILoginInfo, Ci.nsILoginMetaInfo]), |
michael@0 | 17 | |
michael@0 | 18 | // |
michael@0 | 19 | // nsILoginInfo interfaces... |
michael@0 | 20 | // |
michael@0 | 21 | |
michael@0 | 22 | hostname : null, |
michael@0 | 23 | formSubmitURL : null, |
michael@0 | 24 | httpRealm : null, |
michael@0 | 25 | username : null, |
michael@0 | 26 | password : null, |
michael@0 | 27 | usernameField : null, |
michael@0 | 28 | passwordField : null, |
michael@0 | 29 | |
michael@0 | 30 | init : function (aHostname, aFormSubmitURL, aHttpRealm, |
michael@0 | 31 | aUsername, aPassword, |
michael@0 | 32 | aUsernameField, aPasswordField) { |
michael@0 | 33 | this.hostname = aHostname; |
michael@0 | 34 | this.formSubmitURL = aFormSubmitURL; |
michael@0 | 35 | this.httpRealm = aHttpRealm; |
michael@0 | 36 | this.username = aUsername; |
michael@0 | 37 | this.password = aPassword; |
michael@0 | 38 | this.usernameField = aUsernameField; |
michael@0 | 39 | this.passwordField = aPasswordField; |
michael@0 | 40 | }, |
michael@0 | 41 | |
michael@0 | 42 | matches : function (aLogin, ignorePassword) { |
michael@0 | 43 | if (this.hostname != aLogin.hostname || |
michael@0 | 44 | this.httpRealm != aLogin.httpRealm || |
michael@0 | 45 | this.username != aLogin.username) |
michael@0 | 46 | return false; |
michael@0 | 47 | |
michael@0 | 48 | if (!ignorePassword && this.password != aLogin.password) |
michael@0 | 49 | return false; |
michael@0 | 50 | |
michael@0 | 51 | // If either formSubmitURL is blank (but not null), then match. |
michael@0 | 52 | if (this.formSubmitURL != "" && aLogin.formSubmitURL != "" && |
michael@0 | 53 | this.formSubmitURL != aLogin.formSubmitURL) |
michael@0 | 54 | return false; |
michael@0 | 55 | |
michael@0 | 56 | // The .usernameField and .passwordField values are ignored. |
michael@0 | 57 | |
michael@0 | 58 | return true; |
michael@0 | 59 | }, |
michael@0 | 60 | |
michael@0 | 61 | equals : function (aLogin) { |
michael@0 | 62 | if (this.hostname != aLogin.hostname || |
michael@0 | 63 | this.formSubmitURL != aLogin.formSubmitURL || |
michael@0 | 64 | this.httpRealm != aLogin.httpRealm || |
michael@0 | 65 | this.username != aLogin.username || |
michael@0 | 66 | this.password != aLogin.password || |
michael@0 | 67 | this.usernameField != aLogin.usernameField || |
michael@0 | 68 | this.passwordField != aLogin.passwordField) |
michael@0 | 69 | return false; |
michael@0 | 70 | |
michael@0 | 71 | return true; |
michael@0 | 72 | }, |
michael@0 | 73 | |
michael@0 | 74 | clone : function() { |
michael@0 | 75 | let clone = Cc["@mozilla.org/login-manager/loginInfo;1"]. |
michael@0 | 76 | createInstance(Ci.nsILoginInfo); |
michael@0 | 77 | clone.init(this.hostname, this.formSubmitURL, this.httpRealm, |
michael@0 | 78 | this.username, this.password, |
michael@0 | 79 | this.usernameField, this.passwordField); |
michael@0 | 80 | |
michael@0 | 81 | // Copy nsILoginMetaInfo props |
michael@0 | 82 | clone.QueryInterface(Ci.nsILoginMetaInfo); |
michael@0 | 83 | clone.guid = this.guid; |
michael@0 | 84 | clone.timeCreated = this.timeCreated; |
michael@0 | 85 | clone.timeLastUsed = this.timeLastUsed; |
michael@0 | 86 | clone.timePasswordChanged = this.timePasswordChanged; |
michael@0 | 87 | clone.timesUsed = this.timesUsed; |
michael@0 | 88 | |
michael@0 | 89 | return clone; |
michael@0 | 90 | }, |
michael@0 | 91 | |
michael@0 | 92 | // |
michael@0 | 93 | // nsILoginMetaInfo interfaces... |
michael@0 | 94 | // |
michael@0 | 95 | |
michael@0 | 96 | guid : null, |
michael@0 | 97 | timeCreated : null, |
michael@0 | 98 | timeLastUsed : null, |
michael@0 | 99 | timePasswordChanged : null, |
michael@0 | 100 | timesUsed : null |
michael@0 | 101 | |
michael@0 | 102 | }; // end of nsLoginInfo implementation |
michael@0 | 103 | |
michael@0 | 104 | this.NSGetFactory = XPCOMUtils.generateNSGetFactory([nsLoginInfo]); |