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

Commit

Permalink
Don't push more than possible for permissionTypes
Browse files Browse the repository at this point in the history
This addresses review feedback for #10864
  • Loading branch information
bbondy committed Sep 13, 2017
1 parent cd968b7 commit cb4c6d3
Showing 1 changed file with 20 additions and 26 deletions.
46 changes: 20 additions & 26 deletions app/filtering.js
Original file line number Diff line number Diff line change
Expand Up @@ -450,41 +450,35 @@ function registerPermissionHandler (session, partition) {
let response = []
for (let i = 0; i < permissionTypes.length; i++) {
const permission = permissionTypes[i]
const alwaysAllowFullscreen = module.exports.alwaysAllowFullscreen() === fullscreenOption.ALWAYS_ALLOW
if (!permissions[permission]) {
console.warn('WARNING: got unregistered permission request', permission)
response.push(false)
}

// The Torrent Viewer extension is always allowed to show fullscreen media
if (permission === 'fullscreen' &&
} else if (permission === 'fullscreen' &&
// The Torrent Viewer extension is always allowed to show fullscreen media
origin.startsWith('chrome-extension://' + config.torrentExtensionId)) {
response.push(true)
}

// Always allow fullscreen if setting is ON
const alwaysAllowFullscreen = module.exports.alwaysAllowFullscreen() === fullscreenOption.ALWAYS_ALLOW
if (permission === 'fullscreen' && alwaysAllowFullscreen) {
} else if (permission === 'fullscreen' && alwaysAllowFullscreen) {
// Always allow fullscreen if setting is ON
response.push(true)
}

// The Brave extension and PDFJS are always allowed to open files in an external app
if (permission === 'openExternal' && (
} else if (permission === 'openExternal' && (
// The Brave extension and PDFJS are always allowed to open files in an external app
origin.startsWith('chrome-extension://' + config.PDFJSExtensionId) ||
origin.startsWith('chrome-extension://' + config.braveExtensionId))) {
response.push(true)
}

const permissionName = permission + 'Permission'
let isAllowed
if (settings) {
isAllowed = settings.get(permissionName)
}
// Private tabs inherit settings from normal tabs, but not vice versa.
if (isPrivate && tempSettings) {
isAllowed = tempSettings.get(permissionName)
}
if (typeof isAllowed === 'boolean') {
response.push(isAllowed)
} else {
const permissionName = permission + 'Permission'
let isAllowed
if (settings) {
isAllowed = settings.get(permissionName)
}
// Private tabs inherit settings from normal tabs, but not vice versa.
if (isPrivate && tempSettings) {
isAllowed = tempSettings.get(permissionName)
}
if (typeof isAllowed === 'boolean') {
response.push(isAllowed)
}
}

// Display 'Brave Browser' if the origin is null; ex: when a mailto: link
Expand Down

0 comments on commit cb4c6d3

Please sign in to comment.