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

Improve flash hidden element detection #7752

Merged
merged 1 commit into from
Mar 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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