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

Commit 1317c77

Browse files
darkdhdiracdeltas
authored andcommitted
Set Tor new identify
fix #12997 requires brave/muon@7e052dd Auditors: @bridiver, @diracdeltas
1 parent c30c613 commit 1317c77

File tree

5 files changed

+25
-4
lines changed

5 files changed

+25
-4
lines changed

app/common/commonMenu.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,8 @@ module.exports.newTorIdentityMenuItem = () => {
108108
return {
109109
label: locale.translation('newTorIdentity'),
110110
click: function (item, focusedWindow) {
111-
// TODO
112-
},
113-
enabled: false
111+
appActions.setTorNewIdentity()
112+
}
114113
}
115114
}
116115

app/filtering.js

+9
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,15 @@ module.exports.checkTorAvailable = () => {
701701
}, 500)
702702
}
703703

704+
module.exports.setTorNewIdentity = (url) => {
705+
const origin = getOrigin(url)
706+
const ses = session.fromPartition('persist:tor')
707+
if (!ses || !origin) {
708+
return
709+
}
710+
ses.setTorNewIdentity(origin)
711+
}
712+
704713
function initSession (ses, partition) {
705714
registeredSessions[partition] = ses
706715
ses.setEnableBrotli(true)

js/actions/appActions.js

+6
Original file line numberDiff line numberDiff line change
@@ -1968,6 +1968,12 @@ const appActions = {
19681968
dispatch({
19691969
actionType: appConstants.APP_CHECK_TOR_AVAILABLE
19701970
})
1971+
},
1972+
1973+
setTorNewIdentity: function () {
1974+
dispatch({
1975+
actionType: appConstants.APP_SET_TOR_NEW_IDENTITY
1976+
})
19711977
}
19721978
}
19731979

js/constants/appConstants.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,8 @@ const appConstants = {
198198
APP_CHECK_REFERRAL_ACTIVITY: _,
199199
APP_ON_REFERRAL_ACTIVITY: _,
200200
APP_ON_LEDGER_MEDIA_PUBLISHER: _,
201-
APP_CHECK_TOR_AVAILABLE: _
201+
APP_CHECK_TOR_AVAILABLE: _,
202+
APP_SET_TOR_NEW_IDENTITY: _
202203
}
203204

204205
module.exports = mapValuesByKeys(appConstants)

js/stores/appStore.js

+6
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,12 @@ const handleAppAction = (action) => {
391391
case appConstants.APP_CHECK_TOR_AVAILABLE:
392392
filtering.checkTorAvailable()
393393
break
394+
case appConstants.APP_SET_TOR_NEW_IDENTITY:
395+
const activeTab = tabState.getActiveTab(appState)
396+
if (activeTab) {
397+
filtering.setTorNewIdentity(activeTab.get('url'))
398+
}
399+
break
394400
case appConstants.APP_ON_CLEAR_BROWSING_DATA:
395401
const defaults = appState.get('clearBrowsingDataDefaults')
396402
const temp = appState.get('tempClearBrowsingData', Immutable.Map())

0 commit comments

Comments
 (0)