diff --git a/src/confirm-page.html b/src/confirm-page.html index 259af1a..7822702 100644 --- a/src/confirm-page.html +++ b/src/confirm-page.html @@ -1,3 +1,4 @@ + diff --git a/src/js/background/assignManager.js b/src/js/background/assignManager.js index d98c462..a095922 100644 --- a/src/js/background/assignManager.js +++ b/src/js/background/assignManager.js @@ -169,6 +169,7 @@ window.assignManager = { this.storageArea.get(pageUrl).then((siteSettings) => { if (siteSettings) { siteSettings.neverAsk = true; + siteSettings.forceContainer = m.forceContainer; this.storageArea.set(pageUrl, siteSettings); } }).catch((e) => { @@ -323,7 +324,8 @@ window.assignManager = { tab.index + 1, tab.active, siteSettings.neverAsk, - openTabId + openTabId, + siteSettings.forceContainer ); } this.calculateContextMenu(tab); @@ -726,13 +728,31 @@ window.assignManager = { 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 loadPage = browser.runtime.getURL("confirm-page.html"); // 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) { - 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 { let confirmUrl = `${loadPage}?url=${this.encodeURLProperty(url)}&cookieStoreId=${cookieStoreId}`; let currentCookieStoreId; diff --git a/src/js/background/index.html b/src/js/background/index.html index 818dbb4..257c563 100644 --- a/src/js/background/index.html +++ b/src/js/background/index.html @@ -1,3 +1,4 @@ + diff --git a/src/js/confirm-page.js b/src/js/confirm-page.js index 21a445c..6379304 100644 --- a/src/js/confirm-page.js +++ b/src/js/confirm-page.js @@ -42,6 +42,7 @@ function confirmSubmit(redirectUrl, cookieStoreId) { browser.runtime.sendMessage({ method: "neverAsk", neverAsk: true, + forceContainer: true, pageUrl: redirectUrl }); } @@ -56,6 +57,16 @@ function getCurrentTab() { } 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(); await browser.runtime.sendMessage({ method: "exemptContainerAssignment", diff --git a/src/pageActionPopup.html b/src/pageActionPopup.html index ee3da9a..29abab6 100644 --- a/src/pageActionPopup.html +++ b/src/pageActionPopup.html @@ -1,3 +1,4 @@ + diff --git a/src/popup.html b/src/popup.html index be08642..b27f49d 100644 --- a/src/popup.html +++ b/src/popup.html @@ -1,3 +1,4 @@ +