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 #13473 from brave/C65-master
Browse files Browse the repository at this point in the history
C65 master
  • Loading branch information
bsclifton committed Mar 20, 2018
1 parent 23e50ad commit bc8324e
Show file tree
Hide file tree
Showing 27 changed files with 379 additions and 317 deletions.
6 changes: 3 additions & 3 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
runtime = electron
target_arch = x64
brave_electron_version = 5.0.6
chromedriver_version = 2.33
target = v5.0.6
brave_electron_version = 5.1.0
chromedriver_version = 2.35
target = v5.1.0
disturl=https://brave-laptop-binaries.s3.amazonaws.com/atom-shell/dist/
build_from_source = true
18 changes: 9 additions & 9 deletions app/browser/reducers/ledgerReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@

const Immutable = require('immutable')
const {BrowserWindow} = require('electron')
const {getWebContents} = require('../webContentsCache')

// Constants
const appConstants = require('../../../js/constants/appConstants')
const windowConstants = require('../../../js/constants/windowConstants')
const settings = require('../../../js/constants/settings')
const tabActionConstants = require('../../common/constants/tabAction')

// State
const ledgerState = require('../../common/state/ledgerState')
Expand Down Expand Up @@ -369,22 +371,20 @@ const ledgerReducer = (state, action, immutableAction) => {
state = ledgerApi.pageDataChanged(state)
break
}
case windowConstants.WINDOW_GOT_RESPONSE_DETAILS:
case tabActionConstants.FINISH_NAVIGATION:
{
if (!getSetting(settings.PAYMENTS_ENABLED)) {
break
}

// Only capture response for the page (not sub resources, like images, JavaScript, etc)
if (action.getIn(['details', 'resourceType']) === 'mainFrame') {
const pageUrl = action.getIn(['details', 'newURL'])

// create a page view event if this is a page load on the active tabId
const lastActiveTabId = pageDataState.getLastActiveTabId(state)
const tabId = action.get('tabId')
// create a page view event if this is a page load on the active tabId
const lastActiveTabId = pageDataState.getLastActiveTabId(state)
const tabId = action.get('tabId')
const tab = getWebContents(tabId)
if (tab && !tab.isDestroyed()) {
if (!lastActiveTabId || tabId === lastActiveTabId) {
state = ledgerApi.pageDataChanged(state, {
location: pageUrl,
location: tab.getURL(),
tabId
})
}
Expand Down
7 changes: 0 additions & 7 deletions app/browser/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */

const appActions = require('../../js/actions/appActions')
const windowActions = require('../../js/actions/windowActions')
const tabActions = require('../common/actions/tabActions')
const config = require('../../js/constants/config')
const Immutable = require('immutable')
Expand Down Expand Up @@ -715,12 +714,6 @@ const api = {
appActions.updatePassword(username, origin, tabId)
})

tab.on('did-get-response-details', (evt, status, newURL, originalURL, httpResponseCode, requestMethod, referrer, headers, resourceType) => {
if (resourceType === 'mainFrame') {
windowActions.gotResponseDetails(tabId, {status, newURL, originalURL, httpResponseCode, requestMethod, referrer, resourceType})
}
})

tab.on('media-started-playing', (e) => {
let tabValue = getTabValue(tabId)
if (tabValue) {
Expand Down
12 changes: 8 additions & 4 deletions app/common/state/contextMenuState.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,42 @@
const Immutable = require('immutable')
const assert = require('assert')
const { makeImmutable, isMap } = require('./immutableUtil')
const uuid = require('uuid')

const validateState = function (state) {
state = makeImmutable(state)
assert.ok(isMap(state), 'state must be an Immutable.Map')
return state
}

let contextMenuDetail = Immutable.Map()

const api = {
setContextMenu: (windowState, detail) => {
detail = makeImmutable(detail)
windowState = validateState(windowState)

if (!detail) {
if (windowState.getIn(['contextMenuDetail', 'type']) === 'hamburgerMenu') {
if (contextMenuDetail.get('type') === 'hamburgerMenu') {
windowState = windowState.set('hamburgerMenuWasOpen', true)
} else {
windowState = windowState.set('hamburgerMenuWasOpen', false)
}
contextMenuDetail = Immutable.Map()
windowState = windowState.delete('contextMenuDetail')
} else {
if (!(detail.get('type') === 'hamburgerMenu' && windowState.get('hamburgerMenuWasOpen'))) {
windowState = windowState.set('contextMenuDetail', detail)
contextMenuDetail = detail
windowState = windowState.set('contextMenuDetail', uuid())
}
windowState = windowState.set('hamburgerMenuWasOpen', false)
}

return windowState
},

getContextMenu: (windowState) => {
windowState = validateState(windowState)
return windowState.get('contextMenuDetail', Immutable.Map())
return contextMenuDetail
},

selectedIndex: (windowState) => {
Expand Down
4 changes: 2 additions & 2 deletions app/common/tracing.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ exports.trace = (obj, ...args) => {
}
return function (...fnArgs) {
metadata.name = propKey
muon.crashReporter.setCrashKeyValue('javascript-info', JSON.stringify(metadata))
muon.crashReporter.setJavascriptInfoCrashValue(JSON.stringify(metadata))
let result, end, exception
const start = timer.now()
try {
Expand All @@ -64,7 +64,7 @@ exports.trace = (obj, ...args) => {
metadata.stack = e.stack != null ? e.stack : e.name + ': ' + e.message
exception = e
}
muon.crashReporter.setCrashKeyValue('javascript-info', JSON.stringify(metadata))
muon.crashReporter.setJavascriptInfoCrashValue(JSON.stringify(metadata))
if (exception) {
muon.crashReporter.dumpWithoutCrashing()
throw exception
Expand Down
10 changes: 2 additions & 8 deletions app/crash-herald.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,13 @@ const {app} = require('electron')
const version = app.getVersion()
const channel = Channel.channel()

const crashKeys = {
'_version': version,
'channel': channel
}

const initCrashKeys = () => {
// set muon-app-version switch to pass version to renderer processes
app.commandLine.appendSwitch('muon-app-version', version)
app.commandLine.appendSwitch('muon-app-channel', channel)

for (let key in crashKeys) {
muon.crashReporter.setCrashKeyValue(key, crashKeys[key])
}
muon.crashReporter.setVersionCrashValue(version)
muon.crashReporter.setChannelCrashValue(channel)
}

exports.init = (enabled) => {
Expand Down
6 changes: 0 additions & 6 deletions app/filtering.js
Original file line number Diff line number Diff line change
Expand Up @@ -582,12 +582,6 @@ function registerForDownloadListener (session) {
const hostWebContents = webContents.hostWebContents || webContents
const win = BrowserWindow.fromWebContents(hostWebContents) || BrowserWindow.getFocusedWindow()

// TODO(bridiver) - move this fix to muon
const controller = webContents.controller()
if (controller && controller.isValid() && controller.isInitialNavigation()) {
webContents.forceClose()
}

item.setPrompt(getSetting(settings.DOWNLOAD_ALWAYS_ASK) || false)

const downloadId = item.getGuid()
Expand Down
2 changes: 1 addition & 1 deletion app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const telemetry = require('./telemetry')
telemetry.setCheckpoint('init')

const handleUncaughtError = (stack, message) => {
muon.crashReporter.setCrashKeyValue('javascript-info', JSON.stringify({stack, message}))
muon.crashReporter.setJavascriptInfoCrashValue(JSON.stringify({stack, message}))
muon.crashReporter.dumpWithoutCrashing()

if (!ready) {
Expand Down
4 changes: 2 additions & 2 deletions app/renderer/components/common/browserButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ const styles = StyleSheet.create({

browserButton_primaryColor: {
background: globalStyles.button.primary.background,
borderLeft: '2px solid transparent',
borderRight: '2px solid transparent',
borderLeft: `2px solid ${globalStyles.button.primary.gradientColor1}`,
borderRight: `2px solid ${globalStyles.button.primary.gradientColor2}`,
borderTop: `2px solid ${globalStyles.button.primary.gradientColor1}`,
borderBottom: `2px solid ${globalStyles.button.primary.gradientColor2}`,
cursor: 'pointer',
Expand Down
5 changes: 4 additions & 1 deletion app/renderer/components/common/contextMenu/contextMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ const windowActions = require('../../../../../js/actions/windowActions')
// Constants
const keyCodes = require('../../../../common/constants/keyCodes')

// State
const contextMenuState = require('../../../../common/state/contextMenuState')

// Utils
const frameStateUtil = require('../../../../../js/state/frameStateUtil')
const {separatorMenuItem} = require('../../../../common/commonMenu')
Expand Down Expand Up @@ -218,7 +221,7 @@ class ContextMenu extends React.Component {
const currentWindow = state.get('currentWindow')
const activeFrame = frameStateUtil.getActiveFrame(currentWindow) || Immutable.Map()
const selectedIndex = currentWindow.getIn(['ui', 'contextMenu', 'selectedIndex'], null)
const contextMenuDetail = currentWindow.get('contextMenuDetail', Immutable.Map())
const contextMenuDetail = contextMenuState.getContextMenu(currentWindow)

const props = {}
props.lastZoomPercentage = activeFrame.get('lastZoomPercentage')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,8 @@ const styles = StyleSheet.create({
},

item: {
maxWidth: '420px',
maxWidth: 'inherit',
minWidth: 'inherit',
paddingTop: '6px',
paddingRight: '10px',
paddingBottom: '6px',
Expand Down
3 changes: 2 additions & 1 deletion app/renderer/components/frame/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const windowStore = require('../../../../js/stores/windowStore')
const appStoreRenderer = require('../../../../js/stores/appStoreRenderer')

// State
const contextMenuState = require('../../../common/state/contextMenuState')
const siteSettings = require('../../../../js/state/siteSettings')
const siteSettingsState = require('../../../common/state/siteSettingsState')
const tabState = require('../../../common/state/tabState')
Expand Down Expand Up @@ -866,7 +867,7 @@ class Frame extends React.Component {
const allSiteSettings = siteSettingsState.getAllSiteSettings(state, isPrivate)
const frameSiteSettings = siteSettings.getSiteSettingsForURL(allSiteSettings, location) || Immutable.Map()

const contextMenu = currentWindow.get('contextMenuDetail')
const contextMenu = contextMenuState.getContextMenu(currentWindow)
const tab = tabId && tabId > -1 && tabState.getByTabId(state, tabId)

const props = {}
Expand Down
2 changes: 1 addition & 1 deletion docs/state.md
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ WindowStore
},
cleanedOnShutdown: boolean, // whether app data was successfully cleared on shutdown
closedFrames: [], // holds the same type of frame objects as frames
contextMenuDetail: {
contextMenuDetail: { // currently using uuid hack to avoid serializing click function in template
bottom: number, // the bottom position of the context menu
left: number, // the left position of the context menu
maxHeight: number, // the maximum height of the context menu
Expand Down
2 changes: 1 addition & 1 deletion img/windows/win10_close.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion img/windows/win10_close_white.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion img/windows/win10_expand.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion img/windows/win10_minimize.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion img/windows/win10_restore.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 8 additions & 15 deletions js/actions/windowActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -550,9 +550,16 @@ const windowActions = {
* @param {Object} detail - The context menu detail
*/
setContextMenuDetail: function (detail) {
// TODO(darkdh): This is a hack to prevent dispatch from serializing
// click function in template. `contextMenuDetail` is just a uuid to trigger
// state update for new menu
const Immutable = require('immutable')
const contextMenuState = require('../../app/common/state/contextMenuState')
let state = contextMenuState.setContextMenu(Immutable.Map(), detail)
const contextMenuDetail = state.get('contextMenuDetail')
dispatch({
actionType: windowConstants.WINDOW_SET_CONTEXT_MENU_DETAIL,
detail
contextMenuDetail
})
},

Expand Down Expand Up @@ -955,20 +962,6 @@ const windowActions = {
})
},

/**
* Used to get response details (such as the HTTP response code) from a response
* See `eventStore.js` for an example use-case
* @param {number} tabId - the tab id to set
* @param {Object} details - object containing response details
*/
gotResponseDetails: function (tabId, details) {
dispatch({
actionType: windowConstants.WINDOW_GOT_RESPONSE_DETAILS,
tabId,
details
})
},

/**
* Fired when the mouse clicks or hovers over a bookmark folder in the bookmarks toolbar
* @param {number} folderId - from the siteDetail for the bookmark folder
Expand Down
2 changes: 1 addition & 1 deletion js/constants/appConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = {
name: 'Brave',
contactUrl: 'mailto:support+laptop@brave.com',
quitTimeout: isTest ? 3 * 1000 : 10 * 1000,
sessionSaveInterval: 1000 * 60 * 5,
sessionSaveInterval: process.env.BRAVE_SESSION_SAVE_INTERVAL * 1000 || 1000 * 60 * 5,
resourceNames: {
ADBLOCK: 'adblock',
SAFE_BROWSING: 'safeBrowsing',
Expand Down
1 change: 0 additions & 1 deletion js/constants/windowConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ const windowConstants = {
WINDOW_RESET_MENU_STATE: _,
WINDOW_SET_MENUBAR_SELECTED_INDEX: _,
WINDOW_SET_LAST_FOCUSED_SELECTOR: _,
WINDOW_GOT_RESPONSE_DETAILS: _,
WINDOW_SET_BOOKMARKS_TOOLBAR_SELECTED_FOLDER_ID: _,
WINDOW_SET_MODAL_DIALOG_DETAIL: _,
WINDOW_WIDEVINE_SITE_ACCESSED_WITHOUT_INSTALL: _,
Expand Down
25 changes: 16 additions & 9 deletions js/stores/windowStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -480,21 +480,28 @@ const doAction = (action) => {
windowState = windowState.delete('bookmarkFolderDetail')
break
case windowConstants.WINDOW_AUTOFILL_SELECTION_CLICKED:
windowState = contextMenuState.setContextMenu(windowState)
ipc.send('autofill-selection-clicked', action.tabId, action.value, action.frontEndId, action.index)
windowState = windowState.delete('contextMenuDetail')
break
case windowConstants.WINDOW_AUTOFILL_POPUP_HIDDEN:
if (!action.detail &&
windowState.getIn(['contextMenuDetail', 'type']) === 'autofill' &&
windowState.getIn(['contextMenuDetail', 'tabId']) === action.tabId) {
windowState = windowState.delete('contextMenuDetail')
if (action.notify) {
ipc.send('autofill-popup-hidden', action.tabId)
{
const contextMenuDetail = contextMenuState.getContextMenu(windowState)
if (!action.detail &&
contextMenuDetail.get('type') === 'autofill' &&
contextMenuDetail.get('tabId') === action.tabId) {
windowState = contextMenuState.setContextMenu(windowState)
if (action.notify) {
ipc.send('autofill-popup-hidden', action.tabId)
}
}
break
}
break
case windowConstants.WINDOW_SET_CONTEXT_MENU_DETAIL:
windowState = contextMenuState.setContextMenu(windowState, action.detail)
if (action.contextMenuDetail) {
windowState = windowState.set('contextMenuDetail', action.contextMenuDetail)
} else {
windowState = windowState.delete('contextMenuDetail')
}
break
case windowConstants.WINDOW_SET_POPUP_WINDOW_DETAIL:
if (!action.detail) {
Expand Down
3 changes: 2 additions & 1 deletion less/button.less
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ span.buttonSeparator {

&.primaryButton {
background: linear-gradient(@braveLightOrange, @braveOrange);
border: 2px solid transparent;
border-left: 2px solid @braveLightOrange;
border-right: 2px solid @braveOrange;
border-top: 2px solid @braveLightOrange;
border-bottom: 2px solid @braveOrange;
box-shadow: @buttonShadow;
Expand Down
Loading

0 comments on commit bc8324e

Please sign in to comment.