diff --git a/app/common/lib/historyUtil.js b/app/common/lib/historyUtil.js index df232cc35e4..108590b073f 100644 --- a/app/common/lib/historyUtil.js +++ b/app/common/lib/historyUtil.js @@ -2,7 +2,26 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ 'use strict' + const Immutable = require('immutable') +const {makeImmutable} = require('../state/immutableUtil') +const siteUtil = require('../../../js/state/siteUtil') +const aboutHistoryMaxEntries = 500 + +module.exports.maxEntries = aboutHistoryMaxEntries + +const sortTimeDescending = (left, right) => { + if (left.get('lastAccessedTime') < right.get('lastAccessedTime')) return 1 + if (left.get('lastAccessedTime') > right.get('lastAccessedTime')) return -1 + return 0 +} + +module.exports.getHistory = (sites) => { + sites = makeImmutable(sites) || new Immutable.List() + return sites.filter((site) => siteUtil.isHistoryEntry(site)) + .sort(sortTimeDescending) + .slice(0, aboutHistoryMaxEntries) +} const getDayString = (entry, locale) => { const lastAccessedTime = entry.get('lastAccessedTime') @@ -42,15 +61,11 @@ module.exports.groupEntriesByDay = (history, locale) => { * Format is expected to be array containing one array per day. */ module.exports.totalEntries = (entriesByDay) => { + entriesByDay = makeImmutable(entriesByDay) || new Immutable.List() + let result = new Immutable.List() entriesByDay.forEach((entry) => { result = result.push(entry.get('entries')) }) return result } - -module.exports.sortTimeDescending = (left, right) => { - if (left.get('lastAccessedTime') < right.get('lastAccessedTime')) return 1 - if (left.get('lastAccessedTime') > right.get('lastAccessedTime')) return -1 - return 0 -} diff --git a/app/common/state/aboutHistoryState.js b/app/common/state/aboutHistoryState.js new file mode 100644 index 00000000000..6f9048993e6 --- /dev/null +++ b/app/common/state/aboutHistoryState.js @@ -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/. */ + +const {makeImmutable} = require('./immutableUtil') +const historyUtil = require('../lib/historyUtil') + +const aboutHistoryState = { + getHistory: (state) => { + state = makeImmutable(state) + return state.getIn(['about', 'history']) + }, + setHistory: (state) => { + state = makeImmutable(state) + state = state.setIn(['about', 'history', 'entries'], + historyUtil.getHistory(state.get('sites'))) + return state.setIn(['about', 'history', 'updatedStamp'], new Date().getTime()) + } +} + +module.exports = aboutHistoryState diff --git a/app/renderer/components/urlBarIcon.js b/app/renderer/components/urlBarIcon.js index 693f5a8ed26..e8871434cf9 100644 --- a/app/renderer/components/urlBarIcon.js +++ b/app/renderer/components/urlBarIcon.js @@ -47,10 +47,15 @@ class UrlBarIcon extends ImmutableComponent { const defaultToSearch = (!this.isSecure && !this.isInsecure && !showSearch) && !this.props.titleMode && - this.props.loading === false + this.props.loading === false && + !this.isAboutPage return showSearch || defaultToSearch } + get isAboutPage () { + return isSourceAboutUrl(this.props.location) && + this.props.location !== 'about:newtab' + } get iconClasses () { if (this.props.activateSearchEngine) { return cx({urlbarIcon: true}) @@ -62,7 +67,8 @@ class UrlBarIcon extends ImmutableComponent { // NOTE: EV style not approved yet; see discussion at https://github.com/brave/browser-laptop/issues/791 'fa-lock': this.isSecure, 'fa-exclamation-triangle': this.isInsecure, - 'fa-search': this.isSearch + 'fa-search': this.isSearch, + 'fa-list': this.isAboutPage }) } get iconStyles () { diff --git a/app/sessionStore.js b/app/sessionStore.js index fa086127e2b..46c4915439b 100644 --- a/app/sessionStore.js +++ b/app/sessionStore.js @@ -327,7 +327,10 @@ module.exports.cleanAppData = (data, isShutdown) => { }) } - delete data.versionInformation + if (data.about) { + delete data.about.brave + delete data.about.history + } } /** @@ -435,18 +438,21 @@ module.exports.loadAppState = () => { // version information (shown on about:brave) const os = require('os') const versionInformation = [ - {name: 'brave', version: app.getVersion()}, - {name: 'muon', version: process.versions['atom-shell']}, + {name: 'Brave', version: app.getVersion()}, + {name: 'Muon', version: process.versions['atom-shell']}, {name: 'libchromiumcontent', version: process.versions['chrome']}, {name: 'V8', version: process.versions.v8}, {name: 'Node.js', version: process.versions.node}, - {name: 'channel', version: Channel.channel()}, + {name: 'Update Channel', version: Channel.channel()}, {name: 'os.platform', version: os.platform()}, {name: 'os.release', version: os.release()}, {name: 'os.arch', version: os.arch()} // TODO(bsclifton): read the latest commit hash from a file, etc. ] - data.versionInformation = versionInformation + data.about = data.about || {} + data.about.brave = { + versionInformation: versionInformation + } } catch (e) { // TODO: Session state is corrupted, maybe we should backup this // corrupted value for people to report into support. diff --git a/docs/appActions.md b/docs/appActions.md index a067405cfb7..b76ea3b97ff 100644 --- a/docs/appActions.md +++ b/docs/appActions.md @@ -494,6 +494,12 @@ Dispatch a message to indicate default browser check is complete +### populateHistory() + +Notify the AppStore to provide default history values. + + + * * * diff --git a/docs/state.md b/docs/state.md index 12edcc84af0..ebca6386415 100644 --- a/docs/state.md +++ b/docs/state.md @@ -220,6 +220,15 @@ AppStore } }, about: { + brave: { + versionInformation: [{ + name: string, + version: string + }] // used on about:brave. not persisted (removed on save) + }, + history: { + entries: [object] // used on about:history. not persisted (removed on save) + }, newtab: { gridLayoutSize: string, // 'small', 'medium', 'large' sites: [string], // List of sites to be used on gridLayout diff --git a/js/about/history.js b/js/about/history.js index b54894c0b2d..d6af81d9586 100644 --- a/js/about/history.js +++ b/js/about/history.js @@ -13,7 +13,6 @@ const aboutActions = require('./aboutActions') const getSetting = require('../settings').getSetting const SortableTable = require('../components/sortableTable') const Button = require('../components/button') -const siteUtil = require('../state/siteUtil') const {makeImmutable} = require('../../app/common/state/immutableUtil') const historyUtil = require('../../app/common/lib/historyUtil') @@ -56,13 +55,6 @@ class HistoryTimeCell extends ImmutableComponent { } class HistoryDay extends ImmutableComponent { - constructor () { - super() - this.clearSelection = this.clearSelection.bind(this) - } - clearSelection () { - this.refs.historyTable.clearSelection() - } navigate (entry) { entry = makeImmutable(entry) aboutActions.newFrame({ @@ -74,7 +66,6 @@ class HistoryDay extends ImmutableComponent { return