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 #7752 from brave/fix/4020
Browse files Browse the repository at this point in the history
Improve flash hidden element detection
  • Loading branch information
bsclifton authored Mar 17, 2017
2 parents 903cfea + 6cbd6df commit 6f9a4f2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
23 changes: 17 additions & 6 deletions app/extensions/brave/content/scripts/flashListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,23 @@ function hasHiddenFlashElement (elem) {
})
}


// If Flash is enabled but not runnable, show a permission notification for small
// Flash elements
if (chrome.contentSettings.flashEnabled == 'allow' && chrome.contentSettings.plugins != 'allow' && hasHiddenFlashElement(document.documentElement)) {
chrome.ipcRenderer.send('dispatch-action', JSON.stringify([{
actionType: 'app-flash-permission-requested',
location: window.location.href
}]))
if (chrome.contentSettings.flashEnabled == 'allow' && chrome.contentSettings.flashAllowed != 'allow') {
const maxFlashAttempts = 3
let flashAttempts = 0
const intervalId = window.setInterval(() => {
if (flashAttempts >= maxFlashAttempts) {
window.clearInterval(intervalId)
return
}
flashAttempts = flashAttempts + 1
if (hasHiddenFlashElement(document.documentElement)) {
chrome.ipcRenderer.send('dispatch-action', JSON.stringify([{
actionType: 'app-flash-permission-requested',
location: window.location.href
}]))
window.clearInterval(intervalId)
}
}, 1000)
}
7 changes: 6 additions & 1 deletion js/state/contentSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,14 @@ const getDefaultUserPrefContentSettings = (braveryDefaults, appSettings, appConf
setting: 'block',
primaryPattern: '*'
}],
flashEnabled: [{
flashEnabled: [{ // whether flash is installed and enabled
setting: braveryDefaults.get('flash') ? 'allow' : 'block',
primaryPattern: '*'
}],
flashAllowed: [{ // whether user has expressed intent to run flash
setting: 'block',
primaryPattern: '*'
}],
popups: [{
setting: 'block',
primaryPattern: '*'
Expand Down Expand Up @@ -268,6 +272,7 @@ const siteSettingsToContentSettings = (currentSiteSettings, defaultContentSettin
}
if (typeof siteSetting.get('flash') === 'number' && braveryDefaults.get('flash')) {
contentSettings = addContentSettings(contentSettings, 'plugins', primaryPattern, '*', 'allow', getFlashResourceId())
contentSettings = addContentSettings(contentSettings, 'flashAllowed', primaryPattern, '*', 'allow', getFlashResourceId())
}
if (typeof siteSetting.get('widevine') === 'number' && braveryDefaults.get('widevine')) {
contentSettings = addContentSettings(contentSettings, 'plugins', primaryPattern, '*', 'allow', appConfig.widevine.resourceId)
Expand Down

0 comments on commit 6f9a4f2

Please sign in to comment.