[TabGuard] Keep track of anonymized requests.
This commit is contained in:
parent
3cf268e9df
commit
728f9ee9c0
|
@ -589,7 +589,7 @@ var RequestGuard = (() => {
|
|||
if (pending && pending.redirected && pending.redirected.url === request.url) {
|
||||
return lanRes; // don't go on stripping cookies if we're in a redirection loop
|
||||
}
|
||||
let chainNext = r => r === ABORT ? r : TabGuard.check(request);
|
||||
let chainNext = r => r === ABORT ? r : TabGuard.onSend(request);
|
||||
return lanRes instanceof Promise ? lanRes.then(chainNext) : chainNext(lanRes);
|
||||
},
|
||||
|
||||
|
@ -688,7 +688,7 @@ var RequestGuard = (() => {
|
|||
let {requestId, url, tabId, frameId, type} = request;
|
||||
if (type === "main_frame") {
|
||||
TabStatus.initTab(tabId);
|
||||
TabGuard.postCheck(request);
|
||||
TabGuard.onCleanup(request);
|
||||
}
|
||||
let scriptBlocked = request.responseHeaders.some(
|
||||
h => csp.isMine(h) && csp.blocks(h.value, "script")
|
||||
|
@ -721,11 +721,11 @@ var RequestGuard = (() => {
|
|||
}
|
||||
}
|
||||
}
|
||||
TabGuard.postCheck(request);
|
||||
TabGuard.onCleanup(request);
|
||||
},
|
||||
onErrorOccurred(request) {
|
||||
pendingRequests.delete(request.requestId);
|
||||
TabGuard.postCheck(request);
|
||||
TabGuard.onCleanup(request);
|
||||
}
|
||||
};
|
||||
function fakeRequestFromCSP(report, request) {
|
||||
|
|
|
@ -27,6 +27,8 @@ var TabGuard = (() => {
|
|||
anonymizedTabs.delete(tab.id);
|
||||
});
|
||||
|
||||
const anonymizedRequests = new Set();
|
||||
|
||||
let allowedGroups, filteredGroups;
|
||||
let forget = () => {
|
||||
allowedGroups = {};
|
||||
|
@ -53,10 +55,12 @@ var TabGuard = (() => {
|
|||
|
||||
return {
|
||||
forget,
|
||||
check(request) {
|
||||
onSend(request) {
|
||||
const mode = ns.sync.TabGuardMode;
|
||||
if (mode === "off" || !request.incognito && mode!== "global") return;
|
||||
|
||||
anonymizedRequests.delete(request.id);
|
||||
|
||||
const {tabId, type, url, originUrl} = request;
|
||||
|
||||
if (tabId < 0) return; // no tab, no party
|
||||
|
@ -160,6 +164,7 @@ var TabGuard = (() => {
|
|||
requestHeaders = requestHeaders.filter(h => !AUTH_HEADERS_RX.test(h.name));
|
||||
debug("[TabGuard] Removing auth headers from %o (%o)", request, requestHeaders);
|
||||
anonymizedTabs.set(tabId, {tabDomain, otherDomains: [...otherDomains]});
|
||||
anonymizedRequests.add(request.id);
|
||||
return {requestHeaders};
|
||||
};
|
||||
|
||||
|
@ -195,12 +200,16 @@ var TabGuard = (() => {
|
|||
return mustFilter ? filterAuth() : null;
|
||||
})();
|
||||
},
|
||||
postCheck(request) {
|
||||
onCleanup(request) {
|
||||
let {requestId, tabId} = request;
|
||||
if (scheduledCuts.has(requestId)) {
|
||||
scheduledCuts.delete(requestId);
|
||||
TabTies.cut(tabId);
|
||||
}
|
||||
anonymizedRequests.delete(request.id);
|
||||
},
|
||||
isAnonymizedRequest(requestId) {
|
||||
return anonymizedRequests.has(requestId);
|
||||
},
|
||||
isAnonymizedTab(tabId) {
|
||||
return anonymizedTabs.has(tabId);
|
||||
|
|
Loading…
Reference in New Issue