mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Primitive password tracking support (bug 435320, r=thunder)
This commit is contained in:
parent
777c82cf0b
commit
f7911b9746
@ -198,3 +198,48 @@ PasswordStore.prototype = {
|
||||
};
|
||||
PasswordStore.prototype.__proto__ = new Store();
|
||||
|
||||
function PasswordTracker() {
|
||||
this._init();
|
||||
}
|
||||
PasswordTracker.prototype = {
|
||||
_logName: "PasswordTracker",
|
||||
|
||||
__loginManager : null,
|
||||
get _loginManager() {
|
||||
if (!this.__loginManager)
|
||||
this.__loginManager = Cc["@mozilla.org/login-manager;1"].
|
||||
getService(Ci.nsILoginManager);
|
||||
return this.__loginManager;
|
||||
},
|
||||
|
||||
/* We use nsILoginManager's countLogins() method, as it is
|
||||
* the only method that doesn't require the user to enter
|
||||
* a master password, but still gives us an idea of how much
|
||||
* info has changed.
|
||||
*
|
||||
* FIXME: This does not track edits of passwords, so we
|
||||
* artificially add 30 to every score. We should move to
|
||||
* using the LoginManager shim at some point.
|
||||
*
|
||||
* Each addition/removal is worth 15 points.
|
||||
*/
|
||||
_loginCount: 0,
|
||||
get score() {
|
||||
var count = this._loginManager.countLogins("", "", "");
|
||||
var score = Math.abs(this._loginCount - count) * 15;
|
||||
|
||||
if (score >= 100)
|
||||
return 100;
|
||||
else
|
||||
return score + 30;
|
||||
},
|
||||
|
||||
resetScore: function PasswordTracker_resetScore() {
|
||||
this._loginCount = this._loginManager.countLogins("", "", "");
|
||||
},
|
||||
|
||||
_init: function PasswordTracker__init() {
|
||||
this._log = Log4Moz.Service.getLogger("Service." this._logName);
|
||||
this._loginCount = this._loginManager.countLogins("", "", "");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user