Skip to content
This repository was archived by the owner on Dec 11, 2019. It is now read-only.

add a cookie manager #11107

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions app/browser/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,15 @@ const createHistorySubmenu = () => {
click: function (item, focusedWindow) {
CommonMenu.sendToFocusedWindow(focusedWindow, [messages.SHORTCUT_OPEN_CLEAR_BROWSING_DATA_PANEL])
}
},
{
label: locale.translation('manageCookies'),
click: function (item, focusedWindow) {
appActions.createTabRequested({
url: 'about:cookies',
windowId: focusedWindow.id
})
}
}
]
const recentlyClosedItems = menuUtil.createRecentlyClosedTemplateItems(closedFrames)
Expand Down
7 changes: 7 additions & 0 deletions app/browser/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const historyState = require('../common/state/historyState')
const bookmarkOrderCache = require('../common/cache/bookmarkOrderCache')
const ledgerState = require('../common/state/ledgerState')
const {getWindow} = require('./windows')
const filtering = require('../filtering')

let currentPartitionNumber = 0
const incrementPartitionNumber = () => ++currentPartitionNumber
Expand Down Expand Up @@ -291,6 +292,12 @@ const updateAboutDetails = (tab, tabValue) => {
}
} else if (location === 'about:brave') {
tab.send(messages.VERSION_INFORMATION_UPDATED, versionInformation.toJS())
} else if (location === 'about:cookies') {
filtering.cookies.getAll((cookies) => {
if (!tab.isDestroyed()) {
tab.send(messages.COOKIES_UPDATED, cookies)
}
})
}
// send state to about pages
if (aboutUrls.get(location) && aboutDetails) {
Expand Down
21 changes: 21 additions & 0 deletions app/extensions/brave/about-cookies.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<html>
<head>
<meta charset="utf-8">
<meta name="availableLanguages" content="">
<meta name="defaultLanguage" content="en-US">
<meta name='theme-color' content='#ff5000'>
<meta name="referrer" content="no-referrer">
<link rel="shortcut icon"type="image/x-icon" href="img/favicon.ico">
<title data-l10n-id="cookiesTitle"></title>
<script src="ext/l20n.min.js"></script>
<script src="gen/aboutPages.entry.js" async></script>
<link rel="localization" href="locales/{locale}/cookies.properties">
</head>
<body>
<div id="appContainer"/>
</body>
</html>
3 changes: 3 additions & 0 deletions app/extensions/brave/locales/en-US/cookies.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
noCookiesSaved=No cookies saved
cookiesTitle=Manage Cookies
clearCookies=Delete all cookies
7 changes: 6 additions & 1 deletion app/extensions/brave/locales/en-US/menu.properties
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ cleanReload=Clean Reload
clearBrowsingData=Clear Browsing Data…
clearCache=Clear Cache…
clearHistory=Clear History…
manageCookies=Manage Cookies…
clearSiteData=Clear All Cookies and Site Data…
clone=Clone
closeOtherTabs=Close other Tabs
closeTab=Close
closeTabPage=Close tab page
closeWindow=Close Window
copy=Copy
copyToClipboard=Copy to clipboard
copyEmailAddress=Copy Email Address
copyImage=Copy Image
copyImageAddress=Copy Image Address
Expand All @@ -46,6 +48,8 @@ cut=Cut
delete=Delete
deleteBookmark=Delete Bookmark
deleteBookmarks=Delete Selected Bookmarks
deleteCookie=Delete Cookie
deleteCookies=Delete Selected Cookies
deleteFolder=Delete Folder
deleteHistoryEntries=Delete Selected History Entries
deleteHistoryEntry=Delete History Entry
Expand All @@ -68,6 +72,7 @@ downloadsManager=Downloads…
downloadToolbarHide=Hide downloads bar
edit=Edit
editBookmark=Edit Bookmark…
editCookie=Edit cookie…
editFolder=Edit Folder…
emailPageLink=Email Page Link…
exportBookmarks=Export Bookmarks…
Expand Down Expand Up @@ -172,4 +177,4 @@ window=Window
zoom=Zoom
zoom=Zoom
zoomIn=Zoom In
zoomOut=Zoom Out
zoomOut=Zoom Out
1 change: 1 addition & 0 deletions app/extensions/brave/locales/en-US/preferences.properties
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ loveToHear=We'd love to hear from you.
manageAdblockSettings=Manage Adblock Settings…
manageAutofillData=Manage Autofill Data…
managePasswords=Manage passwords…
manageCookies=Manage cookies…
mediaPermission=Camera and microphone access
midiSysexPermission=Use web MIDI
minimumPageTimeHigh=1 minute
Expand Down
28 changes: 28 additions & 0 deletions app/filtering.js
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,34 @@ module.exports.isResourceEnabled = (resourceName, url, isPrivate) => {
return false
}

/**
* Cookie methods
*/
module.exports.cookies = {
getAll: (cb) => {
const cookiesMap = {}
for (let partition in registeredSessions) {
const ses = registeredSessions[partition]
ses.cookies.get({}, (error, cookies) => {
if (error) { console.error(error) }
cookiesMap[partition] = cookies
if (Object.keys(cookiesMap).length ===
Object.keys(registeredSessions).length) {
cb(cookiesMap)
}
})
}
},
remove: (url, name, partition, cb) => {
const ses = registeredSessions[partition]
if (ses) {
ses.cookies.remove(url, name, cb || function () {})
} else {
console.error('No session to remove cookies for: ' + partition)
}
}
}

/**
* Clears all storage data.
* This includes: appcache, cookies, filesystem, indexdb, local storage,
Expand Down
4 changes: 4 additions & 0 deletions app/locale.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ var rendererIdentifiers = function () {
'deleteFolder',
'deleteBookmark',
'deleteBookmarks',
'deleteCookie',
'deleteCookies',
'deleteHistoryEntry',
'deleteHistoryEntries',
'deleteLedgerEntry',
Expand All @@ -66,6 +68,7 @@ var rendererIdentifiers = function () {
'ledgerBackupText3',
'ledgerBackupText4',
'ledgerBackupText5',
'editCookie', // not yet implemented
'editFolder',
'editBookmark',
'unmuteTabs',
Expand Down Expand Up @@ -130,6 +133,7 @@ var rendererIdentifiers = function () {
'clearHistory',
'clearSiteData',
'clearBrowsingData',
'manageCookies',
'recentlyClosed',
'recentlyVisited',
'bookmarks',
Expand Down
2 changes: 1 addition & 1 deletion app/renderer/components/common/sectionTitle.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const styles = StyleSheet.create({
sectionTitleWrapper: {
marginBottom: '0.7rem',
display: 'flex',
alignItems: 'flex-end'
alignItems: 'baseline'
},

sectionTitle: {
Expand Down
18 changes: 17 additions & 1 deletion app/renderer/components/common/sortableTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
const React = require('react')
const Immutable = require('immutable')
const tableSort = require('tablesort')
const KeyCodes = require('../../../common/constants/keyCodes')

const {StyleSheet, css} = require('aphrodite/no-important')
const globalStyles = require('../styles/global')
Expand All @@ -26,6 +27,7 @@ class SortableTable extends React.Component {
super(props)
this.onClick = this.onClick.bind(this)
this.onContextMenu = this.onContextMenu.bind(this)
this.onKeyDown = this.onKeyDown.bind(this)
this.onTableDragStart = this.onTableDragStart.bind(this)
this.state = {
selection: Immutable.Set()
Expand All @@ -41,6 +43,7 @@ class SortableTable extends React.Component {
if (this.props.rows &&
(!prevProps.rows ||
prevProps.rows.length !== this.props.rows.length)) {
this.clearSelection()
this.sortTable.refresh()
}
}
Expand Down Expand Up @@ -228,7 +231,17 @@ class SortableTable extends React.Component {
} else {
this.props.onContextMenu(handlerInputs, this.props.contextMenuName, e)
}
this.clearSelection()
}
}
/**
* Handle keydown
*/
onKeyDown (e) {
if (e.keyCode === KeyCodes.BACKSPACE && this.props.onDelete) {
const handlerInputs = this.getSelectedRowObjects()
if (handlerInputs) {
this.props.onDelete(handlerInputs)
}
}
}
/**
Expand Down Expand Up @@ -300,6 +313,8 @@ class SortableTable extends React.Component {
tableAttributes.draggable = true
}
}
tableAttributes.tabIndex = 0
tableAttributes.onKeyDown = this.onKeyDown
return tableAttributes
}
getRowAttributes (row, index, bodyIndex) {
Expand Down Expand Up @@ -508,6 +523,7 @@ const styles = StyleSheet.create({
// It can be specified by setting css to tableClassNames.
// See 'styles.devices__devicesList' on syncTab.js for example.
table: {
outline: 'none',
boxSizing: 'border-box',
cursor: 'default',
borderSpacing: 0,
Expand Down
7 changes: 7 additions & 0 deletions js/about/aboutActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,13 @@ const aboutActions = {
})
},

removeCookies: function (cookies) {
aboutActions.dispatchAction({
actionType: appConstants.APP_REMOVE_COOKIES,
cookies
})
},

setResourceEnabled: function (resourceName, enabled) {
aboutActions.dispatchAction({
actionType: appConstants.APP_SET_RESOURCE_ENABLED,
Expand Down
Loading