@@ -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' )
@@ -42,6 +43,7 @@ const tor = require('./tor')
42
43
43
44
let appStore = null
44
45
46
+ const tabMessageBox = require ( './browser/tabMessageBox' )
45
47
const beforeSendHeadersFilteringFns = [ ]
46
48
const beforeRequestFilteringFns = [ ]
47
49
const beforeRedirectFilteringFns = [ ]
@@ -119,6 +121,11 @@ function registerForBeforeRequest (session, partition) {
119
121
return
120
122
}
121
123
124
+ if ( ( isMagnetURL ( details ) ) && partition === appConfig . tor . partition ) {
125
+ showTorrentBlockedInTorWarning ( details )
126
+ return
127
+ }
128
+
122
129
const firstPartyUrl = module . exports . getMainFrameUrl ( details )
123
130
const url = details . url
124
131
// this can happen if the tab is closed and the webContents is no longer available
@@ -350,6 +357,16 @@ function registerForBeforeSendHeaders (session, partition) {
350
357
} )
351
358
}
352
359
360
+ function showTorrentBlockedInTorWarning ( details ) {
361
+ if ( details . tabId ) {
362
+ tabMessageBox . show ( details . tabId , {
363
+ message : `${ locale . translation ( 'torrentBlockedInTor' ) } ` ,
364
+ title : 'Brave' ,
365
+ buttons : [ locale . translation ( 'torrentWarningOk' ) ]
366
+ } )
367
+ }
368
+ }
369
+
353
370
/**
354
371
* Register for notifications for webRequest.onHeadersReceived for a particular
355
372
* session.
@@ -363,6 +380,10 @@ function registerForHeadersReceived (session, partition) {
363
380
muonCb ( { } )
364
381
return
365
382
}
383
+ if ( ( isTorrentFile ( details ) ) && partition === appConfig . tor . partition ) {
384
+ showTorrentBlockedInTorWarning ( details )
385
+ return
386
+ }
366
387
const firstPartyUrl = module . exports . getMainFrameUrl ( details )
367
388
// this can happen if the tab is closed and the webContents is no longer available
368
389
if ( ! firstPartyUrl ) {
0 commit comments