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

Add new "empty new tab" option in preferences (for what new tab does) #5690

Merged
merged 3 commits into from
Nov 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/common/constants/settingsEnums.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ const startsWithOption = {
const newTabMode = {
NEW_TAB_PAGE: 'newTabPage',
HOMEPAGE: 'homePage',
DEFAULT_SEARCH_ENGINE: 'defaultSearchEngine'
DEFAULT_SEARCH_ENGINE: 'defaultSearchEngine',
EMPTY_NEW_TAB: 'emptyNewTab'
}

const bookmarksToolbarMode = {
Expand Down
17 changes: 9 additions & 8 deletions app/extensions/brave/locales/en-US/preferences.properties
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,17 @@ hint2=The File menu allows you to create a New Session Tab. Session tabs are lik
sendUsFeedback=Send us feedback…
loveToHear=We'd love to hear from you.
startsWith=Brave starts with
startsWithOptionLastTime=my windows / tabs from last time
startsWithOptionHomePage=my home page
startsWithOptionNewTabPage=the new tab page
startsWithOptionLastTime=My windows / tabs from last time
startsWithOptionHomePage=Home page
startsWithOptionNewTabPage=Dashboard
newTabMode=A new tab shows
newTabBlank=blank
newTabNewTabPage=Dashboard
newTabHomePage=Home page
newTabDefaultSearchEngine=Default search engine
newTabEmpty=Blank page
myHomepage=My home page is
aboutBlank=about:blank
newTabNewTabPage=the new tab page
newTabHomePage=my home page
newTabDefaultSearchEngine=default search engine
myHomepage=My homepage is
default=Default
searchEngine=Search Engine
engineGoKey=Engine Go Key (Type First)
Expand Down Expand Up @@ -217,7 +218,7 @@ downloadsLabel=Save my downloads here:
downloadsInput=~/downloads/
downloadsAskAlwaysSwitch=Always ask me where to save files
notifyOnUpdate=Notify me when an update is available
showHomeButton=Show Home button on URL bar
showHomeButton=Show home button on URL bar
mediaPermission=Camera and microphone access
geolocationPermission=Location access
notificationsPermission=Show notifications
Expand Down
12 changes: 9 additions & 3 deletions js/about/newtab.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const React = require('react')
const Immutable = require('immutable')
const messages = require('../constants/messages')
const HTML5Backend = require('react-dnd-html5-backend')
const { DragDropContext } = require('react-dnd')
const {DragDropContext} = require('react-dnd')
const Stats = require('./newTabComponents/stats')
const Clock = require('./newTabComponents/clock')
const Block = require('./newTabComponents/block')
Expand All @@ -32,7 +32,8 @@ class NewTabPage extends React.Component {
showSiteRemovalNotification: false,
backgroundImage: this.randomBackgroundImage,
imageLoadFailed: false,
updatedStamp: undefined
updatedStamp: undefined,
showEmptyPage: true
}
ipc.on(messages.NEWTAB_DATA_UPDATED, (e, newTabData) => {
const data = Immutable.fromJS(newTabData || {})
Expand All @@ -47,7 +48,8 @@ class NewTabPage extends React.Component {

this.setState({
newTabData: data,
updatedStamp: updatedStamp
updatedStamp: updatedStamp,
showEmptyPage: !!data.get('showEmptyPage')
})
})
}
Expand Down Expand Up @@ -216,6 +218,10 @@ class NewTabPage extends React.Component {
}

render () {
// don't render if user prefers an empty page
if (this.state.showEmptyPage) {
return <div className='empty' />
}
// don't render until object is found
if (!this.state.newTabData) {
return null
Expand Down
1 change: 1 addition & 0 deletions js/about/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,7 @@ class GeneralTab extends ImmutableComponent {
<option data-l10n-id='newTabNewTabPage' value={newTabMode.NEW_TAB_PAGE} />
<option data-l10n-id='newTabHomePage' value={newTabMode.HOMEPAGE} />
<option data-l10n-id='newTabDefaultSearchEngine' value={newTabMode.DEFAULT_SEARCH_ENGINE} />
<option data-l10n-id='newTabEmpty' value={newTabMode.EMPTY_NEW_TAB} />
</select>
</SettingItem>
<SettingItem dataL10nId='myHomepage'>
Expand Down
2 changes: 2 additions & 0 deletions js/components/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const currentWindow = require('../../app/renderer/currentWindow')
const windowStore = require('../stores/windowStore')
const appStoreRenderer = require('../stores/appStoreRenderer')
const siteSettings = require('../state/siteSettings')
const {newTabMode} = require('../../app/common/constants/settingsEnums')

const WEBRTC_DEFAULT = 'default'
const WEBRTC_DISABLE_NON_PROXY = 'disable_non_proxied_udp'
Expand Down Expand Up @@ -127,6 +128,7 @@ class Frame extends ImmutableComponent {
this.webview.send(messages.BRAVERY_DEFAULTS_UPDATED, this.braveryDefaults)
} else if (location === 'about:newtab') {
this.webview.send(messages.NEWTAB_DATA_UPDATED, {
showEmptyPage: getSetting(settings.NEWTAB_MODE) === newTabMode.EMPTY_NEW_TAB,
trackedBlockersCount: this.props.trackedBlockersCount,
adblockCount: this.props.adblockCount,
httpsUpgradedCount: this.props.httpsUpgradedCount,
Expand Down
1 change: 1 addition & 0 deletions js/lib/appUrlUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ module.exports.newFrameUrl = function () {
})
return defaultSearchEngineSettings[0].base

case newTabMode.EMPTY_NEW_TAB:
case newTabMode.NEW_TAB_PAGE:
default:
return 'about:newtab'
Expand Down
Loading