@@ -32,6 +32,7 @@ const P_CONTAINER_EDIT = "containerEdit";
32
32
const P_CONTAINER_DELETE = "containerDelete" ;
33
33
const P_CONTAINERS_ACHIEVEMENT = "containersAchievement" ;
34
34
const P_CONTAINER_ASSIGNMENTS = "containerAssignments" ;
35
+ const P_CLEAR_CONTAINER_STORAGE = "clearContainerStorage" ;
35
36
36
37
const P_MOZILLA_VPN_SERVER_LIST = "moz-vpn-server-list" ;
37
38
const P_ADVANCED_PROXY_SETTINGS = "advanced-proxy-settings-panel" ;
@@ -122,6 +123,19 @@ const Logic = {
122
123
123
124
} ,
124
125
126
+ notify ( i18nOpts ) {
127
+ const notificationCards = document . querySelectorAll ( ".popup-notification-card" ) ;
128
+ const text = browser . i18n . getMessage ( i18nOpts . messageId , i18nOpts . placeholders ) ;
129
+ notificationCards . forEach ( notificationCard => {
130
+ notificationCard . textContent = text ;
131
+ notificationCard . classList . add ( "is-shown" ) ;
132
+
133
+ setTimeout ( ( ) => {
134
+ notificationCard . classList . remove ( "is-shown" ) ;
135
+ } , 2000 ) ;
136
+ } ) ;
137
+ } ,
138
+
125
139
async showAchievementOrContainersListPanel ( ) {
126
140
// Do we need to show an achievement panel?
127
141
let showAchievements = false ;
@@ -971,6 +985,7 @@ Logic.registerPanel(P_CONTAINER_INFO, {
971
985
Utils . alwaysOpenInContainer ( identity ) ;
972
986
window . close ( ) ;
973
987
} ) ;
988
+
974
989
// Show or not the has-tabs section.
975
990
for ( let trHasTabs of document . getElementsByClassName ( "container-info-has-tabs" ) ) { // eslint-disable-line prefer-const
976
991
trHasTabs . style . display = ! identity . hasHiddenTabs && ! identity . hasOpenTabs ? "none" : "" ;
@@ -994,6 +1009,13 @@ Logic.registerPanel(P_CONTAINER_INFO, {
994
1009
Utils . addEnterHandler ( manageContainer , async ( ) => {
995
1010
Logic . showPanel ( P_CONTAINER_EDIT , identity ) ;
996
1011
} ) ;
1012
+ const clearContainerStorageButton = document . getElementById ( "clear-container-storage-info" ) ;
1013
+ Utils . addEnterHandler ( clearContainerStorageButton , async ( ) => {
1014
+ const granted = await browser . permissions . request ( { permissions : [ "browsingData" ] } ) ;
1015
+ if ( granted ) {
1016
+ Logic . showPanel ( P_CLEAR_CONTAINER_STORAGE , identity ) ;
1017
+ }
1018
+ } ) ;
997
1019
return this . buildOpenTabTable ( tabs ) ;
998
1020
} ,
999
1021
@@ -1455,11 +1477,14 @@ Logic.registerPanel(P_CONTAINER_ASSIGNMENTS, {
1455
1477
/* As we don't have the full or correct path the best we can assume is the path is HTTPS and then replace with a broken icon later if it doesn't load.
1456
1478
This is pending a better solution for favicons from web extensions */
1457
1479
const assumedUrl = `https://${ site . hostname } /favicon.ico` ;
1480
+ const resetSiteCookiesInfo = browser . i18n . getMessage ( "clearSiteCookiesTooltipInfo" ) ;
1481
+ const deleteSiteInfo = browser . i18n . getMessage ( "deleteSiteTooltipInfo" ) ;
1458
1482
trElement . innerHTML = Utils . escaped `
1459
1483
<td>
1460
1484
<div class="favicon"></div>
1461
1485
<span title="${ site . hostname } " class="menu-text truncate-text">${ site . hostname } </span>
1462
- <img class="trash-button delete-assignment" src="/img/container-delete.svg" />
1486
+ <img title="${ resetSiteCookiesInfo } " class="reset-button reset-assignment" src="/img/refresh-16.svg" />
1487
+ <img title="${ deleteSiteInfo } " class="trash-button delete-assignment" src="/img/container-delete.svg" />
1463
1488
</td>` ;
1464
1489
trElement . getElementsByClassName ( "favicon" ) [ 0 ] . appendChild ( Utils . createFavIconElement ( assumedUrl ) ) ;
1465
1490
const deleteButton = trElement . querySelector ( ".trash-button" ) ;
@@ -1471,6 +1496,20 @@ Logic.registerPanel(P_CONTAINER_ASSIGNMENTS, {
1471
1496
delete assignments [ siteKey ] ;
1472
1497
this . showAssignedContainers ( assignments ) ;
1473
1498
} ) ;
1499
+ const resetButton = trElement . querySelector ( ".reset-button" ) ;
1500
+ Utils . addEnterHandler ( resetButton , async ( ) => {
1501
+ const cookieStoreId = Logic . currentCookieStoreId ( ) ;
1502
+ const granted = await browser . permissions . request ( { permissions : [ "browsingData" ] } ) ;
1503
+ if ( ! granted ) {
1504
+ return ;
1505
+ }
1506
+ const result = await Utils . resetCookiesForSite ( site . hostname , cookieStoreId ) ;
1507
+ if ( result === true ) {
1508
+ Logic . notify ( { messageId : "cookiesClearedSuccess" , placeholders : [ site . hostname ] } ) ;
1509
+ } else {
1510
+ Logic . notify ( { messageId : "cookiesCouldNotBeCleared" , placeholders : [ site . hostname ] } ) ;
1511
+ }
1512
+ } ) ;
1474
1513
trElement . classList . add ( "menu-item" , "hover-highlight" , "keyboard-nav" ) ;
1475
1514
tableElement . appendChild ( trElement ) ;
1476
1515
} ) ;
@@ -2246,6 +2285,47 @@ Logic.registerPanel(P_MOZILLA_VPN_SERVER_LIST, {
2246
2285
}
2247
2286
} ) ;
2248
2287
2288
+ // P_CLEAR_CONTAINER_STORAGE: Page for confirming container storage removal.
2289
+ // ----------------------------------------------------------------------------
2290
+
2291
+ Logic . registerPanel ( P_CLEAR_CONTAINER_STORAGE , {
2292
+ panelSelector : "#clear-container-storage-panel" ,
2293
+
2294
+ // This method is called when the object is registered.
2295
+ initialize ( ) {
2296
+
2297
+ Utils . addEnterHandler ( document . querySelector ( "#clear-container-storage-cancel-link" ) , ( ) => {
2298
+ const identity = Logic . currentIdentity ( ) ;
2299
+ Logic . showPanel ( P_CONTAINER_INFO , identity , false , false ) ;
2300
+ } ) ;
2301
+ Utils . addEnterHandler ( document . querySelector ( "#close-clear-container-storage-panel" ) , ( ) => {
2302
+ const identity = Logic . currentIdentity ( ) ;
2303
+ Logic . showPanel ( P_CONTAINER_INFO , identity , false , false ) ;
2304
+ } ) ;
2305
+ Utils . addEnterHandler ( document . querySelector ( "#clear-container-storage-ok-link" ) , async ( ) => {
2306
+ const identity = Logic . currentIdentity ( ) ;
2307
+ const userContextId = Utils . userContextId ( identity . cookieStoreId ) ;
2308
+ const result = await browser . runtime . sendMessage ( {
2309
+ method : "deleteContainerDataOnly" ,
2310
+ message : { userContextId }
2311
+ } ) ;
2312
+ if ( result . done === true ) {
2313
+ Logic . notify ( { messageId : "storageWasClearedConfirmation" , placeholders : [ identity . name ] } ) ;
2314
+ }
2315
+ Logic . showPanel ( P_CONTAINER_INFO , identity , false , false ) ;
2316
+ } ) ;
2317
+ } ,
2318
+
2319
+ // This method is called when the panel is shown.
2320
+ prepare ( ) {
2321
+ const identity = Logic . currentIdentity ( ) ;
2322
+
2323
+ // Populating the panel: name, icon, and warning message
2324
+ document . getElementById ( "container-clear-storage-title" ) . textContent = identity . name ;
2325
+ return Promise . resolve ( null ) ;
2326
+ } ,
2327
+ } ) ;
2328
+
2249
2329
// P_CONTAINER_DELETE: Delete a container.
2250
2330
// ----------------------------------------------------------------------------
2251
2331
0 commit comments