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 #14970 from brave/fix/media-device-access
Browse files Browse the repository at this point in the history
Add content setting for media device access
  • Loading branch information
bsclifton committed Aug 8, 2018
1 parent 17233fb commit 45a5fa2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
10 changes: 10 additions & 0 deletions app/extensions/brave/content/scripts/navigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,13 @@ if (chrome.contentSettings.ads == 'block') {

// Spectre hotfix (https://github.com/brave/browser-laptop/issues/12570)
chrome.webFrame.setGlobal('window.SharedArrayBuffer', false)

if (chrome.contentSettings.mediaPermission == 'block') {
// Needed for https://github.com/brave/browser-laptop/issues/14889
// Note this is not necessary in non-Electron-based codebases since Chromium
// automatically handles the permission for device enumeration.
// Also: chromium doesn't have mediaPermission in content setting. It is actually
// microphone && camera in chromium.
executeScript("window.MediaDeviceInfo.prototype.__defineGetter__('label', () => { return '' })")
executeScript("window.InputDeviceInfo.prototype.__defineGetter__('label', () => { return '' })")
}
17 changes: 10 additions & 7 deletions js/state/contentSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ const getDefaultUserPrefContentSettings = (braveryDefaults, appSettings, appConf
setting: getSetting(settings.DO_NOT_TRACK, appSettings) ? 'allow' : 'block',
primaryPattern: '*'
}],
mediaPermission: [{
setting: 'block',
primaryPattern: '*'
}],
passwordManager: getDefaultPasswordManagerSettings(braveryDefaults, appSettings, appConfig),
javascript: [{
setting: braveryDefaults.get('noScript') ? 'block' : 'allow',
Expand Down Expand Up @@ -280,10 +284,12 @@ const siteSettingsToContentSettings = (currentSiteSettings, defaultContentSettin
}
})
}
if (typeof siteSetting.get('runInsecureContent') === 'boolean') {
contentSettings = addContentSettings(contentSettings, 'runInsecureContent', primaryPattern, '*',
siteSetting.get('runInsecureContent') ? 'allow' : 'block')
}
['runInsecureContent', 'autoplay', 'mediaPermission'].forEach((permission) => {
if (typeof siteSetting.get(permission) === 'boolean') {
contentSettings = addContentSettings(contentSettings, permission, primaryPattern, '*',
siteSetting.get(permission) ? 'allow' : 'block')
}
})
if (siteSetting.get('cookieControl')) {
if (siteSetting.get('cookieControl') === 'block3rdPartyCookie') {
contentSettings = addContentSettings(contentSettings, 'cookies', primaryPattern, '*', 'block')
Expand Down Expand Up @@ -323,9 +329,6 @@ const siteSettingsToContentSettings = (currentSiteSettings, defaultContentSettin
if (typeof siteSetting.get('widevine') === 'number' && braveryDefaults.get('widevine')) {
contentSettings = addContentSettings(contentSettings, 'plugins', primaryPattern, '*', 'allow', appConfig.widevine.resourceId)
}
if (typeof siteSetting.get('autoplay') === 'boolean') {
contentSettings = addContentSettings(contentSettings, 'autoplay', primaryPattern, '*', siteSetting.get('autoplay') ? 'allow' : 'block')
}
})
// On the second pass we consider only shieldsUp === false settings since we want those to take precedence.
currentSiteSettings.forEach((siteSetting, hostPattern) => {
Expand Down

0 comments on commit 45a5fa2

Please sign in to comment.