Bug 1611690 - sending a tab now prompts for a master-password. r=eoger

Differential Revision: https://phabricator.services.mozilla.com/D63440

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Mark Hammond 2020-02-20 04:11:41 +00:00
Родитель 2246aa1650
Коммит b83fb2379a
1 изменённых файлов: 20 добавлений и 0 удалений

Просмотреть файл

@ -791,6 +791,7 @@ var gSync = {
switchToTabHavingURI(url, true, { replaceQueryString: true }); switchToTabHavingURI(url, true, { replaceQueryString: true });
}, },
// Returns true if we managed to send the tab to any targets, false otherwise.
async sendTabToDevice(url, targets, title) { async sendTabToDevice(url, targets, title) {
const fxaCommandsDevices = []; const fxaCommandsDevices = [];
const oldSendTabClients = []; const oldSendTabClients = [];
@ -803,6 +804,25 @@ var gSync = {
console.error(`Target ${target.id} unsuitable for send tab.`); console.error(`Target ${target.id} unsuitable for send tab.`);
} }
} }
// If a master-password is enabled then it must be unlocked so FxA can get
// the encryption keys from the login manager. (If we end up using the "sync"
// fallback that would end up prompting by itself, but the FxA command route
// will not) - so force that here.
let cryptoSDR = Cc["@mozilla.org/login-manager/crypto/SDR;1"].getService(
Ci.nsILoginManagerCrypto
);
if (!cryptoSDR.isLoggedIn) {
if (cryptoSDR.uiBusy) {
console.log("Master password UI is busy - not sending the tabs");
return false;
}
try {
cryptoSDR.encrypt("bacon"); // forces the mp prompt.
} catch (e) {
console.log("Master password remains unlocked - not sending the tabs");
return false;
}
}
let numFailed = 0; let numFailed = 0;
if (fxaCommandsDevices.length) { if (fxaCommandsDevices.length) {
console.log( console.log(