Skip to content
This repository has been archived by the owner on Jun 6, 2019. It is now read-only.

Commit

Permalink
Merge pull request #69 from pilgrim-brave/master
Browse files Browse the repository at this point in the history
Clear site cookies and local storage immediately on changing 'block cookies' setting to 'block'
  • Loading branch information
bbondy authored Oct 9, 2018
2 parents 0a62825 + daf5751 commit 4a7020e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
16 changes: 16 additions & 0 deletions app/background/reducers/shieldsPanelReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,22 @@ export default function shieldsPanelReducer (state: State = { tabs: {}, windows:
}
setAllowCookies(tabData.origin, action.setting)
.then(() => {
if (action.setting === 'block') {
chrome.cookies.getAll({ domain: tabData.origin },
function (cookies) {
cookies.forEach(function (cookie) {
chrome.cookies.remove({ 'url': 'http://' + cookie.domain + cookie.path, 'name': cookie.name })
chrome.cookies.remove({ 'url': 'https://' + cookie.domain + cookie.path, 'name': cookie.name })
})
}
)
chrome.tabs.executeScript(tabData.id, {
code: 'try { window.sessionStorage.clear(); } catch(e) {}'})
// clearing localStorage may fail with SecurityError if third-
// party cookies are already blocked, but that's okay
chrome.tabs.executeScript(tabData.id, {
code: 'try { window.localStorage.clear(); } catch(e) {}'})
}
requestShieldPanelData(shieldsPanelState.getActiveTabId(state))
reloadTab(tabData.id, true).catch(() => {
console.error('Tab reload was not successful')
Expand Down
2 changes: 1 addition & 1 deletion app/manifest.dev.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"all_frames": true
}
],
"permissions": [ "contentSettings", "management", "tabs", "storage", "webNavigation", "contextMenus", "*://*/*" ],
"permissions": [ "contentSettings", "management", "tabs", "storage", "webNavigation", "contextMenus", "cookies", "*://*/*" ],
"content_security_policy": "default-src 'self'; script-src 'self' http://localhost:3000 https://localhost:3000 'unsafe-eval'; connect-src http://localhost:3000 https://localhost:3000; style-src * 'unsafe-inline' 'self' blob:; img-src 'self' data:;",
"incognito": "split",
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAupOLMy5Fd4dCSOtjcApsAQOnuBdTs+OvBVt/3P93noIrf068x0xXkvxbn+fpigcqfNamiJ5CjGyfx9zAIs7zcHwbxjOw0Uih4SllfgtK+svNTeE0r5atMWE0xR489BvsqNuPSxYJUmW28JqhaSZ4SabYrRx114KcU6ko7hkjyPkjQa3P+chStJjIKYgu5tWBiMJp5QVLelKoM+xkY6S7efvJ8AfajxCViLGyDQPDviGr2D0VvIBob0D1ZmAoTvYOWafcNCaqaejPDybFtuLFX3pZBqfyOCyyzGhucyCmfBXJALKbhjRAqN5glNsUmGhhPK87TuGATQfVuZtenMvXMQIDAQAB"
Expand Down
2 changes: 1 addition & 1 deletion app/manifest.prod.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"all_frames": true
}
],
"permissions": [ "contentSettings", "management", "tabs", "storage", "webNavigation", "contextMenus", "*://*/*" ],
"permissions": [ "contentSettings", "management", "tabs", "storage", "webNavigation", "contextMenus", "cookies", "*://*/*" ],
"content_security_policy": "default-src 'self'; script-src 'self'; style-src 'unsafe-inline'; img-src 'self' data:;",
"incognito": "split",
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAupOLMy5Fd4dCSOtjcApsAQOnuBdTs+OvBVt/3P93noIrf068x0xXkvxbn+fpigcqfNamiJ5CjGyfx9zAIs7zcHwbxjOw0Uih4SllfgtK+svNTeE0r5atMWE0xR489BvsqNuPSxYJUmW28JqhaSZ4SabYrRx114KcU6ko7hkjyPkjQa3P+chStJjIKYgu5tWBiMJp5QVLelKoM+xkY6S7efvJ8AfajxCViLGyDQPDviGr2D0VvIBob0D1ZmAoTvYOWafcNCaqaejPDybFtuLFX3pZBqfyOCyyzGhucyCmfBXJALKbhjRAqN5glNsUmGhhPK87TuGATQfVuZtenMvXMQIDAQAB"
Expand Down

0 comments on commit 4a7020e

Please sign in to comment.