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 #6247 from brave/chromium54
Browse files Browse the repository at this point in the history
Chromium54
  • Loading branch information
bbondy authored Dec 16, 2016
2 parents 8b34eb3 + b0e85eb commit 6ac06a4
Show file tree
Hide file tree
Showing 126 changed files with 4,466 additions and 1,998 deletions.
6 changes: 3 additions & 3 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
runtime = electron
target = 1.4.0
target = 2.0.4
target_arch = x64
brave_electron_version = 1.4.31
disturl = https://atom.io/download/atom-shell
brave_electron_version = 2.0.4
disturl = http://brave-laptop-binaries.s3.amazonaws.com/atom-shell/dist
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## [0.13.0](https://github.com/brave/browser-laptop/releases/v0.13.0dev)
- (TODO)

## [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))
- Added Qwant as a new search engine. ([#2701](https://github.com/brave/browser-laptop/issues/2701))
Expand Down
66 changes: 31 additions & 35 deletions app/browser/basicAuth.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
const electron = require('electron')
const app = electron.app
const { app } = require('electron')
const appActions = require('../../js/actions/appActions')
const appConstants = require('../../js/constants/appConstants')
const appDispatcher = require('../../js/dispatcher/appDispatcher')
const appStore = require('../../js/stores/appStore')
const basicAuthState = require('../common/state/basicAuthState')
const { makeImmutable } = require('../common/state/immutableUtil')

// URLs to callback for auth.
let authCallbacks = {}
Expand All @@ -12,34 +10,8 @@ const cleanupAuthCallback = (tabId) => {
delete authCallbacks[tabId]
}

const runAuthCallback = (tabId, detail) => {
let cb = authCallbacks[tabId]
if (cb) {
delete authCallbacks[tabId]
if (detail) {
let username = detail.get('username')
let password = detail.get('password')
cb(username, password)
} else {
cb()
}
}
}

const doAction = (action) => {
switch (action.actionType) {
case appConstants.APP_SET_LOGIN_RESPONSE_DETAIL:
appDispatcher.waitFor([appStore.dispatchToken], () => {
runAuthCallback(action.tabId, action.detail)
})
break
default:
}
}

const basicAuth = {
init: () => {
appDispatcher.register(doAction)
init: (state, action) => {
app.on('login', (e, webContents, request, authInfo, cb) => {
e.preventDefault()
let tabId = webContents.getId()
Expand All @@ -50,11 +22,35 @@ const basicAuth = {
webContents.on('crashed', () => {
cleanupAuthCallback(tabId)
})
appActions.setLoginRequiredDetail(tabId, {
request,
authInfo
setImmediate(() => {
appActions.setLoginRequiredDetail(tabId, {
request,
authInfo
})
})
})

return state
},

setLoginResponseDetail: (state, action) => {
state = makeImmutable(state)
action = makeImmutable(action)
let tabId = action.get('tabId')
let detail = action.get('detail')
state = basicAuthState.setLoginResponseDetail(state, action)
let cb = authCallbacks[tabId]
if (cb) {
cleanupAuthCallback(tabId)
if (detail) {
let username = detail.get('username')
let password = detail.get('password')
cb(username, password)
} else {
cb()
}
}
return state
}
}

Expand Down
33 changes: 33 additions & 0 deletions app/browser/contentSettings/hostContentSettings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/* 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/. */

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

let registeredSessions = {}

module.exports.setContentSettings = (contentSettings) => {
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'))
})
for (let partition in registeredSessions) {
registeredSessions[partition].webRequest.handleBehaviorChanged()
}
})
}

module.exports.setContentSetting = (primaryUrl, secondaryUrl = '*', contentType, resourceId = '', setting) => {
for (var partition in registeredSessions) {
registeredSessions[partition].contentSettings.set(primaryUrl, secondaryUrl, contentType, resourceId, setting)
}
}

module.exports.init = (ses, partition, isPrivate) => {
registeredSessions[partition] = ses
}
27 changes: 27 additions & 0 deletions app/browser/electronDownloadItem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* 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/. */

const downloadStates = require('../../js/constants/downloadStates')

/**
* Maps downloadId to an electron download-item
*/
const downloadMap = {}

module.exports.updateElectronDownloadItem = (downloadId, item, state) => {
if (state === downloadStates.INTERRUPTED || state === downloadStates.CANCELLED || state === downloadStates.COMPLETED) {
delete downloadMap[downloadId]
} else {
downloadMap[downloadId] = item
}
}

module.exports.cancelDownload = (downloadId) =>
downloadMap[downloadId] && downloadMap[downloadId].cancel()

module.exports.pauseDownload = (downloadId) =>
downloadMap[downloadId] && downloadMap[downloadId].pause()

module.exports.resumeDownload = (downloadId) =>
downloadMap[downloadId] && downloadMap[downloadId].resume()
15 changes: 0 additions & 15 deletions app/browser/lib/patchUserDataDir.js

This file was deleted.

96 changes: 96 additions & 0 deletions app/browser/reducers/downloadsReducer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/* 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 downloadStates = require('../../../js/constants/downloadStates')
const {clipboard, BrowserWindow, shell} = require('electron')
const fs = require('fs')
const path = require('path')
const {cancelDownload, pauseDownload, resumeDownload} = require('../electronDownloadItem')
const {CANCEL, PAUSE, RESUME} = require('../../common/constants/electronDownloadItemActions')

const downloadsReducer = (state, action) => {
const download = action.downloadId ? state.getIn(['downloads', action.downloadId]) : undefined
if (!download &&
![appConstants.APP_MERGE_DOWNLOAD_DETAIL,
appConstants.APP_CLEAR_COMPLETED_DOWNLOADS].includes(action.actionType)) {
return state
}
switch (action.actionType) {
case appConstants.APP_DOWNLOAD_REVEALED:
fs.exists(download.get('savePath'), (exists) => {
if (exists) {
shell.showItemInFolder(download.get('savePath'))
} else {
shell.openItem(path.dirname(download.get('savePath')))
}
})
break
case appConstants.APP_DOWNLOAD_OPENED:
fs.exists(download.get('savePath'), (exists) => {
if (exists) {
shell.openItem(download.get('savePath'))
} else {
shell.beep()
}
})
break
case appConstants.APP_DOWNLOAD_ACTION_PERFORMED:
switch (action.downloadAction) {
case CANCEL:
// It's important to update state before the cancel since it'll remove the reference
state = state.setIn(['downloads', action.downloadId, 'state'], downloadStates.CANCELLED)
cancelDownload(action.downloadId)
break
case PAUSE:
pauseDownload(action.downloadId)
state = state.setIn(['downloads', action.downloadId, 'state'], downloadStates.PAUSED)
break
case RESUME:
resumeDownload(action.downloadId)
state = state.setIn(['downloads', action.downloadId, 'state'], downloadStates.IN_PROGRESS)
break
}
break
case appConstants.APP_DOWNLOAD_COPIED_TO_CLIPBOARD:
clipboard.writeText(download.get('url'))
break
case appConstants.APP_DOWNLOAD_DELETED:
shell.moveItemToTrash(download.get('savePath'))
state = state.deleteIn(['downloads', action.downloadId])
break
case appConstants.APP_DOWNLOAD_CLEARED:
state = state.deleteIn(['downloads', action.downloadId])
break
case appConstants.APP_DOWNLOAD_REDOWNLOADED:
const win = BrowserWindow.getFocusedWindow()
if (win) {
win.webContents.downloadURL(download.get('url'))
state = state.deleteIn(['downloads', action.downloadId])
} else {
shell.beep()
}
break
case appConstants.APP_MERGE_DOWNLOAD_DETAIL:
if (action.downloadDetail) {
state = state.mergeIn(['downloads', action.downloadId], action.downloadDetail)
} else {
state = state.deleteIn(['downloads', action.downloadId])
}
break
case appConstants.APP_CLEAR_COMPLETED_DOWNLOADS:
if (state.get('downloads')) {
const downloads = state.get('downloads')
.filter((download) =>
![downloadStates.COMPLETED, downloadStates.INTERRUPTED, downloadStates.CANCELLED].includes(download.get('state')))
state = state.set('downloads', downloads)
}
break
}
return state
}

module.exports = downloadsReducer
21 changes: 21 additions & 0 deletions app/browser/reducers/flashReducer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* 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 flash = require('../../../js/flash')
const {makeImmutable} = require('../../common/state/immutableUtil')

const flashReducer = (state, action) => {
action = makeImmutable(action)
switch (action.get('actionType')) {
case appConstants.APP_SET_STATE:
flash.init()
break
}
return state
}

module.exports = flashReducer
51 changes: 51 additions & 0 deletions app/browser/reducers/tabsReducer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/* 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 appConfig = require('../../../js/constants/appConfig')
const appConstants = require('../../../js/constants/appConstants')
const tabs = require('../tabs')
const tabState = require('../../common/state/tabState')
const windowConstants = require('../../../js/constants/windowConstants')
const { makeImmutable } = require('../../common/state/immutableUtil')

const tabsReducer = (state, action) => {
action = makeImmutable(action)
switch (action.get('actionType')) {
case appConstants.APP_SET_STATE:
state = tabs.init(state, action)
break
case appConstants.APP_TAB_CREATED:
state = tabState.maybeCreateTab(state, action)
break
case appConstants.APP_TAB_UPDATED:
state = tabState.maybeCreateTab(state, action)
break
case appConstants.APP_CLOSE_TAB:
state = tabs.removeTab(state, action)
break
case appConstants.APP_TAB_CLOSED:
state = tabState.removeTab(state, action)
break
case appConstants.APP_ALLOW_FLASH_ONCE:
case appConstants.APP_ALLOW_FLASH_ALWAYS:
{
const webContents = tabs.getWebContents(action.get('tabId'))
if (webContents && !webContents.isDestroyed() && webContents.getURL() === action.get('url')) {
webContents.authorizePlugin(appConfig.flash.resourceId)
}
break
}
case windowConstants.WINDOW_SET_AUDIO_MUTED:
state = tabs.setAudioMuted(state, action)
break
case windowConstants.WINDOW_CLOSE_FRAME:
state = tabState.closeFrame(state, action)
break
}
return state
}

module.exports = tabsReducer
Loading

0 comments on commit 6ac06a4

Please sign in to comment.