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 dev-channel
Browse files Browse the repository at this point in the history
  • Loading branch information
bbondy committed Nov 1, 2016
2 parents 46d1085 + 3874b48 commit 8bd4696
Show file tree
Hide file tree
Showing 29 changed files with 427 additions and 179 deletions.
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Brave welcomes contributions via [pull requests](https://github.com/brave/browse

* Make commits in logical units. If needed, run `git rebase -i` to squash commits before opening a pull request.
* New features and most other pull requests require a new [test](https://github.com/brave/browser-laptop/blob/master/docs/tests.md) to be written before the pull request will be accepted. Some exceptions would be a tweak to an area of code that doesn't have tests yet, text changes, build config changes, things that can't be tested due to test suite limitations, etc.
* Use Github [auto-closing keywords](https://help.github.com/articles/closing-issues-via-commit-messages/) in the commit message, and make the commit messsage body as descriptive as necessary. Ex:
* Use Github [auto-closing keywords](https://help.github.com/articles/closing-issues-via-commit-messages/) in the commit message, and make the commit message body as descriptive as necessary. Ex:

````
Add contributing guide
Expand Down
2 changes: 1 addition & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
runtime = electron
target = 1.4.0
target_arch = x64
brave_electron_version = 1.4.22
brave_electron_version = 1.4.23
disturl = https://atom.io/download/atom-shell
12 changes: 1 addition & 11 deletions app/browser/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,21 +322,11 @@ const createHistorySubmenu = () => {
CommonMenu.separatorMenuItem,
*/
{
label: locale.translation('clearHistory'),
label: locale.translation('clearBrowsingData'),
accelerator: 'Shift+CmdOrCtrl+Delete',
click: function (item, focusedWindow) {
CommonMenu.sendToFocusedWindow(focusedWindow, [messages.SHORTCUT_OPEN_CLEAR_BROWSING_DATA_PANEL, {browserHistory: true}])
}
}, {
label: locale.translation('clearCache'),
click: function (item, focusedWindow) {
CommonMenu.sendToFocusedWindow(focusedWindow, [messages.SHORTCUT_OPEN_CLEAR_BROWSING_DATA_PANEL, {cachedImagesAndFiles: true}])
}
}, {
label: locale.translation('clearSiteData'),
click: function (item, focusedWindow) {
CommonMenu.sendToFocusedWindow(focusedWindow, [messages.SHORTCUT_OPEN_CLEAR_BROWSING_DATA_PANEL, {allSiteCookies: true, cachedImagesAndFiles: true}])
}
}
]
submenu = submenu.concat(menuUtil.createRecentlyClosedMenuItems(Immutable.fromJS(Object.keys(closedFrames).map(key => closedFrames[key]))))
Expand Down
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://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 '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://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="index-load-script.js" defer></script>
<script src="ext/l20n.min.js" async></script>
Expand Down
2 changes: 1 addition & 1 deletion app/extensions/brave/index.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'; img-src * data:; style-src 'self' 'unsafe-inline'; font-src 'self'; 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/ https://suggestqueries.google.com https://ac.duckduckgo.com https://completion.amazon.com https://search.yahoo.com https://api.bing.com https://brave-download.global.ssl.fastly.net https://brave-laptop-updates.global.ssl.fastly.net https://laptop-updates-pre.brave.com https://brave-laptop-updates-pre.brave.com; object-src 'self'; plugin-types application/browser-plugin"/>
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; form-action 'none'; referrer no-referrer; script-src 'self'; img-src * data:; style-src 'self' 'unsafe-inline'; font-src 'self'; 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/ 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://brave-download.global.ssl.fastly.net https://brave-laptop-updates.global.ssl.fastly.net https://laptop-updates-pre.brave.com https://brave-laptop-updates-pre.brave.com; object-src 'self'; plugin-types application/browser-plugin"/>
<title>Brave</title>
<script src="gen/app.entry.js" async></script>
<script src="ext/l20n.min.js" async></script>
Expand Down
1 change: 1 addition & 0 deletions app/extensions/brave/locales/en-US/menu.properties
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ back=Back
forward=Forward
reopenLastClosedWindow=Reopen Last Closed Window
showAllHistory=Show History
clearBrowsingData=Clear Browsing Data…
clearHistory=Clear History…
clearCache=Clear Cache…
clearSiteData=Clear All Cookies and Site Data…
Expand Down
55 changes: 31 additions & 24 deletions app/ledger.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ let addFundsMessage
let reconciliationMessage
let notificationPaymentDoneMessage
let notificationTryPaymentsMessage
let suppressNotifications = false
let reconciliationNotificationShown = false
let notificationTimeout = null

// TODO(bridiver) - create a better way to get setting changes
Expand Down Expand Up @@ -323,9 +321,9 @@ if (ipc) {
if (message === addFundsMessage) {
appActions.hideMessageBox(message)
if (buttonIndex === 0) {
// Don't show notifications for the next 6 hours.
suppressNotifications = true
setTimeout(() => { suppressNotifications = false }, 6 * msecs.hour)
// "Later" -- wait 6 hours to re-show "reconciliation soon" notification.
const nextTime = ledgerInfo.reconcileStamp + 6 * msecs.hour
appActions.changeSetting(settings.PAYMENTS_NOTIFICATION_RECONCILE_SOON_TIMESTAMP, nextTime)
} else {
// Open payments panel
if (win) {
Expand All @@ -339,9 +337,6 @@ if (ipc) {
win.webContents.send(messages.SHORTCUT_NEW_FRAME,
'about:preferences#payments', { singleFrame: true })
}
// If > 24 hours has passed, it might be time to show the reconciliation
// message again
setTimeout(() => { reconciliationNotificationShown = false }, 1 * msecs.day)
} else if (message === notificationPaymentDoneMessage) {
appActions.hideMessageBox(message)
} else if (message === notificationTryPaymentsMessage) {
Expand Down Expand Up @@ -889,6 +884,7 @@ var ledgerInfo = {
creating: false,
created: false,

reconcileFrequency: undefined,
reconcileStamp: undefined,

transactions:
Expand Down Expand Up @@ -1194,6 +1190,7 @@ var getStateInfo = (state) => {
ledgerInfo.created = !!state.properties.wallet
ledgerInfo.creating = !ledgerInfo.created

ledgerInfo.reconcileFrequency = state.properties.days
ledgerInfo.reconcileStamp = state.reconcileStamp

if (info) {
Expand Down Expand Up @@ -1442,8 +1439,7 @@ var pathName = (name) => {

const showNotifications = () => {
if (getSetting(settings.PAYMENTS_ENABLED) &&
getSetting(settings.PAYMENTS_NOTIFICATIONS) &&
!suppressNotifications) {
getSetting(settings.PAYMENTS_NOTIFICATIONS)) {
showEnabledNotifications()
} else if (!getSetting(settings.PAYMENTS_ENABLED)) {
showDisabledNotifications()
Expand Down Expand Up @@ -1500,24 +1496,35 @@ const showEnabledNotifications = () => {
persist: false
}
})
} else if (!reconciliationNotificationShown) {
reconciliationMessage = reconciliationMessage || locale.translation('reconciliationNotification')
appActions.showMessageBox({
greeting: locale.translation('updateHello'),
message: reconciliationMessage,
buttons: [
{text: locale.translation('reviewSites'), className: 'primary'}
],
options: {
style: 'greetingStyle',
persist: false
}
})
reconciliationNotificationShown = true
} else if (shouldShowNotificationReviewPublishers()) {
showNotificationReviewPublishers()
}
}
}

const shouldShowNotificationReviewPublishers = () => {
const nextTime = getSetting(settings.PAYMENTS_NOTIFICATION_RECONCILE_SOON_TIMESTAMP)
return !nextTime || (underscore.now() > nextTime)
}

const showNotificationReviewPublishers = () => {
const nextTime = ledgerInfo.reconcileStamp + (ledgerInfo.reconcileFrequency - 1) * msecs.day
appActions.changeSetting(settings.PAYMENTS_NOTIFICATION_RECONCILE_SOON_TIMESTAMP, nextTime)

reconciliationMessage = reconciliationMessage || locale.translation('reconciliationNotification')
appActions.showMessageBox({
greeting: locale.translation('updateHello'),
message: reconciliationMessage,
buttons: [
{text: locale.translation('reviewSites'), className: 'primary'}
],
options: {
style: 'greetingStyle',
persist: false
}
})
}

// Called from observeTransactions() when we see a new payment (transaction).
const showNotificationPaymentDone = (transactionContributionFiat) => {
notificationPaymentDoneMessage = locale.translation('notificationPaymentDone')
Expand Down
1 change: 1 addition & 0 deletions app/locale.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ var rendererIdentifiers = function () {
'clearCache',
'clearHistory',
'clearSiteData',
'clearBrowsingData',
'recentlyClosed',
'recentlyVisited',
'bookmarks',
Expand Down
63 changes: 63 additions & 0 deletions app/renderer/lib/suggestion.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

const urlParser = require('url')
const appConfig = require('../../../js/constants/appConfig')
const _ = require('underscore')
const Immutable = require('immutable')

const sigmoid = (t) => {
return 1 / (1 + Math.pow(Math.E, -t))
Expand Down Expand Up @@ -112,3 +114,64 @@ module.exports.normalizeLocation = (location) => {
location = location.replace(/^https:\/\//, '')
return location
}

/*
* return a site representing the simple location for a
* set of related sites without a history item for the
* simple location.
*
* This is used to show a history suggestion for something
* like www.google.com if it has not been visited but
* there are two or more locations with that prefix containing
* path info or parameters
*
* @param {Array[Object]} sites - array of similar sites
*/
var virtualSite = (sites) => {
// array of sites without paths or query params
var simple = sites.filter((parsed) => {
return (parsed.hash === null && parsed.search === null && parsed.query === null && parsed.pathname === '/')
})
// if there are no simple locations then we will build and return one
if (simple.length === 0) {
// we need to create a virtual history item
return Immutable.Map({
location: sites[0].protocol + '//' + sites[0].host,
count: 0,
title: sites[0].host,
lastAccessedTime: (new Date()).getTime()
})
} else {
return
}
}

/*
* Create an array of simple locations from history
* The simple locations will be the root domain for a location
* without parameters or path
*
* @param {ImmutableList[ImmutableMap]} - history
*/
module.exports.createVirtualHistoryItems = (historySites) => {
// parse each history item
var parsedHistorySites = historySites.map((site) => {
return urlParser.parse(site.get('location'))
}).toArray()
// group them by host
var grouped = _.groupBy(parsedHistorySites, (parsedSite) => {
return parsedSite.host || 'unknown'
})
// find groups with more than 2 of the same host
var multiGroupKeys = _.filter(_.keys(grouped), (k) => {
return grouped[k].length > 2
})
// potentially create virtual history items
var virtualHistorySites = _.map(multiGroupKeys, (location) => {
return virtualSite(grouped[location])
})
virtualHistorySites = _.filter(virtualHistorySites, (site) => {
return !!site
})
return virtualHistorySites
}
1 change: 1 addition & 0 deletions app/sessionStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ module.exports.cleanPerWindowData = (perWindowData, isShutdown) => {
if (frame.findDetail) {
delete frame.findDetail.numberOfMatches
delete frame.findDetail.activeMatchOrdinal
delete frame.findDetail.internalFindStatePresent
}
delete frame.findbarShown
// Don't restore full screen state
Expand Down
1 change: 1 addition & 0 deletions docs/state.md
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ WindowStore
ledgerInfo: {
creating: boolean, // wallet is being created
created: boolean, // wallet is created
reconcileFrequency: number, // duration between each reconciliation in days
reconcileStamp: number, // timestamp for the next reconcilation
transactions: [ { // contributions reconciling/reconciled
viewingId: string, // UUIDv4 for this contribution
Expand Down
5 changes: 3 additions & 2 deletions js/about/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ const getSetting = require('../settings').getSetting
const SortableTable = require('../components/sortableTable')
const Button = require('../components/button')
const searchProviders = require('../data/searchProviders')
const moment = require('moment')
const punycode = require('punycode')
const moment = require('moment')
moment.locale(navigator.language)

const adblock = appConfig.resourceNames.ADBLOCK
const cookieblock = appConfig.resourceNames.COOKIEBLOCK
Expand Down Expand Up @@ -1527,7 +1528,7 @@ class SecurityTab extends ImmutableComponent {
<Button l10nId='manageAutofillData' className='primaryButton manageAutofillDataButton'
onClick={aboutActions.newFrame.bind(null, {
location: 'about:autofill'
}, true)} />
}, true)} disabled={!getSetting(settings.AUTOFILL_ENABLED, this.props.settings)} />
</SettingsList>
<div className='sectionTitle' data-l10n-id='doNotTrackTitle' />
<SettingsList>
Expand Down
16 changes: 13 additions & 3 deletions js/components/findbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class FindBar extends ImmutableComponent {
constructor () {
super()
this.onBlur = this.onBlur.bind(this)
this.onInputFocus = this.onInputFocus.bind(this)
this.onClear = this.onClear.bind(this)
this.onKeyDown = this.onKeyDown.bind(this)
this.onChange = this.onChange.bind(this)
Expand Down Expand Up @@ -59,13 +60,16 @@ class FindBar extends ImmutableComponent {
* Focus the find in page input and select the text
*/
focus () {
const input = this.searchInput
input.focus()
input.select()
this.searchInput.focus()
}

select () {
this.searchInput.select()
}

componentDidMount () {
this.focus()
windowActions.setFindbarSelected(false)
}

componentWillUpdate (nextProps) {
Expand All @@ -75,6 +79,7 @@ class FindBar extends ImmutableComponent {
componentDidUpdate (prevProps) {
if (this.props.selected) {
this.focus()
windowActions.setFindbarSelected(false)
}
if (!this.props.findDetail || !prevProps.findDetail ||
this.props.findDetail.get('searchString') !== prevProps.findDetail.get('searchString') ||
Expand All @@ -101,6 +106,10 @@ class FindBar extends ImmutableComponent {
}
}

onInputFocus () {
this.searchInput.select()
}

onBlur (e) {
windowActions.setFindbarSelected(this.frame, false)
}
Expand Down Expand Up @@ -192,6 +201,7 @@ class FindBar extends ImmutableComponent {
spellCheck='false'
ref={(node) => { this.searchInput = node }}
value={inputValue}
onFocus={this.onInputFocus}
onKeyDown={this.onKeyDown}
onKeyUp={this.onChange} />
<span className='searchStringContainerIcon fa fa-times findClear'
Expand Down
2 changes: 1 addition & 1 deletion js/components/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,7 @@ class Frame extends ImmutableComponent {

this.webview.addEventListener('did-navigate', (e) => {
if (this.props.findbarShown) {
windowActions.setFindbarShown(this.frame, false)
this.props.onFindHide()
}

for (let message in this.notificationCallbacks) {
Expand Down
5 changes: 4 additions & 1 deletion js/components/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,9 @@ class Main extends ImmutableComponent {
windowActions.setFindbarShown(activeFrame, false)
webviewActions.stopFindInPage()
windowActions.setFindDetail(activeFrame, Immutable.fromJS({
internalFindStatePresent: false
internalFindStatePresent: false,
numberOfMatches: -1,
activeMatchOrdinal: 0
}))
}

Expand Down Expand Up @@ -1203,6 +1205,7 @@ class Main extends ImmutableComponent {
ledgerInfo={this.props.appState.get('ledgerInfo') || new Immutable.Map()}
publisherInfo={this.props.appState.get('publisherInfo') || new Immutable.Map()}
frameSiteSettings={this.frameSiteSettings(frame.get('location'))}
onFindHide={this.onFindHide}
enableNoScript={this.enableNoScript(this.frameSiteSettings(frame.get('location')))}
isPreview={frame.get('key') === this.props.windowState.get('previewFrameKey')}
isActive={FrameStateUtil.isFrameKeyActive(this.props.windowState, frame.get('key'))}
Expand Down
Loading

0 comments on commit 8bd4696

Please sign in to comment.