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

Commit

Permalink
Merge branch 'master' into prefs-payments
Browse files Browse the repository at this point in the history
  • Loading branch information
luixxiul authored Jan 10, 2017
2 parents 9c6b641 + 14b3bf7 commit 888f965
Show file tree
Hide file tree
Showing 156 changed files with 1,733 additions and 1,349 deletions.
9 changes: 8 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
{
"presets": ["react", "es2015"],
"presets": [
"react",
["env", {
"targets": {
"chrome": 54
}
}]
],
"plugins": [
"transform-react-inline-elements",
"transform-react-constant-elements"
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

- Platform (Win7, 8, 10? macOS? Linux distro?):

- Brave Version:
- Brave Version (revision SHA):

- Steps to reproduce:
1.
Expand Down
4 changes: 2 additions & 2 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
runtime = electron
target = 2.0.5
target = 2.0.8
target_arch = x64
brave_electron_version = 2.0.5
brave_electron_version = 2.0.8
disturl = http://brave-laptop-binaries.s3.amazonaws.com/atom-shell/dist
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Changelog

## [0.13.0](https://github.com/brave/browser-laptop/releases/v0.13.0dev)
- Muon updated to 2.0.5
- Linux sandbox added. ([#874])
- Window renderer processes no longer include Node, content renderer never did in Brave. ([#6454])
- Muon updated to 2.0.8.
- Chromium updated to 54.0.2840.100.

## [0.12.15](https://github.com/brave/browser-laptop/releases/v0.12.15dev)
- Added Yandex as a new search engine. ([#2703](https://github.com/brave/browser-laptop/issues/2703))
Expand Down
104 changes: 16 additions & 88 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ For other versions of our browser, please see:

To download the latest release, [see our releases page](https://github.com/brave/browser-laptop/releases).

For a more user-friendly download page, [please visit our website](https://brave.com/downloads.html).
You can also [visit our website](https://brave.com/downloads.html) to get the latest stable release (along with a more user-friendly download page).

## Community

Expand All @@ -28,15 +28,13 @@ For a more user-friendly download page, [please visit our website](https://brave
* See [docs/debugging.md](docs/debugging.md) for information on debugging.
* See [docs/translations.md](docs/translations.md) to learn how you can help us with translations (localization).

## Build prerequisites
## Running from source

You'll need certain packages installed before you can build and run Brave locally.
If you're setting up using Windows, please see the [Building on Windows wiki entry](https://github.com/brave/browser-laptop/wiki/(setup)-Windows-build-guide) for a full walkthrough.

### Windows
For other platforms (macOS, Linux) You'll need certain packages installed before you can build and run Brave locally.

Please see the [Building on Windows wiki entry](https://github.com/brave/browser-laptop/wiki/(setup)-Windows-build-guide)

### All other platforms
### Prerequisites

1. `nodejs` **`>= 6.1`**

Expand All @@ -46,22 +44,20 @@ Please see the [Building on Windows wiki entry](https://github.com/brave/browser

sudo npm install -g node-gyp@3.3.1

### Linux

On Debian/Ubuntu
#### On Debian/Ubuntu

````
apt-get install libgnome-keyring-dev build-essential
````

On Fedora
#### On Fedora

````
dnf install libgnome-keyring-devel rpm-build
dnf group install "Development Tools" "C Development Tools and Libraries"
````

## Installation
### Installation

After installing the prerequisites:

Expand All @@ -84,7 +80,7 @@ After installing the prerequisites:

npm install

If this fails on Linux with an error related to `abp-filter-parser-cpp`, try updating to Node 6.1 and `node-gyp` 3.3.1 (see discussion at https://github.com/brave/browser-laptop/issues/214)
If this fails on Linux with an error related to `ad-block`, try updating to Node 6.1 and `node-gyp` 3.3.1 (see discussion at https://github.com/brave/browser-laptop/issues/214)

Instead of `npm install` you may also install with [yarn](https://github.com/yarnpkg/yarn).

Expand All @@ -96,9 +92,9 @@ Additional notes on troubleshooting installation issues are in the [Troubleshoot

Some platforms are available as pre-configured VMs. See the [readme](https://github.com/brave/browser-laptop/blob/master/test/vms/vagrant/README.md) for details.

## Development
### Running Brave

To run a development version of the browser requires a few steps. The easiest way is just to use two
To run a development version of the browser requires a few steps. The easiest way is just to use two
terminals. One terminal can be used just to watch for changes to the code

npm run watch
Expand All @@ -107,7 +103,7 @@ Now actually run Brave in another terminal

npm start

To run the tests:
To run the webdriver tests:

npm run watch-test or npm run watch-all

Expand All @@ -129,82 +125,14 @@ npm config set brave:port 9001

Additional notes on troubleshooting development issues are in the [Troubleshooting](https://github.com/brave/browser-laptop/wiki/Troubleshooting) page in the Wiki.

### Running inside of a development version of Brave's Electron fork

We are using a [fork of Electron with some minor modifications](https://github.com/brave/electron). We try to upstream everything to [electron/electron](https://github.com/electron/electron) but forking allows us to take patches before upstreaming.
## Running inside of a development version of [Muon](https://github.com/brave/muon)

By default, we provide pre-built binaries when you `npm install` with our own fork of [electron-prebuilt](https://github.com/brave/electron-prebuilt).

If you want to modify the code to Electron itself, then you'll need to build it. An example of why you might do that would be exposing a new event to the webview from Electron.

Build instructions:
- [macOS build instructions](https://github.com/brave/electron/blob/master/docs/development/build-instructions-osx.md)
- [Windows build instructions](https://github.com/brave/electron/blob/master/docs/development/build-instructions-windows.md)
- [Linux build instructions](https://github.com/brave/electron/blob/master/docs/development/build-instructions-linux.md)

Once you're happy with the changes you've made in the electron fork, you can test the changes locally by building and then copying the output files over the `node_modules/electron-prebuilt` for browser-laptop.

Assuming you have your directories in a structure such as this:

projects/
electron/
browser-laptop/

You can simply run an npm task to build and install your local electron instance:

npm run install

If your directory structure isn't side by side, you can run the following (altering the rsync as needed) command from within electron:

rsync -avz --delete out/D/Brave.app dist {{path-to-browser-laptop}}/node_modules/electron-prebuilt/dist/
If you want to modify the code to [Muon](https://github.com/brave/muon) (Brave's Electron fork), then you'll need to build it. An example of why you might do that would be exposing a new event to the webview (from Muon).

To start this process, you'll want to check out our [browser-laptop-bootstrap](https://github.com/brave/browser-laptop-bootstrap) repo. From there, [you can follow the steps in our wiki](https://github.com/brave/browser-laptop-bootstrap/wiki) to get up and running.

## Packaging for bundles, installers, and updates

In order do run any build commands, you'll need an environment variable set for `CHANNEL` (set to `'dev'`, `'beta'`, or `'stable'`).

For more information, see [docs/buildingReleases.md](docs/buildingReleases.md) which has a more detailed overview of our release process.

### macOS:

From within brave-browser you can create a .app file for distribution:

CHANNEL=dev npm run build-package

After the .app file is built you can create a dmg and update zip with:

IDENTIFIER=XYZ npm run build-installer

Where XYZ is your signing identifier.

### Windows 7,8,10 x64:

You'll also need to set the `CERT` and `CERT_PASSWORD` environment variables with your [authenticode signing cert and password](https://blogs.msdn.microsoft.com/ieinternals/2011/03/22/everything-you-need-to-know-about-authenticode-code-signing/) if you want to build an installer.

To set these values, you can either set the environment on a per-session basis (`$env:CHANNEL="dev"`) or update your [system/user environment variables](http://www.computerhope.com/issues/ch000549.htm).

You must also have NSIS 3.0rc2 or later installed and `makensis`'s folder must be in your PATH.

To create a folder with the app .exe and all dependencies you can run:

CHANNEL=dev npm run build-package

After the above folder is created, you can create a setup (exe, msi, RELEASES file and update nupkg) with:

npm run build-installer

### Linux:

To create a package:

CHANNEL=dev npm run build-package

To create a dev package:

CHANNEL=dev npm run build-package

Finally run:

npm run build-installer

You will see a .deb and .rpm files in dist/
Please [see our wiki entry](https://github.com/brave/browser-laptop/wiki/Packaging-for-bundles,-installers,-and-updates) for more information about packaging.
36 changes: 17 additions & 19 deletions app/adBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,16 @@
'use strict'

const URL = require('url')
const ABPFilterParserLib = require('abp-filter-parser-cpp')
const ABPFilterParser = ABPFilterParserLib.ABPFilterParser
const FilterOptions = ABPFilterParserLib.FilterOptions
const {AdBlockClient, FilterOptions} = require('ad-block')
const DataFile = require('./dataFile')
const Filtering = require('./filtering')
const appConfig = require('../js/constants/appConfig')
const debounce = require('../js/lib/debounce')
// Maintains a map between a resource uuid and an adblock instance
const adblockInstances = new Map()
const defaultAdblock = new ABPFilterParser()
const defaultSafeBrowsing = new ABPFilterParser()
const regions = require('abp-filter-parser-cpp/lib/regions')
const defaultAdblock = new AdBlockClient()
const defaultSafeBrowsing = new AdBlockClient()
const regions = require('ad-block/lib/regions')
const getSetting = require('../js/settings').getSetting
const {ADBLOCK_CUSTOM_RULES} = require('../js/constants/settings')
const customFilterRulesUUID = 'CE61F035-9F0A-4999-9A5A-D4E46AF676F7'
Expand Down Expand Up @@ -66,9 +64,9 @@ const startAdBlocking = (adblock, resourceName, shouldCheckMainFrame) => {
})
}

module.exports.initInstance = (parser, resourceName, shouldCheckMainFrame) => {
DataFile.init(resourceName, startAdBlocking.bind(null, parser, resourceName, shouldCheckMainFrame),
(data) => parser.deserialize(data))
module.exports.initInstance = (adBlockClient, resourceName, shouldCheckMainFrame) => {
DataFile.init(resourceName, startAdBlocking.bind(null, adBlockClient, resourceName, shouldCheckMainFrame),
(data) => adBlockClient.deserialize(data))
return module.exports
}

Expand Down Expand Up @@ -104,29 +102,29 @@ const registerAppConfigForResource = (uuid, enabled, version) => {
module.exports.updateAdblockDataFiles = (uuid, enabled, version = 2, shouldCheckMainFrame = false) => {
registerAppConfigForResource(uuid, enabled, version)
if (!adblockInstances.has(uuid)) {
const parser = new ABPFilterParser()
adblockInstances.set(uuid, parser)
module.exports.initInstance(parser, uuid, shouldCheckMainFrame)
const adBlockClient = new AdBlockClient()
adblockInstances.set(uuid, adBlockClient)
module.exports.initInstance(adBlockClient, uuid, shouldCheckMainFrame)
}
}

module.exports.updateAdblockCustomRules = debounce((rules) => {
let parser
let adBlockClient
registerAppConfigForResource(customFilterRulesUUID, true, 1)
if (!adblockInstances.has(customFilterRulesUUID)) {
parser = new ABPFilterParser()
adBlockClient = new AdBlockClient()
} else {
parser = adblockInstances.get(customFilterRulesUUID)
adBlockClient = adblockInstances.get(customFilterRulesUUID)
}
parser.clear()
parser.parse(rules)
adBlockClient.clear()
adBlockClient.parse(rules)

if (!adblockInstances.has(customFilterRulesUUID)) {
adblockInstances.set(customFilterRulesUUID, parser)
adblockInstances.set(customFilterRulesUUID, adBlockClient)
// This is just to stay consistent with other adblock resources
// which use data files. Tests will check for this to make sure
// the resource loaded correctly.
appActions.setResourceETag(customFilterRulesUUID, '.')
startAdBlocking(parser, customFilterRulesUUID, false)
startAdBlocking(adBlockClient, customFilterRulesUUID, false)
}
}, 1500)
53 changes: 38 additions & 15 deletions app/browser/contentSettings/hostContentSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,53 @@

const { makeImmutable } = require('../../common/state/immutableUtil')

let registeredCallbacks = []
let registeredSessions = {}
let registeredPrivateSessions = {}

module.exports.setContentSettings = (contentSettings) => {
module.exports.setContentSettings = (contentSettings, incognito) => {
contentSettings = makeImmutable(contentSettings)
contentSettings.forEach((settings, contentType) => {
for (let partition in registeredSessions) {
registeredSessions[partition].contentSettings.clearForOneType(contentType)
}
settings.forEach((setting) => {
module.exports.setContentSetting(setting.get('primaryPattern'), setting.get('secondaryPattern'),
contentType, setting.get('resourceId'), setting.get('setting'))

const partitions = incognito ? registeredPrivateSessions : registeredSessions
for (let partition in partitions) {
const ses = partitions[partition]

contentSettings.forEach((settings, contentType) => {
ses.contentSettings.clearForOneType(contentType)
settings.forEach((setting) => {
module.exports.setContentSetting(ses, setting.get('primaryPattern'), setting.get('secondaryPattern'),
contentType, setting.get('resourceId'), setting.get('setting'))
})
})
for (let partition in registeredSessions) {
registeredSessions[partition].webRequest.handleBehaviorChanged()
}
})
ses.webRequest.handleBehaviorChanged()
}
}

module.exports.setContentSetting = (ses, primaryUrl, secondaryUrl = '*', contentType, resourceId = '', setting) => {
ses.contentSettings.set(primaryUrl, secondaryUrl, contentType, resourceId, setting)
}

module.exports.setContentSetting = (primaryUrl, secondaryUrl = '*', contentType, resourceId = '', setting) => {
for (var partition in registeredSessions) {
registeredSessions[partition].contentSettings.set(primaryUrl, secondaryUrl, contentType, resourceId, setting)
const runCallback = (cb, incognito) => {
let settings = cb(incognito)

if (typeof settings !== 'object') {
console.warn('contentSettings callback did not return an object:', settings)
return
}

module.exports.setContentSettings(settings, incognito)
}

module.exports.init = (ses, partition, isPrivate) => {
if (isPrivate) {
registeredPrivateSessions[partition] = ses
}
registeredSessions[partition] = ses
registeredCallbacks.forEach((fn) => fn(isPrivate))
}

module.exports.registerContentSettings = (cb) => {
let fn = runCallback.bind(this, cb)
registeredCallbacks.push(fn)
return fn
}
19 changes: 19 additions & 0 deletions app/browser/reducers/clipboardReducer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

'use strict'

const appConstants = require('../../../js/constants/appConstants')
const {clipboard} = require('electron')

const clipboardReducer = (state, action) => {
switch (action.actionType) {
case appConstants.APP_CLIPBOARD_TEXT_UPDATED:
clipboard.writeText(action.text)
break
}
return state
}

module.exports = clipboardReducer
3 changes: 3 additions & 0 deletions app/browser/reducers/flashReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ const flashReducer = (state, action) => {
case appConstants.APP_SET_STATE:
flash.init()
break
case appConstants.APP_FLASH_PERMISSION_REQUESTED:
flash.showFlashMessageBox(action.get('location'), action.get('senderTabId'))
break
}
return state
}
Expand Down
3 changes: 3 additions & 0 deletions app/browser/reducers/tabsReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ const tabsReducer = (state, action) => {
}
break
}
case appConstants.APP_TAB_CLONED:
state = tabs.clone(state, action)
break
case windowConstants.WINDOW_SET_AUDIO_MUTED:
state = tabs.setAudioMuted(state, action)
break
Expand Down
Loading

0 comments on commit 888f965

Please sign in to comment.