mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-27 12:36:14 +01:00
check for chrome.webRequest.onAuthRequired
avail
This commit is contained in:
parent
1ea07a6ced
commit
a260d269ec
@ -230,69 +230,71 @@ var bg_isBackground = true,
|
||||
}
|
||||
});
|
||||
|
||||
chrome.webRequest.onAuthRequired.addListener(function (details, callback) {
|
||||
if (!details.url || pendingAuthRequests.indexOf(details.requestId) != -1) {
|
||||
if (callback) {
|
||||
callback();
|
||||
if (chrome.webRequest && chrome.webRequest.onAuthRequired) {
|
||||
chrome.webRequest.onAuthRequired.addListener(function (details, callback) {
|
||||
if (!details.url || pendingAuthRequests.indexOf(details.requestId) != -1) {
|
||||
if (callback) {
|
||||
callback();
|
||||
}
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
var domain = bg_utilsService.getDomain(details.url);
|
||||
if (!domain) {
|
||||
if (callback) {
|
||||
callback();
|
||||
var domain = bg_utilsService.getDomain(details.url);
|
||||
if (!domain) {
|
||||
if (callback) {
|
||||
callback();
|
||||
}
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
pendingAuthRequests.push(details.requestId);
|
||||
pendingAuthRequests.push(details.requestId);
|
||||
|
||||
if (bg_utilsService.isFirefox()) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
if (bg_utilsService.isFirefox()) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
bg_loginService.getAllDecryptedForDomain(domain).then(function (logins) {
|
||||
if (!logins || logins.length !== 1) {
|
||||
reject();
|
||||
return;
|
||||
}
|
||||
|
||||
resolve({
|
||||
authCredentials: {
|
||||
username: logins[0].username,
|
||||
password: logins[0].password
|
||||
}
|
||||
});
|
||||
}, function () {
|
||||
reject();
|
||||
});
|
||||
});
|
||||
}
|
||||
else {
|
||||
bg_loginService.getAllDecryptedForDomain(domain).then(function (logins) {
|
||||
if (!logins || logins.length !== 1) {
|
||||
reject();
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
|
||||
resolve({
|
||||
callback({
|
||||
authCredentials: {
|
||||
username: logins[0].username,
|
||||
password: logins[0].password
|
||||
}
|
||||
});
|
||||
}, function () {
|
||||
reject();
|
||||
});
|
||||
});
|
||||
}
|
||||
else {
|
||||
bg_loginService.getAllDecryptedForDomain(domain).then(function (logins) {
|
||||
if (!logins || logins.length !== 1) {
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
|
||||
callback({
|
||||
authCredentials: {
|
||||
username: logins[0].username,
|
||||
password: logins[0].password
|
||||
}
|
||||
});
|
||||
}, function () {
|
||||
callback();
|
||||
});
|
||||
}
|
||||
}, { urls: ['http://*/*', 'https://*/*'] }, [bg_utilsService.isFirefox() ? 'blocking' : 'asyncBlocking']);
|
||||
}
|
||||
}, { urls: ['http://*/*', 'https://*/*'] }, [bg_utilsService.isFirefox() ? 'blocking' : 'asyncBlocking']);
|
||||
|
||||
chrome.webRequest.onCompleted.addListener(completeAuthRequest, { urls: ['http://*/*'] });
|
||||
chrome.webRequest.onErrorOccurred.addListener(completeAuthRequest, { urls: ['http://*/*'] });
|
||||
chrome.webRequest.onCompleted.addListener(completeAuthRequest, { urls: ['http://*/*'] });
|
||||
chrome.webRequest.onErrorOccurred.addListener(completeAuthRequest, { urls: ['http://*/*'] });
|
||||
|
||||
function completeAuthRequest(details) {
|
||||
var i = pendingAuthRequests.indexOf(details.requestId);
|
||||
if (i > -1) {
|
||||
pendingAuthRequests.splice(i, 1);
|
||||
function completeAuthRequest(details) {
|
||||
var i = pendingAuthRequests.indexOf(details.requestId);
|
||||
if (i > -1) {
|
||||
pendingAuthRequests.splice(i, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user