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

Commit

Permalink
Open link in new private tab should use tor if enabled
Browse files Browse the repository at this point in the history
fix #14103

Test Plan:
1. make sure tor tabs is enabled
2. go to a link and right-click 'open in new private tab'
3. in the new private tab, go to check.torproject.org to make sure Tor
   is enabled
4. right click on the onion image, select 'open image in new tab'
5. in the new tab, go to check.torproect.org to make sure Tor is enabled

auditors: @darkdh
  • Loading branch information
diracdeltas committed Jun 8, 2018
1 parent 2c55028 commit 0820b3d
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 5 deletions.
2 changes: 2 additions & 0 deletions app/browser/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ const api = {
if (ses) {
isPrivate = ses.isOffTheRecord()
}
const isTor = isPrivate && settingsStore.getSetting(settings.USE_TOR_PRIVATE_TABS)

const frameOpts = {
location,
Expand All @@ -531,6 +532,7 @@ const api = {
guestInstanceId: newTab.guestInstanceId,
isPinned: !!newTabValue.get('pinned'),
isPrivate,
isTor,
openerTabId,
disposition,
index,
Expand Down
1 change: 1 addition & 0 deletions app/browser/windows.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ function openFramesInWindow (win, frames, activeFrameKey) {
url: frame.location || frame.src || frame.provisionalLocation || frame.url,
partitionNumber: frame.partitionNumber,
isPrivate: frame.isPrivate,
isTor: frame.isPrivate && getSetting(settings.USE_TOR_PRIVATE_TABS),
active: activeFrameKey ? frame.key === activeFrameKey : true,
discarded: frame.unloaded,
title: frame.title,
Expand Down
9 changes: 8 additions & 1 deletion app/renderer/reducers/contextMenuReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ const onTabPageMenu = function (state, action) {

const openInNewTabMenuItem = (url, isPrivate, partitionNumber, openerTabId) => {
const active = getSetting(settings.SWITCH_TO_NEW_TABS) === true
const isTor = isPrivate && getSetting(settings.USE_TOR_PRIVATE_TABS)
if (Array.isArray(url) && Array.isArray(partitionNumber)) {
return {
label: locale.translation('openInNewTabs'),
Expand All @@ -119,6 +120,7 @@ const openInNewTabMenuItem = (url, isPrivate, partitionNumber, openerTabId) => {
appActions.createTabRequested({
url: url[i],
isPrivate,
isTor,
partitionNumber: partitionNumber[i],
openerTabId,
active
Expand All @@ -133,6 +135,7 @@ const openInNewTabMenuItem = (url, isPrivate, partitionNumber, openerTabId) => {
appActions.createTabRequested({
url,
isPrivate,
isTor,
partitionNumber,
openerTabId,
active
Expand All @@ -144,6 +147,7 @@ const openInNewTabMenuItem = (url, isPrivate, partitionNumber, openerTabId) => {

const openInNewPrivateTabMenuItem = (url, openerTabId) => {
const active = getSetting(settings.SWITCH_TO_NEW_TABS) === true
const isTor = getSetting(settings.USE_TOR_PRIVATE_TABS)
if (Array.isArray(url)) {
return {
label: locale.translation('openInNewPrivateTabs'),
Expand All @@ -152,6 +156,7 @@ const openInNewPrivateTabMenuItem = (url, openerTabId) => {
appActions.createTabRequested({
url: url[i],
isPrivate: true,
isTor,
openerTabId,
active
})
Expand All @@ -165,6 +170,7 @@ const openInNewPrivateTabMenuItem = (url, openerTabId) => {
appActions.createTabRequested({
url,
isPrivate: true,
isTor,
openerTabId,
active
})
Expand Down Expand Up @@ -205,10 +211,11 @@ const openInNewSessionTabMenuItem = (url, openerTabId) => {
}

const openInNewWindowMenuItem = (location, isPrivate, partitionNumber) => {
const isTor = isPrivate && getSetting(settings.USE_TOR_PRIVATE_TABS)
return {
label: locale.translation('openInNewWindow'),
click: () => {
appActions.newWindow({ location, isPrivate, partitionNumber })
appActions.newWindow({ location, isPrivate, isTor, partitionNumber })
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion app/renderer/rendererShortcutHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,11 @@ function handleShortcut (frameKey, shortcut, e, args) {

if (sourceLocation !== null) {
const frame = frameStateUtil.getFrameByKey(windowStore.state, frameKey)
const isPrivate = frame.get('isPrivate', false)
appActions.createTabRequested({
url: sourceLocation,
isPrivate: frame.get('isPrivate', false),
isPrivate,
isTor: isPrivate && getSetting(settings.USE_TOR_PRIVATE_TABS),
partitionNumber: frame.get('partitionNumber'),
openerTabId: tabId,
active: true
Expand Down
20 changes: 17 additions & 3 deletions js/contextMenus.js
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,7 @@ function hamburgerTemplateInit (location, e) {
}

const openInNewTabMenuItem = (url, isPrivate, partitionNumber, openerTabId) => {
const isTor = isPrivate && getSetting(settings.USE_TOR_PRIVATE_TABS)
const active = getSetting(settings.SWITCH_TO_NEW_TABS) === true
if (Array.isArray(url) && Array.isArray(partitionNumber)) {
return {
Expand All @@ -744,6 +745,7 @@ const openInNewTabMenuItem = (url, isPrivate, partitionNumber, openerTabId) => {
appActions.createTabRequested({
url: url[i],
isPrivate,
isTor,
partitionNumber: partitionNumber[i],
openerTabId,
active
Expand All @@ -758,6 +760,7 @@ const openInNewTabMenuItem = (url, isPrivate, partitionNumber, openerTabId) => {
appActions.createTabRequested({
url,
isPrivate,
isTor,
partitionNumber,
openerTabId,
active
Expand All @@ -778,6 +781,7 @@ const openAllInNewTabsMenuItem = (folderDetail) => {

const openInNewPrivateTabMenuItem = (url, openerTabId) => {
const active = getSetting(settings.SWITCH_TO_NEW_TABS) === true
const isTor = getSetting(settings.USE_TOR_PRIVATE_TABS)
if (Array.isArray(url)) {
return {
label: locale.translation('openInNewPrivateTabs'),
Expand All @@ -786,6 +790,7 @@ const openInNewPrivateTabMenuItem = (url, openerTabId) => {
appActions.createTabRequested({
url: url[i],
isPrivate: true,
isTor,
openerTabId,
active
})
Expand All @@ -799,6 +804,7 @@ const openInNewPrivateTabMenuItem = (url, openerTabId) => {
appActions.createTabRequested({
url,
isPrivate: true,
isTor,
openerTabId,
active
})
Expand All @@ -808,10 +814,11 @@ const openInNewPrivateTabMenuItem = (url, openerTabId) => {
}

const openInNewWindowMenuItem = (location, isPrivate, partitionNumber) => {
const isTor = isPrivate && getSetting(settings.USE_TOR_PRIVATE_TABS)
return {
label: locale.translation('openInNewWindow'),
click: () => {
appActions.newWindow({ location, isPrivate, partitionNumber })
appActions.newWindow({ location, isPrivate, isTor, partitionNumber })
}
}
}
Expand Down Expand Up @@ -887,9 +894,12 @@ const searchSelectionMenuItem = (location) => {
let activeFrame = windowStore.getState().get('activeFrameKey')
let frame = windowStore.getFrame(activeFrame)
let searchUrl = appStoreRenderer.state.getIn(['searchDetail', 'searchURL']).replace('{searchTerms}', encodeURIComponent(location))
const isPrivate = frame.get('isPrivate')
const isTor = isPrivate && getSetting(settings.USE_TOR_PRIVATE_TABS)
appActions.createTabRequested({
url: searchUrl,
isPrivate: frame.get('isPrivate'),
isPrivate,
isTor,
partitionNumber: frame.get('partitionNumber'),
windowId: frame.get('windowId')
})
Expand Down Expand Up @@ -955,6 +965,7 @@ function mainTemplateInit (nodeProps, frame, tab) {
const isTextSelected = nodeProps.selectionText && nodeProps.selectionText.length > 0
const isAboutPage = aboutUrls.has(frame.get('location'))
const isPrivate = frame.get('isPrivate')
const isTor = isPrivate && getSetting(settings.USE_TOR_PRIVATE_TABS)

if (isLink) {
template = addLinkMenu(nodeProps.linkURL, frame)
Expand All @@ -972,7 +983,9 @@ function mainTemplateInit (nodeProps, frame, tab) {
appActions.createTabRequested({
url: nodeProps.srcURL,
openerTabId: frame.get('tabId'),
partition: frameStateUtil.getPartitionFromNumber(frame.get('partitionNumber'), isPrivate),
isPrivate,
isTor,
partitionNumber: frame.get('partitionNumber'),
active: active
})
}
Expand Down Expand Up @@ -1001,6 +1014,7 @@ function mainTemplateInit (nodeProps, frame, tab) {
appActions.createTabRequested({
url: searchUrl,
isPrivate,
isTor,
partitionNumber: frame.get('partitionNumber')
})
}
Expand Down

0 comments on commit 0820b3d

Please sign in to comment.