Merge pull request #2649 from mozilla/2263-always-open-in-container-bug

Remember choice for default containers in the "Always open in" confirm page
This commit is contained in:
luke crouch 2024-08-27 13:47:53 -05:00 committed by GitHub
commit 077c7e08c8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 26 additions and 3 deletions

View file

@ -165,11 +165,17 @@ window.assignManager = {
_neverAsk(m) {
const pageUrl = m.pageUrl;
if (m.neverAsk === true) {
if (m.defaultContainer === true) {
this.storageArea.remove(pageUrl);
return;
}
// If we have existing data and for some reason it hasn't been
// deleted etc lets update it
this.storageArea.get(pageUrl).then((siteSettings) => {
if (siteSettings) {
siteSettings.neverAsk = true;
siteSettings.userContextId = backgroundLogic.getUserContextIdFromCookieStoreId(m.cookieStoreId);
this.storageArea.set(pageUrl, siteSettings);
}
}).catch((e) => {

View file

@ -7,14 +7,16 @@ async function load() {
redirectUrlElement.textContent = redirectUrl;
appendFavicon(redirectUrl, redirectUrlElement);
// Option for staying on the previous container
document.getElementById("deny").addEventListener("click", (e) => {
e.preventDefault();
denySubmit(redirectUrl);
denySubmit(redirectUrl, currentCookieStoreId);
});
// Option for going to the default container (no container)
document.getElementById("deny-no-container").addEventListener("click", (e) => {
e.preventDefault();
denySubmit(redirectUrl);
denySubmit(redirectUrl, currentCookieStoreId);
});
const container = await browser.contextualIdentities.get(cookieStoreId);
@ -27,6 +29,7 @@ async function load() {
el.textContent = browser.i18n.getMessage(elementData.messageId, containerName);
});
// Option for going to newly selected container
document.getElementById("confirm").addEventListener("click", (e) => {
e.preventDefault();
confirmSubmit(redirectUrl, cookieStoreId);
@ -59,6 +62,7 @@ function confirmSubmit(redirectUrl, cookieStoreId) {
browser.runtime.sendMessage({
method: "neverAsk",
neverAsk: true,
cookieStoreId: cookieStoreId,
pageUrl: redirectUrl
});
}
@ -72,8 +76,21 @@ function getCurrentTab() {
});
}
async function denySubmit(redirectUrl) {
async function denySubmit(redirectUrl, currentCookieStoreId) {
const tab = await getCurrentTab();
const currentContainer = currentCookieStoreId ? await browser.contextualIdentities.get(currentCookieStoreId) : null;
const neverAsk = document.getElementById("never-ask").checked;
if (neverAsk) {
await browser.runtime.sendMessage({
method: "neverAsk",
neverAsk: true,
cookieStoreId: currentCookieStoreId,
pageUrl: redirectUrl,
defaultContainer: !currentContainer
});
}
await browser.runtime.sendMessage({
method: "exemptContainerAssignment",
tabId: tab[0].id,