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

Commit

Permalink
Specify correct contentSetting resourceId on Windows
Browse files Browse the repository at this point in the history
Fix #6687

Auditors: @bridiver
  • Loading branch information
bbondy committed Jan 19, 2017
1 parent 8d1ae13 commit f682695
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
6 changes: 3 additions & 3 deletions app/browser/reducers/tabsReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

'use strict'

const appConfig = require('../../../js/constants/appConfig')
const appConstants = require('../../../js/constants/appConstants')
const tabs = require('../tabs')
const tabState = require('../../common/state/tabState')
const windowConstants = require('../../../js/constants/windowConstants')
const { makeImmutable } = require('../../common/state/immutableUtil')
const {makeImmutable} = require('../../common/state/immutableUtil')
const {getFlashResourceId} = require('../../../js/flash')

const tabsReducer = (state, action) => {
action = makeImmutable(action)
Expand All @@ -34,7 +34,7 @@ const tabsReducer = (state, action) => {
{
const webContents = tabs.getWebContents(action.get('tabId'))
if (webContents && !webContents.isDestroyed() && webContents.getURL() === action.get('url')) {
webContents.authorizePlugin(appConfig.flash.resourceId)
webContents.authorizePlugin(getFlashResourceId())
}
break
}
Expand Down
2 changes: 0 additions & 2 deletions js/constants/appConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,12 @@ module.exports = {
enabled: false,
installUrl: 'https://get.adobe.com/flashplayer/',
url: getTargetAboutUrl('about:flash'),
resourceId: 'PepperFlashPlayer.plugin',
shields: false
},
widevine: {
enabled: false,
moreInfoUrl: 'https://www.eff.org/issues/drm',
licenseUrl: 'https://www.google.com/policies/terms/',
resourceId: 'widevinecdmadapter.plugin',
shields: false
},
adblock: {
Expand Down
7 changes: 6 additions & 1 deletion js/flash.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ const {getOrigin} = require('./state/siteUtil')
const locale = require('../app/locale')
const messages = require('./constants/messages')
const settings = require('./constants/settings')
const {memoize} = require('underscore')

// set to true if the flash install check has succeeded
let flashInstalled = false

const getPepperFlashPath = () => {
const getPepperFlashPath = memoize(() => {
if (['darwin', 'win32'].includes(process.platform)) {
return app.getPath('pepperFlashSystemPlugin')
}
Expand All @@ -34,6 +35,10 @@ const getPepperFlashPath = () => {
}
}
return pluginPath
})

module.exports.getFlashResourceId = () => {
return path.basename(getPepperFlashPath())
}

module.exports.showFlashMessageBox = (location, tabId) => {
Expand Down
15 changes: 8 additions & 7 deletions js/state/contentSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@ const AppStore = require('../stores/appStore')
const appConstants = require('../constants/appConstants')
const appConfig = require('../constants/appConfig')
const config = require('../constants/config')
const { registerContentSettings } = require('../../app/browser/contentSettings/hostContentSettings')
const {registerContentSettings} = require('../../app/browser/contentSettings/hostContentSettings')
const {makeImmutable} = require('../../app/common/state/immutableUtil')
const Immutable = require('immutable')
const settings = require('../constants/settings')
const {cookieExceptions, localStorageExceptions} = require('../data/siteHacks')
const {defaultPasswordManager} = require('../constants/passwordManagers')
const urlParse = require('url').parse
const siteSettings = require('./siteSettings')
const { registerUserPrefs } = require('./userPrefs')
const { getSetting } = require('../settings')
const {registerUserPrefs} = require('./userPrefs')
const {getSetting} = require('../settings')
const {getFlashResourceId} = require('../flash')

// backward compatibility with appState siteSettings
const parseSiteSettingsPattern = (pattern) => {
Expand Down Expand Up @@ -127,7 +128,7 @@ const getDefaultPluginSettings = (braveryDefaults, appSettings, appConfig) => {
},
{
setting: 'block',
resourceId: appConfig.flash.resourceId,
resourceId: getFlashResourceId(),
primaryPattern: '*'
},
{
Expand All @@ -138,12 +139,12 @@ const getDefaultPluginSettings = (braveryDefaults, appSettings, appConfig) => {
// allow autodetction of flash install by adobe
{
setting: 'allow',
resourceId: appConfig.flash.resourceId,
resourceId: getFlashResourceId(),
primaryPattern: '[*.]adobe.com'
},
{
setting: 'allow',
resourceId: appConfig.flash.resourceId,
resourceId: getFlashResourceId(),
primaryPattern: '[*.]macromedia.com'
}
]
Expand Down Expand Up @@ -223,7 +224,7 @@ const siteSettingsToContentSettings = (currentSiteSettings, defaultContentSettin
contentSettings = addContentSettings(contentSettings, 'adInsertion', primaryPattern, '*', siteSetting.get('adControl') === 'showBraveAds' ? 'allow' : 'block')
}
if (typeof siteSetting.get('flash') === 'number' && braveryDefaults.get('flash')) {
contentSettings = addContentSettings(contentSettings, 'plugins', primaryPattern, '*', 'allow', appConfig.flash.resourceId)
contentSettings = addContentSettings(contentSettings, 'plugins', primaryPattern, '*', 'allow', getFlashResourceId())
}
if (typeof siteSetting.get('widevine') === 'number' && braveryDefaults.get('widevine')) {
contentSettings = addContentSettings(contentSettings, 'plugins', primaryPattern, '*', 'allow', appConfig.widevine.resourceId)
Expand Down

1 comment on commit f682695

@bridiver
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++

Please sign in to comment.