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

Commit

Permalink
temporary and wip changes for chromium54
Browse files Browse the repository at this point in the history
  • Loading branch information
bridiver committed Dec 14, 2016
1 parent 8ae8eb4 commit dbc0796
Show file tree
Hide file tree
Showing 48 changed files with 199 additions and 221 deletions.
8 changes: 4 additions & 4 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
runtime = electron
target = 1.4.0
#runtime = electron
#target = 1.4.0
target_arch = x64
brave_electron_version = 1.4.31
disturl = https://atom.io/download/atom-shell
#brave_electron_version = 1.4.23
#disturl = https://atom.io/download/atom-shell
15 changes: 0 additions & 15 deletions app/browser/lib/patchUserDataDir.js

This file was deleted.

6 changes: 6 additions & 0 deletions app/browser/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ const tabs = {
activeTab = tab
}
})
tab.on('new-window', (e, url, frameName, disposition, options = {}) => {
let userGesture = options.userGesture
if (userGesture === false) {
e.preventDefault()
}
})
currentWebContents[tabId] = tab
})
},
Expand Down
8 changes: 1 addition & 7 deletions app/common/commonMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,7 @@ const settings = require('../../js/constants/settings')
const getSetting = require('../../js/settings').getSetting
const communityURL = 'https://community.brave.com/'
const isDarwin = process.platform === 'darwin'

let electron
try {
electron = require('electron')
} catch (e) {
electron = global.require('electron')
}
const electron = require('electron')

