зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1382937 - Rewrite Sync's master password functions to use the `nsILoginManagerCrypto` wrappers. r=MattN
Using `nsISecretDecoderRing` directly bypasses `nsILoginManagerCrypto.uiBusy` and the observer notifications, so other consumers might not be aware we're already showing the dialog. We also bail early if the UI is busy, to avoid showing multiple dialogs. MozReview-Commit-ID: I7xzUWZkyPH --HG-- extra : rebase_source : 91cef140cc54d1c81fe5c1986ffd2b8983ddd575
This commit is contained in:
Родитель
91159e3d56
Коммит
d93840902b
|
@ -113,7 +113,6 @@ WeaveService.prototype = {
|
|||
let getHistogramById = Services.telemetry.getHistogramById;
|
||||
getHistogramById("WEAVE_CONFIGURED").add(isConfigured);
|
||||
if (isConfigured) {
|
||||
getHistogramById("WEAVE_CONFIGURED_MASTER_PASSWORD").add(Utils.mpEnabled());
|
||||
this.ensureLoaded();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,10 @@ XPCOMUtils.defineLazyGetter(this, "FxAccountsCommon", function() {
|
|||
return FxAccountsCommon;
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "cryptoSDR",
|
||||
"@mozilla.org/login-manager/crypto/SDR;1",
|
||||
"nsILoginManagerCrypto");
|
||||
|
||||
/*
|
||||
* Custom exception types.
|
||||
*/
|
||||
|
@ -480,36 +484,21 @@ this.Utils = {
|
|||
return function innerBind() { return method.apply(object, arguments); };
|
||||
},
|
||||
|
||||
/**
|
||||
* Is there a master password configured, regardless of current lock state?
|
||||
*/
|
||||
mpEnabled: function mpEnabled() {
|
||||
let tokenDB = Cc["@mozilla.org/security/pk11tokendb;1"]
|
||||
.getService(Ci.nsIPK11TokenDB);
|
||||
let token = tokenDB.getInternalKeyToken();
|
||||
return token.hasPassword;
|
||||
},
|
||||
|
||||
/**
|
||||
* Is there a master password configured and currently locked?
|
||||
*/
|
||||
mpLocked: function mpLocked() {
|
||||
let tokenDB = Cc["@mozilla.org/security/pk11tokendb;1"]
|
||||
.getService(Ci.nsIPK11TokenDB);
|
||||
let token = tokenDB.getInternalKeyToken();
|
||||
return token.hasPassword && !token.isLoggedIn();
|
||||
mpLocked() {
|
||||
return !cryptoSDR.isLoggedIn;
|
||||
},
|
||||
|
||||
// If Master Password is enabled and locked, present a dialog to unlock it.
|
||||
// Return whether the system is unlocked.
|
||||
ensureMPUnlocked: function ensureMPUnlocked() {
|
||||
if (!Utils.mpLocked()) {
|
||||
return true;
|
||||
ensureMPUnlocked() {
|
||||
if (cryptoSDR.uiBusy) {
|
||||
return false;
|
||||
}
|
||||
let sdr = Cc["@mozilla.org/security/sdr;1"]
|
||||
.getService(Ci.nsISecretDecoderRing);
|
||||
try {
|
||||
sdr.encryptString("bacon");
|
||||
cryptoSDR.encrypt("bacon");
|
||||
return true;
|
||||
} catch (e) {}
|
||||
return false;
|
||||
|
|
Загрузка…
Ссылка в новой задаче