diff --git a/app/extensions/brave/index-dev.html b/app/extensions/brave/index-dev.html
index 5083be311fc..8206cce774a 100644
--- a/app/extensions/brave/index-dev.html
+++ b/app/extensions/brave/index-dev.html
@@ -10,6 +10,7 @@
Brave
+
diff --git a/app/extensions/brave/index-load-script.js b/app/extensions/brave/index-load-script.js
index 3ea41c5b38c..cf6190712fa 100644
--- a/app/extensions/brave/index-load-script.js
+++ b/app/extensions/brave/index-load-script.js
@@ -21,4 +21,6 @@ document.querySelector('#webpackLoading').style.display = 'block'
createScript(appEntry).catch(function () {
document.querySelector('#webpackLoading').style.display = 'none'
document.querySelector('#setupError').style.display = 'block'
+}).then(() => {
+ createScript(baseHref + '/gen/lib.devTools.js')
})
diff --git a/app/extensions/brave/index.html b/app/extensions/brave/index.html
index 07b7c729f43..e6d602299e1 100644
--- a/app/extensions/brave/index.html
+++ b/app/extensions/brave/index.html
@@ -10,6 +10,7 @@
Brave
+
diff --git a/js/devTools.js b/js/devTools.js
new file mode 100644
index 00000000000..83e61c7274a
--- /dev/null
+++ b/js/devTools.js
@@ -0,0 +1,10 @@
+const electron = require('electron')
+const appActions = require('./actions/appActions')
+
+module.exports = function (name) {
+ if (name === 'electron') {
+ return electron
+ } else if (name === 'appActions') {
+ return appActions
+ }
+}
diff --git a/js/flash.js b/js/flash.js
index f7c2736a352..b2ed5ae0e27 100644
--- a/js/flash.js
+++ b/js/flash.js
@@ -17,7 +17,8 @@ const messages = require('./constants/messages')
const siteUtil = require('./state/siteUtil')
const urlParse = require('url').parse
const settings = require('./constants/settings')
-const { siteHacks } = require('./data/siteHacks')
+const {siteHacks} = require('./data/siteHacks')
+const urlutil = require('./lib/urlutil')
let flashInstalled = false
const notificationCallbacks = {}
@@ -43,16 +44,6 @@ const getPepperFlashPath = () => {
return pluginPath
}
-/**
- * Checks whether a link is an Flash installer URL.
- * @param {string} url
- * @return {boolean}
- */
-const isFlashInstallUrl = (url) => {
- const adobeRegex = new RegExp('//(get\\.adobe\\.com/([a-z_-]+/)*flashplayer|www\\.macromedia\\.com/go/getflash|www\\.adobe\\.com/go/getflash)', 'i')
- return adobeRegex.test(url)
-}
-
/**
* Shows a Flash CtP notification if Flash is installed and enabled.
* If not enabled, alert user that Flash is installed.
@@ -169,12 +160,7 @@ const shouldInterceptFlash = (url, isPrivate) => {
return false
}
- const parsed = urlParse(url)
- const exemptHostPattern = new RegExp('(\\.adobe\\.com|www\\.google(\\.\\w+){1,2}|^duckduckgo\\.com|^search\\.yahoo\\.com)$')
- return parsed.hostname &&
- ['http:', 'https:'].includes(parsed.protocol) &&
- !exemptHostPattern.test(parsed.hostname) &&
- !['/search', '/search/'].includes(parsed.pathname)
+ return urlutil.shouldInterceptFlash(url)
}
function handleFlashCTP (details, isPrivate) {
@@ -221,7 +207,7 @@ function handleFlashInstallUrl (details, isPrivate) {
}
const origin = siteUtil.getOrigin(mainFrameUrl)
- if (origin && isFlashInstallUrl(details.url) &&
+ if (origin && urlutil.isFlashInstallUrl(details.url) &&
shouldInterceptFlash(mainFrameUrl, isPrivate)) {
result.cancel = true
showFlashNotification(origin, details.tabId, details.url)
diff --git a/test/lib/brave.js b/test/lib/brave.js
index 1382abccb62..bcdbb686a11 100644
--- a/test/lib/brave.js
+++ b/test/lib/brave.js
@@ -1,3 +1,4 @@
+/* globals devTools */
var Application = require('spectron').Application
var chai = require('chai')
require('./coMocha')
@@ -153,13 +154,13 @@ var exports = {
addCommands: function () {
this.app.client.addCommand('ipcSend', function (message, ...param) {
return this.execute(function (message, ...param) {
- return require('electron').remote.getCurrentWindow().webContents.send(message, ...param)
+ return devTools('electron').remote.getCurrentWindow().webContents.send(message, ...param)
}, message, ...param).then((response) => response.value)
})
this.app.client.addCommand('ipcSendRenderer', function (message, ...param) {
return this.execute(function (message, ...param) {
- return require('electron').ipcRenderer.send(message, ...param)
+ return devTools('electron').ipcRenderer.send(message, ...param)
}, message, ...param).then((response) => response.value)
})
@@ -310,7 +311,7 @@ var exports = {
this.app.client.addCommand('showFindbar', function (show, key = 1) {
return this.execute(function (show, key) {
window.windowActions.setFindbarShown(Object.assign({
- windowId: require('electron').remote.getCurrentWindow().id,
+ windowId: devTools('electron').remote.getCurrentWindow().id,
key
}), show !== false)
}, show, key)
@@ -328,7 +329,7 @@ var exports = {
return this.execute(function (location, isPinned, options) {
var Immutable = require('immutable')
window.windowActions.setPinned(Immutable.fromJS(Object.assign({
- windowId: require('electron').remote.getCurrentWindow().id,
+ windowId: devTools('electron').remote.getCurrentWindow().id,
location
}, options)), isPinned)
}, location, isPinned, options)
@@ -336,13 +337,13 @@ var exports = {
this.app.client.addCommand('ipcOn', function (message, fn) {
return this.execute(function (message, fn) {
- return require('electron').remote.getCurrentWindow().webContents.on(message, fn)
+ return devTools('electron').remote.getCurrentWindow().webContents.on(message, fn)
}, message, fn).then((response) => response.value)
})
this.app.client.addCommand('newWindowAction', function (frameOpts, browserOpts) {
return this.execute(function () {
- return require('../../../js/actions/appActions').newWindow()
+ return devTools('appActions').newWindow()
}, frameOpts, browserOpts).then((response) => response.value)
})
@@ -354,7 +355,7 @@ var exports = {
*/
this.app.client.addCommand('addSite', function (siteDetail, tag) {
return this.execute(function (siteDetail, tag) {
- return require('../../../js/actions/appActions').addSite(siteDetail, tag)
+ return devTools('appActions').addSite(siteDetail, tag)
}, siteDetail, tag).then((response) => response.value)
})
@@ -365,7 +366,7 @@ var exports = {
*/
this.app.client.addCommand('addSiteList', function (siteDetail) {
return this.execute(function (siteDetail) {
- return require('../../../js/actions/appActions').addSite(siteDetail)
+ return devTools('appActions').addSite(siteDetail)
}, siteDetail).then((response) => response.value)
})
@@ -377,7 +378,7 @@ var exports = {
*/
this.app.client.addCommand('setResourceEnabled', function (resourceName, enabled) {
return this.execute(function (resourceName, enabled) {
- return require('../../../js/actions/appActions').setResourceEnabled(resourceName, enabled)
+ return devTools('appActions').setResourceEnabled(resourceName, enabled)
}, resourceName, enabled).then((response) => response.value)
})
@@ -389,7 +390,7 @@ var exports = {
*/
this.app.client.addCommand('removeSite', function (siteDetail, tag) {
return this.execute(function (siteDetail, tag) {
- return require('../../../js/actions/appActions').removeSite(siteDetail, tag)
+ return devTools('appActions').removeSite(siteDetail, tag)
}, siteDetail, tag).then((response) => response.value)
})
@@ -401,7 +402,7 @@ var exports = {
*/
this.app.client.addCommand('changeSetting', function (key, value) {
return this.execute(function (key, value) {
- return require('../../../js/actions/appActions').changeSetting(key, value)
+ return devTools('appActions').changeSetting(key, value)
}, key, value).then((response) => response.value)
})
@@ -413,7 +414,7 @@ var exports = {
*/
this.app.client.addCommand('changeSiteSetting', function (hostPattern, key, value) {
return this.execute(function (hostPattern, key, value) {
- return require('../../../js/actions/appActions').changeSiteSetting(hostPattern, key, value)
+ return devTools('appActions').changeSiteSetting(hostPattern, key, value)
}, hostPattern, key, value).then((response) => response.value)
})
@@ -424,13 +425,13 @@ var exports = {
*/
this.app.client.addCommand('clearAppData', function (clearDataDetail) {
return this.execute(function (clearDataDetail) {
- return require('../../../js/actions/appActions').clearAppData(clearDataDetail)
+ return devTools('appActions').clearAppData(clearDataDetail)
}, clearDataDetail).then((response) => response.value)
})
this.app.client.addCommand('getDefaultWindowHeight', function () {
return this.execute(function () {
- let screen = require('electron').screen
+ let screen = devTools('electron').screen
let primaryDisplay = screen.getPrimaryDisplay()
return primaryDisplay.workAreaSize.height
}).then((response) => response.value)
@@ -438,7 +439,7 @@ var exports = {
this.app.client.addCommand('getDefaultWindowWidth', function () {
return this.execute(function () {
- let screen = require('electron').screen
+ let screen = devTools('electron').screen
let primaryDisplay = screen.getPrimaryDisplay()
return primaryDisplay.workAreaSize.width
}).then((response) => response.value)
@@ -446,7 +447,7 @@ var exports = {
this.app.client.addCommand('getPrimaryDisplayHeight', function () {
return this.execute(function () {
- let screen = require('electron').screen
+ let screen = devTools('electron').screen
return screen.getPrimaryDisplay().bounds.height
}).then((response) => response.value)
})
@@ -459,14 +460,14 @@ var exports = {
this.app.client.addCommand('getPrimaryDisplayWidth', function () {
return this.execute(function () {
- let screen = require('electron').screen
+ let screen = devTools('electron').screen
return screen.getPrimaryDisplay().bounds.width
}).then((response) => response.value)
})
this.app.client.addCommand('resizeWindow', function (width, height) {
return this.execute(function (width, height) {
- return require('electron').remote.getCurrentWindow().setSize(width, height)
+ return devTools('electron').remote.getCurrentWindow().setSize(width, height)
}, width, height).then((response) => response.value)
})
@@ -527,7 +528,7 @@ var exports = {
internal.viewInstanceId
// This allows you to send more args than just the event itself like would only
// be possible with dispatchEvent.
- require('electron').ipcRenderer.emit('ELECTRON_GUEST_VIEW_INTERNAL_DISPATCH_EVENT-' + internal.viewInstanceId, ...params)
+ devTools('electron').ipcRenderer.emit('ELECTRON_GUEST_VIEW_INTERNAL_DISPATCH_EVENT-' + internal.viewInstanceId, ...params)
}, frameKey, eventName, ...params).then((response) => response.value)
})
@@ -570,7 +571,8 @@ var exports = {
quitTimeout: 0,
path: './node_modules/.bin/electron',
env,
- args: ['./', '--debug=5858', '--enable-logging', '--v=1']
+ args: ['./', '--debug=5858', '--enable-logging', '--v=1'],
+ requireName: 'devTools'
})
return this.app.start()
},
diff --git a/webpack.config.js b/webpack.config.js
index f7ec3da168e..9d3b5696df5 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -20,6 +20,7 @@ function config () {
exclude: [
/node_modules/,
/\.min.js$/,
+ path.resolve(__dirname, 'app', 'browser', '*'),
path.resolve(__dirname, 'app', 'extensions', '*')
],
loader: 'babel'
@@ -106,24 +107,28 @@ function merge (config, env) {
}
var app = {
- name: 'app',
target: 'web',
- entry: ['./js/entry.js'],
+ entry: {
+ app: [ path.resolve(__dirname, 'js', 'entry.js') ],
+ aboutPages: [ path.resolve(__dirname, 'js', 'about', 'entry.js') ]
+ },
output: {
path: path.resolve(__dirname, 'app', 'extensions', 'brave', 'gen'),
- filename: 'app.entry.js',
+ filename: '[name].entry.js',
publicPath: './gen/'
}
}
-var aboutPages = {
- name: 'about',
+var devTools = {
target: 'web',
- entry: ['./js/about/entry.js'],
+ entry: {
+ devTools: [ path.resolve(__dirname, 'js', 'devTools.js') ]
+ },
output: {
path: path.resolve(__dirname, 'app', 'extensions', 'brave', 'gen'),
- filename: 'aboutPages.entry.js',
- publicPath: './gen/'
+ filename: 'lib.[name].js',
+ publicPath: './gen/',
+ library: '[name]'
}
}
@@ -141,17 +146,17 @@ var webtorrentPage = {
module.exports = {
development: [
merge(app, development()),
- merge(aboutPages, development()),
+ merge(devTools, development()),
merge(webtorrentPage, development())
],
production: [
merge(app, production()),
- merge(aboutPages, production()),
+ merge(devTools, development()),
merge(webtorrentPage, production())
],
test: [
merge(app, production()),
- merge(aboutPages, production()),
+ merge(devTools, development()),
merge(webtorrentPage, production())
]
}[env]