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

Commit

Permalink
Merge branch '0.13.1-branch' into enpass_password_manager
Browse files Browse the repository at this point in the history
  • Loading branch information
luixxiul authored Jan 25, 2017
2 parents 3861396 + 46ff336 commit 4e72eb0
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 13 deletions.
2 changes: 1 addition & 1 deletion app/extensions/brave/locales/en-US/preferences.properties
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ loveToHear=We'd love to hear from you.
startsWith=Brave starts with
startsWithOptionLastTime=My windows / tabs from last time
startsWithOptionHomePage=Home page
startsWithOptionNewTabPage=Dashboard
startsWithOptionNewTabPage=a new tab
tabCloseActionLastActive=Last active tab
tabCloseActionNext=Next tab
tabCloseActionFirst=First tab
Expand Down
36 changes: 26 additions & 10 deletions app/ledger.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ const ipc = electron.ipcMain
const session = electron.session

const acorn = require('acorn')
const ledgerBalance = require('ledger-balance')
const ledgerClient = require('ledger-client')
const ledgerGeoIP = require('ledger-geoip')
const ledgerPublisher = require('ledger-publisher')
const qr = require('qr-image')
const querystring = require('querystring')
const random = require('random-lib')
Expand All @@ -60,6 +56,12 @@ const ledgerUtil = require('./common/lib/ledgerUtil')
const Tabs = require('./browser/tabs')
const {fileUrl} = require('../js/lib/appUrlUtil')

// "only-when-needed" loading...
let ledgerBalance = null
let ledgerClient = null
let ledgerGeoIP = null
let ledgerPublisher = null

