diff --git a/src/_locales b/src/_locales index 417e629..1b944a2 160000 --- a/src/_locales +++ b/src/_locales @@ -1 +1 @@ -Subproject commit 417e6294ed767914b617a5e56ccbe67482df181c +Subproject commit 1b944a2cbd8577c8ca928729ff1439dd30ce8269 diff --git a/src/js/background/backgroundLogic.js b/src/js/background/backgroundLogic.js index 1050d40..90b41a4 100644 --- a/src/js/background/backgroundLogic.js +++ b/src/js/background/backgroundLogic.js @@ -81,6 +81,25 @@ const backgroundLogic = { return {done: true, userContextId}; }, + // Remove container data (cookies, localStorage and cache) + async deleteContainerDataOnly(userContextId) { + await this._closeTabs(userContextId); + + await browser.browsingData.removeCookies({ + cookieStoreId: this.cookieStoreId(userContextId) + }); + + await browser.browsingData.removeLocalStorage({ + cookieStoreId: this.cookieStoreId(userContextId) + }); + + await browser.browsingData.removeCache({ + cookieStoreId: this.cookieStoreId(userContextId) + }); + + return {done: true, userContextId}; + }, + async createOrUpdateContainer(options) { if (options.userContextId !== "new") { return await browser.contextualIdentities.update( diff --git a/src/js/background/messageHandler.js b/src/js/background/messageHandler.js index 5d644b6..03a25cc 100644 --- a/src/js/background/messageHandler.js +++ b/src/js/background/messageHandler.js @@ -23,6 +23,9 @@ const messageHandler = { case "deleteContainer": response = backgroundLogic.deleteContainer(m.message.userContextId); break; + case "deleteContainerDataOnly": + response = backgroundLogic.deleteContainerDataOnly(m.message.userContextId); + break; case "createOrUpdateContainer": response = backgroundLogic.createOrUpdateContainer(m.message); break; @@ -90,10 +93,10 @@ const messageHandler = { break; case "assignAndReloadInContainer": tab = await assignManager.reloadPageInContainer( - m.url, + m.url, m.currentUserContextId, - m.newUserContextId, - m.tabIndex, + m.newUserContextId, + m.tabIndex, m.active, true ); diff --git a/src/js/popup.js b/src/js/popup.js index b8f80ff..3d41d74 100644 --- a/src/js/popup.js +++ b/src/js/popup.js @@ -940,6 +940,19 @@ Logic.registerPanel(P_CONTAINER_INFO, { Utils.alwaysOpenInContainer(identity); window.close(); }); + + const deleteData = document.querySelector("#delete-data-info-panel"); + Utils.addEnterHandler(deleteData, async () => { + const userContextId = Utils.userContextId(identity.cookieStoreId) + + await browser.runtime.sendMessage({ + method: "deleteContainerDataOnly", + message: { userContextId } + }); + + window.close(); + }); + // Show or not the has-tabs section. for (let trHasTabs of document.getElementsByClassName("container-info-has-tabs")) { // eslint-disable-line prefer-const trHasTabs.style.display = !identity.hasHiddenTabs && !identity.hasOpenTabs ? "none" : ""; diff --git a/src/manifest.json b/src/manifest.json index e0f9765..e78430c 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -12,6 +12,7 @@ "permissions": [ "", "activeTab", + "browsingData", "cookies", "contextMenus", "contextualIdentities", diff --git a/src/popup.html b/src/popup.html index ef22e94..ea4914d 100644 --- a/src/popup.html +++ b/src/popup.html @@ -245,6 +245,16 @@ + + + + + Delete data + + + + +