handle changing permissions better
This commit is contained in:
parent
609397d95a
commit
848f44733e
@ -498,6 +498,7 @@ try {
|
||||
function headerListener(
|
||||
details: chrome.webRequest.WebResponseHeadersDetails,
|
||||
): chrome.webRequest.BlockingResponse | undefined {
|
||||
console.log("header listener");
|
||||
if (chrome.runtime.lastError) {
|
||||
console.error(chrome.runtime.lastError);
|
||||
return;
|
||||
@ -507,6 +508,7 @@ function headerListener(
|
||||
console.warn("wallet not available while handling header");
|
||||
return;
|
||||
}
|
||||
console.log("in header listener");
|
||||
if (details.statusCode === 402 || details.statusCode === 202) {
|
||||
console.log(`got 402/202 from ${details.url}`);
|
||||
for (const header of details.responseHeaders || []) {
|
||||
@ -572,12 +574,29 @@ function headerListener(
|
||||
}
|
||||
|
||||
function setupHeaderListener(): void {
|
||||
console.log("setting up header listener");
|
||||
// Handlers for catching HTTP requests
|
||||
chrome.webRequest.onHeadersReceived.addListener(
|
||||
headerListener,
|
||||
{ urls: ["https://*/*", "http://*/*"] },
|
||||
["responseHeaders", "blocking"],
|
||||
);
|
||||
chrome.permissions.contains(extendedPermissions, (result: boolean) => {
|
||||
if (
|
||||
chrome.webRequest.onHeadersReceived &&
|
||||
chrome.webRequest.onHeadersReceived.hasListener(headerListener)
|
||||
) {
|
||||
chrome.webRequest.onHeadersReceived.removeListener(headerListener);
|
||||
}
|
||||
if (result) {
|
||||
console.log("actually adding listener");
|
||||
chrome.webRequest.onHeadersReceived.addListener(
|
||||
headerListener,
|
||||
{ urls: ["<all_urls>"] },
|
||||
["responseHeaders", "blocking"],
|
||||
);
|
||||
}
|
||||
chrome.webRequest.handlerBehaviorChanged(() => {
|
||||
if (chrome.runtime.lastError) {
|
||||
console.error(chrome.runtime.lastError);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -602,4 +621,12 @@ export async function wxMain(): Promise<void> {
|
||||
});
|
||||
|
||||
setupHeaderListener();
|
||||
|
||||
chrome.permissions.onAdded.addListener((perm) => {
|
||||
if (chrome.runtime.lastError) {
|
||||
console.error(chrome.runtime.lastError);
|
||||
return;
|
||||
}
|
||||
setupHeaderListener();
|
||||
});
|
||||
}
|
||||
|
@ -4,8 +4,8 @@
|
||||
"name": "GNU Taler Wallet (git)",
|
||||
"description": "Privacy preserving and transparent payments",
|
||||
"author": "GNU Taler Developers",
|
||||
"version": "0.6.75",
|
||||
"version_name": "0.6.0pre10",
|
||||
"version": "0.6.77.1",
|
||||
"version_name": "0.7.0.dev.1",
|
||||
|
||||
"minimum_chrome_version": "51",
|
||||
"minimum_opera_version": "36",
|
||||
|
Loading…
Reference in New Issue
Block a user