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

Commit

Permalink
Merge pull request #9702 from brave/issue-9701
Browse files Browse the repository at this point in the history
only send ipc messages to the hostWebContents of the tab that generat…
  • Loading branch information
bsclifton authored Jun 30, 2017
2 parents 1c74191 + cb9afe6 commit 8fde201
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions app/filtering.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ function registerForBeforeRequest (session, partition) {
continue
}
if (results.cancel) {
// We have no good way of knowing which BrowserWindow the blocking is for
// yet so send it everywhere and let listeners decide how to respond.
let message = details.resourceType === 'mainFrame'
? messages.BLOCKED_PAGE
: messages.BLOCKED_RESOURCE
Expand All @@ -137,11 +135,16 @@ function registerForBeforeRequest (session, partition) {
appActions.addResourceCount(parentResourceName, 1)
}

BrowserWindow.getAllWindows().forEach((wnd) =>
wnd.webContents.send(message, parentResourceName, {
tabId: details.tabId,
url: details.url
}))
// TODO(bridiver) - convert to appActions/appState
setImmediate(() => {
const tab = webContents.fromTabID(details.tabId)
if (tab && tab.hostWebContents) {
tab.hostWebContents.send(message, parentResourceName, {
tabId: details.tabId,
url: details.url
})
}
})

if (parentResourceName === appConfig.resourceNames.SAFE_BROWSING) {
let redirectURL = appUrlUtil.getTargetAboutUrl('about:safebrowsing#' + details.url)
Expand All @@ -167,11 +170,16 @@ function registerForBeforeRequest (session, partition) {
if (isHttpsEverywhere) {
appActions.addResourceCount(results.resourceName, 1)
}
BrowserWindow.getAllWindows().forEach((wnd) =>
wnd.webContents.send(messages.HTTPSE_RULE_APPLIED, results.ruleset, {
tabId: details.tabId,
url: details.url
}))
// TODO(bridiver) - convert to appActions/appState
setImmediate(() => {
const tab = webContents.fromTabID(details.tabId)
if (tab && tab.hostWebContents) {
tab.hostWebContents.send(messages.HTTPSE_RULE_APPLIED, results.ruleset, {
tabId: details.tabId,
url: details.url
})
}
})
}
cb({redirectURL: results.redirectURL})
return
Expand Down

0 comments on commit 8fde201

Please sign in to comment.