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

Commit

Permalink
Improve flash hidden element detection
Browse files Browse the repository at this point in the history
Separates plugin content setting from flashEnabled setting so that shields down
allows tiny flash elements to be detected. Also improves hidden element detection
for slow/delayed element loads.

Fix #4020

Auditors: @srirambv @bbondy

Test Plan:
1. go to reverso.net with flash enabled in about:preferences and shields down
2. enter something in the box and click translate
3. you should see a flash notification bar. click 'allow'
4. click on the copy-paste icon in the results box. the page should tell you that the text was copied.
  • Loading branch information
diracdeltas committed Mar 16, 2017
1 parent 05b0622 commit 6cbd6df
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 6cbd6df

Please sign in to comment.