toolkit/components/passwordmgr/nsLoginInfo.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

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.

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 const Cc = Components.classes;
     7 const Ci = Components.interfaces;
     9 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
    11 function nsLoginInfo() {}
    13 nsLoginInfo.prototype = {
    15     classID : Components.ID("{0f2f347c-1e4f-40cc-8efd-792dea70a85e}"),
    16     QueryInterface: XPCOMUtils.generateQI([Ci.nsILoginInfo, Ci.nsILoginMetaInfo]),
    18     //
    19     // nsILoginInfo interfaces...
    20     //
    22     hostname      : null,
    23     formSubmitURL : null,
    24     httpRealm     : null,
    25     username      : null,
    26     password      : null,
    27     usernameField : null,
    28     passwordField : null,
    30     init : function (aHostname, aFormSubmitURL, aHttpRealm,
    31                      aUsername,      aPassword,
    32                      aUsernameField, aPasswordField) {
    33         this.hostname      = aHostname;
    34         this.formSubmitURL = aFormSubmitURL;
    35         this.httpRealm     = aHttpRealm;
    36         this.username      = aUsername;
    37         this.password      = aPassword;
    38         this.usernameField = aUsernameField;
    39         this.passwordField = aPasswordField;
    40     },
    42     matches : function (aLogin, ignorePassword) {
    43         if (this.hostname      != aLogin.hostname      ||
    44             this.httpRealm     != aLogin.httpRealm     ||
    45             this.username      != aLogin.username)
    46             return false;
    48         if (!ignorePassword && this.password != aLogin.password)
    49             return false;
    51         // If either formSubmitURL is blank (but not null), then match.
    52         if (this.formSubmitURL != "" && aLogin.formSubmitURL != "" &&
    53             this.formSubmitURL != aLogin.formSubmitURL)
    54             return false;
    56         // The .usernameField and .passwordField values are ignored.
    58         return true;
    59     },
    61     equals : function (aLogin) {
    62         if (this.hostname      != aLogin.hostname      ||
    63             this.formSubmitURL != aLogin.formSubmitURL ||
    64             this.httpRealm     != aLogin.httpRealm     ||
    65             this.username      != aLogin.username      ||
    66             this.password      != aLogin.password      ||
    67             this.usernameField != aLogin.usernameField ||
    68             this.passwordField != aLogin.passwordField)
    69             return false;
    71         return true;
    72     },
    74     clone : function() {
    75         let clone = Cc["@mozilla.org/login-manager/loginInfo;1"].
    76                     createInstance(Ci.nsILoginInfo);
    77         clone.init(this.hostname, this.formSubmitURL, this.httpRealm,
    78                    this.username, this.password,
    79                    this.usernameField, this.passwordField);
    81         // Copy nsILoginMetaInfo props
    82         clone.QueryInterface(Ci.nsILoginMetaInfo);
    83         clone.guid = this.guid;
    84         clone.timeCreated = this.timeCreated;
    85         clone.timeLastUsed = this.timeLastUsed;
    86         clone.timePasswordChanged = this.timePasswordChanged;
    87         clone.timesUsed = this.timesUsed;
    89         return clone;
    90     },
    92     //
    93     // nsILoginMetaInfo interfaces...
    94     //
    96     guid : null,
    97     timeCreated : null,
    98     timeLastUsed : null,
    99     timePasswordChanged : null,
   100     timesUsed : null
   102 }; // end of nsLoginInfo implementation
   104 this.NSGetFactory = XPCOMUtils.generateNSGetFactory([nsLoginInfo]);

mercurial