@@ -28,6 +28,7 @@ const ipcMain = electron.ipcMain
28
28
const app = electron . app
29
29
const path = require ( 'path' )
30
30
const getOrigin = require ( '../js/lib/urlutil' ) . getOrigin
31
+ const { isTorrentFile, isMagnetURL} = require ( './browser/webtorrent' )
31
32
const { adBlockResourceName} = require ( './adBlock' )
32
33
const { updateElectronDownloadItem} = require ( './browser/electronDownloadItem' )
33
34
const { fullscreenOption} = require ( './common/constants/settingsEnums' )
@@ -41,6 +42,7 @@ const tor = require('./tor')
41
42
42
43
let appStore = null
43
44
45
+ const tabMessageBox = require ( './browser/tabMessageBox' )
44
46
const beforeSendHeadersFilteringFns = [ ]
45
47
const beforeRequestFilteringFns = [ ]
46
48
const beforeRedirectFilteringFns = [ ]
@@ -118,6 +120,11 @@ function registerForBeforeRequest (session, partition) {
118
120
return
119
121
}
120
122
123
+ if ( ( isMagnetURL ( details ) ) && partition === appConfig . tor . partition ) {
124
+ showTorrentBlockedInTorWarning ( details )
125
+ return
126
+ }
127
+
121
128
const firstPartyUrl = module . exports . getMainFrameUrl ( details )
122
129
const url = details . url
123
130
// this can happen if the tab is closed and the webContents is no longer available
@@ -349,6 +356,17 @@ function registerForBeforeSendHeaders (session, partition) {
349
356
} )
350
357
}
351
358
359
+ function showTorrentBlockedInTorWarning ( details ) {
360
+ if ( details . tabId ) {
361
+ tabMessageBox . show ( details . tabId , {
362
+ message : `${ locale . translation ( 'torrentBlockedInTor' ) } ` ,
363
+ title : 'Brave' ,
364
+ buttons : [ locale . translation ( 'torrentWarningOk' ) ]
365
+ } )
366
+ return
367
+ }
368
+ }
369
+
352
370
/**
353
371
* Register for notifications for webRequest.onHeadersReceived for a particular
354
372
* session.
@@ -362,6 +380,10 @@ function registerForHeadersReceived (session, partition) {
362
380
muonCb ( { } )
363
381
return
364
382
}
383
+ if ( ( isTorrentFile ( details ) ) && partition === appConfig . tor . partition ) {
384
+ showTorrentBlockedInTorWarning ( details )
385
+ return
386
+ }
365
387
const firstPartyUrl = module . exports . getMainFrameUrl ( details )
366
388
// this can happen if the tab is closed and the webContents is no longer available
367
389
if ( ! firstPartyUrl ) {
0 commit comments