Remember to NOT use the assigned container

This commit is contained in:
Pavel Peganov 2022-02-13 02:58:49 +03:00
parent cdd8ebc66a
commit 33306a3a5b
No known key found for this signature in database
GPG key ID: 923ADD86063E2C28
6 changed files with 39 additions and 4 deletions

View file

@ -1,3 +1,4 @@
<!DOCTYPE html>
<html> <html>
<head> <head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta http-equiv="content-type" content="text/html; charset=utf-8">

View file

@ -169,6 +169,7 @@ window.assignManager = {
this.storageArea.get(pageUrl).then((siteSettings) => { this.storageArea.get(pageUrl).then((siteSettings) => {
if (siteSettings) { if (siteSettings) {
siteSettings.neverAsk = true; siteSettings.neverAsk = true;
siteSettings.forceContainer = m.forceContainer;
this.storageArea.set(pageUrl, siteSettings); this.storageArea.set(pageUrl, siteSettings);
} }
}).catch((e) => { }).catch((e) => {
@ -323,7 +324,8 @@ window.assignManager = {
tab.index + 1, tab.index + 1,
tab.active, tab.active,
siteSettings.neverAsk, siteSettings.neverAsk,
openTabId openTabId,
siteSettings.forceContainer
); );
} }
this.calculateContextMenu(tab); this.calculateContextMenu(tab);
@ -726,13 +728,31 @@ window.assignManager = {
browser.tabs.create({url, cookieStoreId, index, active, openerTabId}); browser.tabs.create({url, cookieStoreId, index, active, openerTabId});
}, },
reloadPageInContainer(url, currentUserContextId, userContextId, index, active, neverAsk = false, openerTabId = null) { reloadPageInContainer(url, currentUserContextId, userContextId, index, active, neverAsk = false, openerTabId = null, forceContainer = true) {
const cookieStoreId = backgroundLogic.cookieStoreId(userContextId); const cookieStoreId = backgroundLogic.cookieStoreId(userContextId);
const loadPage = browser.runtime.getURL("confirm-page.html"); const loadPage = browser.runtime.getURL("confirm-page.html");
// False represents assignment is not permitted // False represents assignment is not permitted
// If the user has explicitly checked "Never Ask Again" on the warning page we will send them straight there // If the user has explicitly checked "Never Ask Again" on the warning page we will:
// - If the user confirmed the use of assigned container, we use that
// - If the user denied the use of assigned container, we keep what they have
//
// As-is this behaviour then never makes use of the container assignment for links
// opened from the outside, so there's one exception: when a tab is opened without
// a currentUserContextId (and it *is* missing in outside links), it's forced
// into the assigned container despite forceContainer: false
if (neverAsk) { if (neverAsk) {
return browser.tabs.create({url, cookieStoreId, index, active, openerTabId}); let currentCookieStoreId;
if (currentUserContextId) {
currentCookieStoreId = backgroundLogic.cookieStoreId(currentUserContextId);
}
let desiredCookieStoreId;
if (forceContainer || !currentCookieStoreId) {
desiredCookieStoreId = cookieStoreId;
} else {
this.setExempted(url, index);
desiredCookieStoreId = currentCookieStoreId;
}
return browser.tabs.create({url, cookieStoreId: desiredCookieStoreId, index, active, openerTabId});
} else { } else {
let confirmUrl = `${loadPage}?url=${this.encodeURLProperty(url)}&cookieStoreId=${cookieStoreId}`; let confirmUrl = `${loadPage}?url=${this.encodeURLProperty(url)}&cookieStoreId=${cookieStoreId}`;
let currentCookieStoreId; let currentCookieStoreId;

View file

@ -1,3 +1,4 @@
<!DOCTYPE html>
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">

View file

@ -42,6 +42,7 @@ function confirmSubmit(redirectUrl, cookieStoreId) {
browser.runtime.sendMessage({ browser.runtime.sendMessage({
method: "neverAsk", method: "neverAsk",
neverAsk: true, neverAsk: true,
forceContainer: true,
pageUrl: redirectUrl pageUrl: redirectUrl
}); });
} }
@ -56,6 +57,16 @@ function getCurrentTab() {
} }
async function denySubmit(redirectUrl) { async function denySubmit(redirectUrl) {
const neverAsk = document.getElementById("never-ask").checked;
// Sending neverAsk message to background to store for next time we see this process
if (neverAsk) {
browser.runtime.sendMessage({
method: "neverAsk",
neverAsk: true,
forceContainer: false,
pageUrl: redirectUrl
});
}
const tab = await getCurrentTab(); const tab = await getCurrentTab();
await browser.runtime.sendMessage({ await browser.runtime.sendMessage({
method: "exemptContainerAssignment", method: "exemptContainerAssignment",

View file

@ -1,3 +1,4 @@
<!DOCTYPE html>
<html> <html>
<head> <head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta http-equiv="content-type" content="text/html; charset=utf-8">

View file

@ -1,3 +1,4 @@
<!DOCTYPE html>
<html> <html>
<head> <head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta http-equiv="content-type" content="text/html; charset=utf-8">