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 #12412 from brave/fix/chrome-csp
Browse files Browse the repository at this point in the history
Fix extension icons appearing in about: pages and context menu
  • Loading branch information
bsclifton committed Dec 27, 2017
2 parents 830acf5 + 0b14695 commit d0c2c6c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
3 changes: 2 additions & 1 deletion app/common/state/extensionState.js
Expand Up @@ -5,6 +5,7 @@
const { makeImmutable } = require('./immutableUtil')
const Immutable = require('immutable')
const platformUtil = require('../lib/platformUtil')
const {chromeUrl} = require('../../../js/lib/appUrlUtil')

const browserActionDefaults = Immutable.fromJS({
tabs: {}
Expand Down Expand Up @@ -77,7 +78,7 @@ const extensionState = {
browserActionBackgroundImage: (browserAction, tabId) => {
tabId = tabId ? tabId.toString() : '-1'
let path = browserAction.getIn(['tabs', tabId, 'path']) || browserAction.get('path')
let basePath = browserAction.get('base_path')
let basePath = chromeUrl(browserAction.get('base_path'))
if (path && basePath) {
// Older extensions may provide a string path
if (typeof path === 'string') {
Expand Down
4 changes: 2 additions & 2 deletions app/extensions.js
Expand Up @@ -3,7 +3,7 @@ const contextMenus = require('./browser/extensions/contextMenus')
const extensionActions = require('./common/actions/extensionActions')
const config = require('../js/constants/config')
const appConfig = require('../js/constants/appConfig')
const {chromeUrl} = require('../js/lib/appUrlUtil')
const {fileUrl} = require('../js/lib/appUrlUtil')
const {getExtensionsPath, getBraveExtUrl, getBraveExtIndexHTML} = require('../js/lib/appUrlUtil')
const {getSetting} = require('../js/settings')
const settings = require('../js/constants/settings')
Expand Down Expand Up @@ -408,7 +408,7 @@ module.exports.init = () => {
extensionInfo.setInstallInfo(installInfo.id, installInfo)
installInfo.filePath = installInfo.base_path

installInfo.base_path = chromeUrl(installInfo.base_path)
installInfo.base_path = fileUrl(installInfo.base_path)

extensionActions.extensionInstalled(installInfo.id, installInfo)
extensionActions.extensionEnabled(installInfo.id)
Expand Down
10 changes: 5 additions & 5 deletions js/lib/appUrlUtil.js
Expand Up @@ -24,11 +24,11 @@ module.exports.fileUrl = (filePath) => {
return encodeURI('file://' + fileUrlPath)
}

module.exports.chromeUrl = (filePath = '') => {
filePath = module.exports.fileUrl(filePath)
filePath = filePath.replace('file://', 'chrome://brave')

return filePath
/**
* Converts file URL to chrome:// URL
*/
module.exports.chromeUrl = (fileUrl = '') => {
return fileUrl.replace('file://', 'chrome://brave')
}

/**
Expand Down
2 changes: 1 addition & 1 deletion test/unit/lib/appUrlUtilTest.js
Expand Up @@ -81,7 +81,7 @@ describe('appUrlUtil test', function () {
})
describe('chromeUrl', function () {
it('can convert file paths', function () {
const filePath = '/users/bbondy/space here/tesT.html'
const filePath = 'file:///users/bbondy/space%20here/tesT.html'
const chromeUrl = appUrlUtil.chromeUrl(filePath)
const expected = 'chrome://brave/users/bbondy/space%20here/tesT.html'
assert.equal(chromeUrl, expected)
Expand Down

0 comments on commit d0c2c6c

Please sign in to comment.