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

Commit

Permalink
start migrating to electron userPrefs and contentSettings
Browse files Browse the repository at this point in the history
fixes #2157
  • Loading branch information
bridiver committed Jun 21, 2016
1 parent 4c2195f commit b310fb1
Show file tree
Hide file tree
Showing 18 changed files with 395 additions and 461 deletions.
15 changes: 8 additions & 7 deletions app/extensions.js
Expand Up @@ -19,18 +19,17 @@ let generateBraveManifest = () => {
all_frames: true,
matches: ['<all_urls>'],
include_globs: [
'http://*/*', 'https://*/*', 'file://*', 'data:*'
'http://*/*', 'https://*/*', 'file://*', 'data:*', 'about:srcdoc'
],
exclude_globs: [
getIndexHTML()
],
match_about_blank: true,
js: [
'content/scripts/util.js',
'js/actions/extensionActions.js',
'content/scripts/blockFlash.js',
'content/scripts/blockCanvasFingerprinting.js',
'content/scripts/block3rdPartyStorage.js',
'content/scripts/brave-default.js',
'js/actions/extensionActions.js',
'content/scripts/inputHandler.js',
'content/scripts/spellCheck.js'
],
Expand All @@ -43,7 +42,7 @@ let generateBraveManifest = () => {
all_frames: true,
matches: ['<all_urls>'],
include_globs: [
'http://*/*', 'https://*/*', 'file://*', 'data:*'
'http://*/*', 'https://*/*', 'file://*', 'data:*', 'about:srcdoc'
],
exclude_globs: [
getIndexHTML()
Expand Down Expand Up @@ -91,7 +90,7 @@ let generateBraveManifest = () => {
]
},
permissions: [
'externally_connectable.all_urls'
'externally_connectable.all_urls', 'tabs', '<all_urls>', 'contentSettings'
],
externally_connectable: {
matches: [
Expand Down Expand Up @@ -143,7 +142,9 @@ module.exports.init = () => {
process.on('background-page-loaded', function (extensionId, backgroundPageWebContents) {
if (extensionId === config.braveExtensionId) {
backgroundPage = backgroundPageWebContents
backgroundPage.send('update-state', AppStore.getState().toJS(), appConfig)
backgroundPage.on('dom-ready', () => {
backgroundPage.send('update-state', AppStore.getState().toJS(), appConfig)
})
}
})

Expand Down
19 changes: 9 additions & 10 deletions app/extensions/brave/brave-background.js
@@ -1,35 +1,34 @@
var appState = null
var appConfig = null
var _empty_ = Immutable.Map()
window.appState = null
window.appConfig = null
window._empty_ = Immutable.Map()

chrome.ipc.on('update-state', (evt, newState, newConfig) => {
appState = Immutable.fromJS(newState)
appConfig = newConfig
window.appState = Immutable.fromJS(newState)
window.appConfig = newConfig
})

chrome.runtime.onConnect.addListener((port) => {
sendMessage = () => {
let tabSettings = getSiteSettings(appState, port.sender.tab.incognito)
let tabSettings = getSiteSettings(window.appState, port.sender.tab.incognito)
let locationSettings = getSiteSettingsForURL(tabSettings, port.sender.tab.url) || _empty_

port.postMessage(activeSettings(locationSettings, appState, appConfig))
port.postMessage(activeSettings(locationSettings, window.appState, window.appConfig))
}

port.onMessage.addListener((msg) => {
if (!port.sender || !port.sender.tab)
if (!port.sender || !port.sender.tab || port.sender.id !== chrome.runtime.id)
return

if (msg.type === 'action') {
chrome.ipc.send('dispatch-action', JSON.stringify(msg.action))
}

// have not received state yet
if (!appState || !appConfig) {
if (!window.appState || !window.appConfig) {
port.postMessage({msg: 'wait'})
return
}

sendMessage()
})
})

81 changes: 0 additions & 81 deletions app/extensions/brave/content/scripts/block3rdPartyStorage.js

This file was deleted.

0 comments on commit b310fb1

Please sign in to comment.