let app
let BrowserWindow
Expand Down
4 changes: 3 additions & 1 deletion app/extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ let generateBraveManifest = () => {
web_accessible_resources: [
'img/favicon.ico',
'about-flash.html',
'about-blank.html'
'about-blank.html',
'about-newtab.html',
'about-preferences.html'
],
incognito: 'spanning',
key: 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAupOLMy5Fd4dCSOtjcApsAQOnuBdTs+OvBVt/3P93noIrf068x0xXkvxbn+fpigcqfNamiJ5CjGyfx9zAIs7zcHwbxjOw0Uih4SllfgtK+svNTeE0r5atMWE0xR489BvsqNuPSxYJUmW28JqhaSZ4SabYrRx114KcU6ko7hkjyPkjQa3P+chStJjIKYgu5tWBiMJp5QVLelKoM+xkY6S7efvJ8AfajxCViLGyDQPDviGr2D0VvIBob0D1ZmAoTvYOWafcNCaqaejPDybFtuLFX3pZBqfyOCyyzGhucyCmfBXJALKbhjRAqN5glNsUmGhhPK87TuGATQfVuZtenMvXMQIDAQAB'
Expand Down
4 changes: 2 additions & 2 deletions app/extensions/brave/content/scripts/adInsertion.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,12 @@ if (chrome.contentSettings.adInsertion == 'allow') {
var host = document.location.hostname
if (host) {
host = host.replace('www.', '')
chrome.ipc.on('set-ad-div-candidates', (e, divHost, adDivCandidates, placeholderUrl) => {
chrome.ipcRenderer.on('set-ad-div-candidates', (e, divHost, adDivCandidates, placeholderUrl) => {
// don't accidentally intercept messages not intended for this host
if (host === divHost) {
setAdDivCandidates(adDivCandidates, placeholderUrl)
}
})
chrome.ipc.send('get-ad-div-candidates', host)
chrome.ipcRenderer.send('get-ad-div-candidates', host)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ if (chrome.contentSettings.canvasFingerprinting == 'block') {
}

// Block the read from occuring; send info to background page instead
chrome.ipc.sendToHost('got-canvas-fingerprinting', msg)
chrome.ipcRenderer.sendToHost('got-canvas-fingerprinting', msg)
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/extensions/brave/content/scripts/flashListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function isAdobeLink (href) {
}

function showFlashNotification (origin, e) {
chrome.ipc.sendToHost('show-flash-notification', origin)
chrome.ipcRenderer.sendToHost('show-flash-notification', origin)
e.preventDefault()
e.stopPropagation()
}
Expand Down
14 changes: 7 additions & 7 deletions app/extensions/brave/content/scripts/idleHandler.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
chrome.idle.setDetectionInterval(15*60)
chrome.idle.onStateChanged.addListener((idleState) => {
chrome.ipc.send('dispatch-action', JSON.stringify({
actionType: 'app-idle-state-changed',
idleState
}))
})
// chrome.idle.setDetectionInterval(15*60)
// chrome.idle.onStateChanged.addListener((idleState) => {
// chrome.ipcRenderer.send('dispatch-action', JSON.stringify({
// actionType: 'app-idle-state-changed',
// idleState
// }))
// })
6 changes: 3 additions & 3 deletions app/extensions/brave/content/scripts/inputHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,17 +136,17 @@ document.addEventListener('keydown', (e /*: Event*/) => {
case KeyEvent.DOM_VK_ESCAPE:
if (document.readyState !== 'complete') {
e.preventDefault()
chrome.ipc.sendToHost('stop-load')
chrome.ipcRenderer.sendToHost('stop-load')
}
break
case KeyEvent.DOM_VK_LEFT:
if (e.metaKey && !isEditable(document.activeElement) && isPlatformOSX()) {
chrome.ipc.sendToHost('go-back')
chrome.ipcRenderer.sendToHost('go-back')
}
break
case KeyEvent.DOM_VK_RIGHT:
if (e.metaKey && !isEditable(document.activeElement) && isPlatformOSX()) {
chrome.ipc.sendToHost('go-forward')
chrome.ipcRenderer.sendToHost('go-forward')
}
break
}
Expand Down
8 changes: 4 additions & 4 deletions app/extensions/brave/content/scripts/pageInformation.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/* jshint asi: true */
/* jshint esversion: 6 */

(function () { try {
(function () { try {
var resolve = (tree, context) => {
var node = tree.body ? tree.body[0] : tree

Expand Down Expand Up @@ -135,7 +135,7 @@
if (!node) node = document.head.querySelector("link[rel='shortcut icon']")
if (node) results.faviconURL = node.getAttribute('href')

var pubinfo = chrome.ipc.sendSync('ledger-publisher', document.location.href)
var pubinfo = chrome.ipcRenderer.sendSync('ledger-publisher', document.location.href)
if ((!pubinfo) || (!pubinfo.context) || (!pubinfo.rules)) return console.log('no pubinfo available')

var context = pubinfo.context
Expand Down Expand Up @@ -171,7 +171,7 @@
results.faviconURL = resolve(rule.faviconURL.consequent, context)
}
break
}
}

if (results.faviconURL) {
var prefix = (results.faviconURL.indexOf('//') === 0) ? document.location.protocol
Expand All @@ -182,7 +182,7 @@
}

results.url = window.location.href
chrome.ipc.send('dispatch-action', JSON.stringify({
chrome.ipcRenderer.send('dispatch-action', JSON.stringify({
location: window.location.href,
actionType: 'event-set-page-info',
pageInfo: results
Expand Down
12 changes: 6 additions & 6 deletions app/extensions/brave/content/scripts/passwordManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
if (chrome.contentSettings.passwordManager == 'allow') {
let credentials = {}
function savePassword (username/*: ?string*/, pw/*: string*/, origin/*: string*/, action/*: string*/) {
chrome.ipc.send('save-password', username, pw, origin, action)
chrome.ipcRenderer.send('save-password', username, pw, origin, action)
}

let submittedForms = []
Expand Down Expand Up @@ -62,7 +62,7 @@ if (chrome.contentSettings.passwordManager == 'allow') {

// Fill the password immediately if there's only one or if the username
// is already autofilled
chrome.ipc.send('get-passwords', formOrigin, action)
chrome.ipcRenderer.send('get-passwords', formOrigin, action)

if (usernameElem) {
usernameElem.addEventListener('keyup', (e) => {
Expand All @@ -73,11 +73,11 @@ if (chrome.contentSettings.passwordManager == 'allow') {
case KeyEvent.DOM_VK_ESCAPE:
e.preventDefault()
e.stopPropagation()
chrome.ipc.send('hide-context-menu')
chrome.ipcRenderer.send('hide-context-menu')
break
default:
let rect = usernameElem.getBoundingClientRect()
chrome.ipc.send('show-username-list', formOrigin, action, {
chrome.ipcRenderer.send('show-username-list', formOrigin, action, {
bottom: rect.bottom,
left: rect.left,
width: rect.width
Expand All @@ -91,7 +91,7 @@ if (chrome.contentSettings.passwordManager == 'allow') {
form.addEventListener('submit', (e) => {
if (usernameElem) {
usernameElem.blur()
chrome.ipc.send('hide-context-menu')
chrome.ipcRenderer.send('hide-context-menu')
}
onFormSubmit(form, formOrigin)
})
Expand Down Expand Up @@ -137,7 +137,7 @@ if (chrome.contentSettings.passwordManager == 'allow') {
tryAutofillForm(formOrigin, form)
})

chrome.ipc.on('got-password', (e, username, password, origin, action, isUnique) => {
chrome.ipcRenderer.on('got-password', (e, username, password, origin, action, isUnique) => {
var elems = credentials[action]
if (formOrigin === origin && elems) {
elems.forEach((elem) => {
Expand Down
2 changes: 1 addition & 1 deletion app/extensions/brave/content/scripts/spellCheck.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

let lang = navigator.language.split('-')[0].split('_')[0]
chrome.webFrame.setSpellCheckProvider(lang || '', true, {
spellCheck: (word) => !chrome.ipc.sendSync('is-misspelled', word)
spellCheck: (word) => !chrome.ipcRenderer.sendSync('is-misspelled', word)
})
4 changes: 2 additions & 2 deletions app/extensions/brave/content/scripts/themeColor.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */

(function () {
var ipcRenderer = chrome.ipc;
var ipcRenderer = chrome.ipcRenderer;

const rgbaFromStr = function (rgba) {
if (!rgba) {
Expand Down Expand Up @@ -57,6 +57,6 @@
}

if(window.top == window.self) {
chrome.ipc.sendToHost('theme-color-computed', computeThemeColor())
chrome.ipcRenderer.sendToHost('theme-color-computed', computeThemeColor())
}
})()
2 changes: 1 addition & 1 deletion app/extensions/brave/index-dev.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<!-- TODO: Don't allow img-src *, needed for favicons -->
<!-- TODO: Refactor away all unsafe-inline content -->
<!-- TODO: Replace suggestqueries.google.com and ac.duckduckgo.com and other search engines with a single config search engine -->
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; form-action 'none'; referrer no-referrer; script-src 'self' http://localhost:*; connect-src 'self' https://s3.amazonaws.com/adblock-data/ https://s3.amazonaws.com/safe-browsing-data/ https://s3.amazonaws.com/tracking-protection-data/ https://s3.amazonaws.com/https-everywhere-data/ http://localhost:* ws://localhost:* https://suggestqueries.google.com https://ac.duckduckgo.com https://completion.amazon.com https://search.yahoo.com https://api.bing.com https://www.startpage.com https://infogalactic.com https://api.qwant.com https://brave-download.global.ssl.fastly.net https://brave-laptop-updates.global.ssl.fastly.net https://brave-download.global.ssl.fastly.net https://laptop-updates-pre.brave.com https://brave-laptop-updates-pre.brave.com; style-src 'unsafe-inline'; font-src 'self' http://localhost:*; img-src 'self' * data:; object-src 'self'; plugin-types application/browser-plugin">
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; form-action http://localhost:*; referrer no-referrer; script-src 'self' http://localhost:*; connect-src 'self' https://s3.amazonaws.com/adblock-data/ https://s3.amazonaws.com/safe-browsing-data/ https://s3.amazonaws.com/tracking-protection-data/ https://s3.amazonaws.com/https-everywhere-data/ http://localhost:* ws://localhost:* https://suggestqueries.google.com https://ac.duckduckgo.com https://completion.amazon.com https://search.yahoo.com https://api.bing.com https://www.startpage.com https://infogalactic.com https://api.qwant.com https://brave-download.global.ssl.fastly.net https://brave-laptop-updates.global.ssl.fastly.net https://brave-download.global.ssl.fastly.net https://laptop-updates-pre.brave.com https://brave-laptop-updates-pre.brave.com; style-src 'unsafe-inline'; font-src 'self' http://localhost:*; img-src 'self' * data:; object-src 'self'; plugin-types application/browser-plugin">
<title>Brave</title>
<script src="ext/l20n.min.js"></script>
<script src="gen/app.entry.js" async></script>
Expand Down
2 changes: 1 addition & 1 deletion app/extensions/brave/index-load-script.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var baseHref = 'http://localhost:' + process.env.npm_package_config_port
var baseHref = 'http://localhost:8080' // + process.env.npm_package_config_port
var appEntry = baseHref + '/gen/app.entry.js'

var baseNode = document.createElement('base')
Expand Down
13 changes: 8 additions & 5 deletions app/filtering.js
Original file line number Diff line number Diff line change
Expand Up @@ -549,17 +549,20 @@ function initForPartition (partition) {
fns.forEach((fn) => { fn(ses, partition) })
}

const filterableProtocols = ['http:', 'https:']

function shouldIgnoreUrl (url) {
// Ensure host is well-formed (RFC 1035) and has a non-empty hostname
try {
let host = urlParse(url).hostname
if (host.includes('..') || host.length > 255 || host.length === 0) {
return true
// TODO(bridiver) - handle RFS check and cancel http/https requests with 0 or > 255 length hostames
const parsedUrl = urlParse(url)
if (filterableProtocols.includes(parsedUrl.protocol)) {
return false
}
} catch (e) {
return true
console.warn('Error parsing ' + url)
}
return false
return true
}

module.exports.init = () => {
Expand Down
22 changes: 10 additions & 12 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
let ready = false

// Setup the crash handling
const CrashHerald = require('./crash-herald')
// const CrashHerald = require('./crash-herald')

const handleUncaughtError = (error) => {
var message, ref, stack
Expand Down Expand Up @@ -42,14 +42,12 @@ if (process.platform === 'win32') {

const electron = require('electron')
const app = electron.app
// set userData before loading anything else
require('./browser/lib/patchUserDataDir')
const BrowserWindow = electron.BrowserWindow
const dialog = electron.dialog
const ipcMain = electron.ipcMain
const Immutable = require('immutable')
const Menu = require('./browser/menu')
const Updater = require('./updater')
// const Updater = require('./updater')
const Importer = require('./importer')
const messages = require('../js/constants/messages')
const appConfig = require('../js/constants/appConfig')
Expand Down Expand Up @@ -212,7 +210,7 @@ const saveAppState = (appState, cb) => {
// Otherwise just quit.
if (appState.updates && (appState.updates.status === UpdateStatus.UPDATE_APPLYING_NO_RESTART ||
appState.updates.status === UpdateStatus.UPDATE_APPLYING_RESTART)) {
Updater.quitAndInstall()
// Updater.quitAndInstall()
} else {
app.quit()
}
Expand Down Expand Up @@ -254,7 +252,7 @@ loadAppStatePromise.then((initialState) => {
}
if (initialState.settings[SEND_CRASH_REPORTS] !== false) {
console.log('Crash reporting enabled')
CrashHerald.init()
// CrashHerald.init()
} else {
console.log('Crash reporting disabled')
}
Expand Down Expand Up @@ -435,7 +433,7 @@ app.on('ready', () => {
webtorrent.init()

if (!loadedPerWindowState || loadedPerWindowState.length === 0) {
if (!CmdLine.newWindowURL()) {
if (!CmdLine.newWindowURL) {
appActions.newWindow()
}
} else {
Expand All @@ -458,9 +456,9 @@ app.on('ready', () => {
appActions.changeSetting(settings.IS_DEFAULT_BROWSER, isDefaultBrowser)
}

if (CmdLine.newWindowURL()) {
if (CmdLine.newWindowURL) {
appActions.newWindow(Immutable.fromJS({
location: CmdLine.newWindowURL()
location: CmdLine.newWindowURL
}))
}

Expand Down Expand Up @@ -750,11 +748,11 @@ app.on('ready', () => {

// Setup the auto updater, check the env variable first because it's
// used to check the update channel before releases.
Updater.init(process.platform, process.arch, process.env.BRAVE_UPDATE_VERSION || pack.version)
// Updater.init(process.platform, process.arch, process.env.BRAVE_UPDATE_VERSION || pack.version)

// This is fired by a menu entry (for now - will be scheduled)
process.on(messages.CHECK_FOR_UPDATE, () => Updater.checkForUpdate(true))
ipcMain.on(messages.CHECK_FOR_UPDATE, () => Updater.checkForUpdate(true))
// process.on(messages.CHECK_FOR_UPDATE, () => Updater.checkForUpdate(true))
// ipcMain.on(messages.CHECK_FOR_UPDATE, () => Updater.checkForUpdate(true))

// This is fired from a auto-update metadata call
process.on(messages.UPDATE_META_DATA_RETRIEVED, (metadata) => {
Expand Down
2 changes: 1 addition & 1 deletion app/renderer/components/browserActionButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

const React = require('react')
const ImmutableComponent = require('../../../js/components/immutableComponent')
const electron = global.require('electron')
const electron = require('electron')
const ipc = electron.ipcRenderer
const Button = require('../../../js/components/button')
const cx = require('../../../js/lib/classSet')
Expand Down
2 changes: 1 addition & 1 deletion js/about/aboutActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const messages = require('../constants/messages')
const serializer = require('../dispatcher/serializer')
const windowConstants = require('../constants/windowConstants')
const appConstants = require('../constants/appConstants')
const ipc = window.chrome.ipc
const ipc = window.chrome.ipcRenderer

const aboutActions = {
/**
Expand Down
2 changes: 1 addition & 1 deletion js/about/adblock.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const aboutActions = require('./aboutActions')
const ImmutableComponent = require('../components/immutableComponent')
const SwitchControl = require('../components/switchControl')

const ipc = window.chrome.ipc
const ipc = window.chrome.ipcRenderer

// Stylesheets
require('../../less/switchControls.less')
Expand Down
2 changes: 1 addition & 1 deletion js/about/autofill.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const ImmutableComponent = require('../components/immutableComponent')
const aboutActions = require('./aboutActions')
const Button = require('../components/button')

const ipc = window.chrome.ipc
const ipc = window.chrome.ipcRenderer

require('../../less/about/autofill.less')
require('../../node_modules/font-awesome/css/font-awesome.css')
Expand Down
Loading

0 comments on commit dbc0796

Please sign in to comment.