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

Commit

Permalink
Merge pull request #14709 from brave/fix/tor-bookmarks
Browse files Browse the repository at this point in the history
Block tab.loadURL in tor tabs until tor is initialized
  • Loading branch information
bsclifton authored Jul 11, 2018
2 parents e78fc93 + bef471d commit 1cf53e1
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions app/browser/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,18 @@ const getPartitionNumber = (partition) => {
return Number(partition.split('persist:partition-')[1] || 0)
}

const shouldWaitForTorLoad = (webContents, appState) => {
if (webContents &&
webContents.session &&
webContents.session.partition === appConfig.tor.partition) {
appState = appState || appStore.getState()
if (appState.getIn(['tor', 'online']) !== true) {
console.log('Blocking page load until Tor tab is initialized')
return true
}
}
}

/**
* Obtains the current partition.
* Warning: This function has global side effects in that it increments the
Expand Down Expand Up @@ -905,6 +917,9 @@ const api = {
action = makeImmutable(action)
const tabId = action.get('tabId')
const tab = webContentsCache.getWebContents(tabId)
if (shouldWaitForTorLoad(tab)) {
return
}
if (tab && !tab.isDestroyed()) {
const url = normalizeUrl(action.get('url'))
const currentUrl = tab.getURL()
Expand Down Expand Up @@ -944,6 +959,9 @@ const api = {

loadURLInTab: (state, tabId, url) => {
const tab = webContentsCache.getWebContents(tabId)
if (shouldWaitForTorLoad(tab)) {
return
}
if (tab && !tab.isDestroyed()) {
url = normalizeUrl(url)
tab.loadURL(url)
Expand Down

0 comments on commit 1cf53e1

Please sign in to comment.