// TBD: remove these post beta [MTR]
const logPath = 'ledger-log.json'
const publisherPath = 'ledger-publisher.json'
Expand Down Expand Up @@ -218,10 +220,6 @@ const doAction = (action) => {
*/
var init = () => {
try {
ledgerInfo._internal.debugP = ledgerClient.prototype.boolion(process.env.LEDGER_CLIENT_DEBUG)
publisherInfo._internal.debugP = ledgerClient.prototype.boolion(process.env.LEDGER_PUBLISHER_DEBUG)
publisherInfo._internal.verboseP = ledgerClient.prototype.boolion(process.env.LEDGER_PUBLISHER_VERBOSE)

appDispatcher.register(doAction)
initialize(getSetting(settings.PAYMENTS_ENABLED))

Expand All @@ -247,6 +245,7 @@ var boot = () => {
ledgerInfo.creating = true
appActions.updateLedgerInfo({ creating: true })
try {
clientprep()
client = ledgerClient(null, underscore.extend({ roundtrip: roundtrip }, clientOptions), null)
} catch (ex) {
appActions.updateLedgerInfo({})
Expand Down Expand Up @@ -653,6 +652,7 @@ var initialize = (paymentsEnabled) => {
}
if (client) return

if (!ledgerPublisher) ledgerPublisher = require('ledger-publisher')
cacheRuleSet(ledgerPublisher.rules)

fs.access(pathName(statePath), fs.FF_OK, (err) => {
Expand All @@ -674,6 +674,7 @@ var initialize = (paymentsEnabled) => {
getStateInfo(state)

try {
clientprep()
client = ledgerClient(state.personaId,
underscore.extend(state.options, { roundtrip: roundtrip }, clientOptions),
state)
Expand All @@ -698,8 +699,12 @@ var initialize = (paymentsEnabled) => {
} catch (ex) {
return console.log('ledger client creation error: ' + ex.toString() + '\n' + ex.stack)
}
if (client.sync(callback) === true) run(random.randomInt({ min: msecs.minute, max: 10 * msecs.minute }))
cacheRuleSet(state.ruleset)

// speed-up browser start-up by delaying the first synchronization action
setTimeout(() => {
if (client.sync(callback) === true) run(random.randomInt({ min: msecs.minute, max: 10 * msecs.minute }))
cacheRuleSet(state.ruleset)
}, 3 * msecs.second)

// Make sure bravery props are up-to-date with user settings
setPaymentInfo(getSetting(settings.PAYMENTS_CONTRIBUTION_AMOUNT))
Expand All @@ -713,6 +718,13 @@ var initialize = (paymentsEnabled) => {
})
}

var clientprep = () => {
if (!ledgerClient) ledgerClient = require('ledger-client')
ledgerInfo._internal.debugP = ledgerClient.prototype.boolion(process.env.LEDGER_CLIENT_DEBUG)
publisherInfo._internal.debugP = ledgerClient.prototype.boolion(process.env.LEDGER_PUBLISHER_DEBUG)
publisherInfo._internal.verboseP = ledgerClient.prototype.boolion(process.env.LEDGER_PUBLISHER_VERBOSE)
}

var enable = (paymentsEnabled) => {
if (paymentsEnabled && !getSetting(settings.PAYMENTS_NOTIFICATION_TRY_PAYMENTS_DISMISSED)) {
appActions.changeSetting(settings.PAYMENTS_NOTIFICATION_TRY_PAYMENTS_DISMISSED, true)
Expand All @@ -721,6 +733,7 @@ var enable = (paymentsEnabled) => {
publisherInfo._internal.enabled = paymentsEnabled
if (synopsis) return updatePublisherInfo()

if (!ledgerPublisher) ledgerPublisher = require('ledger-publisher')
synopsis = new (ledgerPublisher.Synopsis)()
fs.readFile(pathName(synopsisPath), (err, data) => {
var initSynopsis = () => {
Expand Down Expand Up @@ -1176,6 +1189,8 @@ var updateLedgerInfo = () => {

if ((client) && (now > ledgerInfo._internal.geoipExpiry)) {
ledgerInfo._internal.geoipExpiry = now + (5 * msecs.minute)

if (!ledgerGeoIP) ledgerGeoIP = require('ledger-geoip')
return ledgerGeoIP.getGeoIP(client.options, (err, provider, result) => {
if (err) console.log('ledger geoip warning: ' + JSON.stringify(err, null, 2))
if (result) ledgerInfo.countryCode = result
Expand Down Expand Up @@ -1458,6 +1473,7 @@ var getBalance = () => {
balanceTimeoutId = setTimeout(getBalance, 1 * msecs.minute)
if (!ledgerInfo.address) return

if (!ledgerBalance) ledgerBalance = require('ledger-balance')
ledgerBalance.getBalance(ledgerInfo.address, underscore.extend({ balancesP: true }, client.options),
(err, provider, result) => {
var unconfirmed
Expand Down
12 changes: 11 additions & 1 deletion app/renderer/components/urlBarSuggestions.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@ const ImmutableComponent = require('../../../js/components/immutableComponent')
const suggestionTypes = require('../../../js/constants/suggestionTypes')
const cx = require('../../../js/lib/classSet')
const locale = require('../../../js/l10n')
const {isForSecondaryAction} = require('../../../js/lib/eventUtil')

class UrlBarSuggestions extends ImmutableComponent {
constructor () {
super()
this.onSuggestionClicked = this.onSuggestionClicked.bind(this)
}

get activeIndex () {
if (this.props.suggestionList === null) {
return -1
Expand All @@ -23,6 +29,10 @@ class UrlBarSuggestions extends ImmutableComponent {
windowActions.setUrlBarSuggestions(null, null)
}

onSuggestionClicked (e) {
windowActions.activeSuggestionClicked(isForSecondaryAction(e), e.shiftKey)
}

render () {
const suggestions = this.props.suggestionList
const bookmarkSuggestions = suggestions.filter((s) => s.type === suggestionTypes.BOOKMARK)
Expand Down Expand Up @@ -55,7 +65,7 @@ class UrlBarSuggestions extends ImmutableComponent {
const selected = this.activeIndex === currentIndex || (!this.activeIndex && currentIndex === 0 && this.props.hasLocationValueSuffix)
return <li data-index={currentIndex}
onMouseOver={this.onMouseOver.bind(this)}
onClick={suggestion.onClick}
onClick={this.onSuggestionClicked}
key={`${suggestion.location}|${index + i}`}
ref={(node) => { selected && (this.selectedElement = node) }}
className={cx({
Expand Down
2 changes: 1 addition & 1 deletion js/data/searchProviders.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ module.exports = { "providers" :
"shortcut" : ":y"
},
{
"name" : "Youtube",
"name" : "YouTube",
"base" : "https://www.youtube.com",
"image" : "https://www.youtube.com/favicon.ico",
"search" : "https://www.youtube.com/results?search_type=search_videos&search_query={searchTerms}&search_sort=relevance&search_category=0&page=",
Expand Down
11 changes: 11 additions & 0 deletions test/components/urlBarSuggestionsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,17 @@ describe('urlBarSuggestions', function () {
.click(urlBarSuggestions + ' li.suggestionItem[data-index="0"]')
.tabByIndex(1)
.waitForUrl(this.page1Url)
.waitForTabCount(2)
})

it('navigates to non-first suggestion when clicked', function * () {
yield this.app.client
.setInputText(urlInput, 'Page')
.waitForVisible(urlBarSuggestions + ' li.suggestionItem[data-index="1"]')
.click(urlBarSuggestions + ' li.suggestionItem[data-index="1"]')
.tabByIndex(1)
.waitForUrl(this.page2Url)
.waitForTabCount(2)
})

it('navigates to a suggestion with keyboard', function * () {
Expand Down

0 comments on commit 4e72eb0

Please sign in to comment.