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

Commit

Permalink
Initial work done for #2106
Browse files Browse the repository at this point in the history
- Add settings for new tab behaviour, handle this behaviour when you click the new tab button
- Scaffolding for deafult search engine appearing as new tab
- Grab proper search engine information on new tab
- New tab can load default search engine
- Add functionality for new tab options
- Abstraction of handling new tab settings
- Hopefully final abstraction to complete new tab functionality
  • Loading branch information
Scott King authored and bsclifton committed Nov 1, 2016
1 parent c4b6a14 commit 908a373
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions js/components/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ class Main extends ImmutableComponent {
}
}
let openInForeground = getSetting(settings.SWITCH_TO_NEW_TABS) === true || options.openInForeground
// let defaultUrl = newFrameUrl()
const frameOpts = {
location: url || config.defaultUrl,
isPrivate: !!options.isPrivate,
Expand Down
30 changes: 30 additions & 0 deletions js/lib/appUrlUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ const Immutable = require('immutable')
const path = require('path')
const UrlUtil = require('./urlutil')
const config = require('../constants/config')
const getSetting = require('../settings').getSetting
const settings = require('../constants/settings')
const searchProviders = require('../data/searchProviders').providers

module.exports.fileUrl = (str) => {
var pathName = path.resolve(str).replace(/\\/g, '/')
Expand Down Expand Up @@ -148,3 +151,30 @@ function getHash (input) {
}

module.exports.navigatableTypes = ['http:', 'https:', 'about:', 'chrome:', 'chrome-extension:', 'file:', 'view-source:', 'ftp:']

/**
* Grabs the url of the new tab
*/
// module.exports.newFrameUrl = function () {
// let newTabMode = getSetting(settings.NEWTAB_MODE)
// let defaultUrl
// switch (newTabMode) {
// case 'newTabPage':
// defaultUrl = 'about:newtab'
// break
// case 'homePage':
// defaultUrl = getSetting(settings.HOMEPAGE)
// break
// case 'defaultSearchEngine':
// let defaultSearchEngine = getSetting(settings.DEFAULT_SEARCH_ENGINE)
// let defaultSearchEngineSettings = searchProviders.filter(engine => {
// return engine.name === defaultSearchEngine
// })
// defaultUrl = defaultSearchEngineSettings[0].base
// break
// default:
// defaultUrl = ''
// break
// }
// return defaultUrl
// }
3 changes: 3 additions & 0 deletions js/stores/windowStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const currentWindow = require('../../app/renderer/currentWindow')
const {tabFromFrame} = require('../state/frameStateUtil')
const {l10nErrorText} = require('../../app/common/lib/httpUtil')
const {aboutUrls, getSourceAboutUrl, isIntermediateAboutPage, navigatableTypes} = require('../lib/appUrlUtil')
const searchProviders = require('../data/searchProviders').providers
const Serializer = require('../dispatcher/serializer')

let windowState = Immutable.fromJS({
Expand Down Expand Up @@ -173,6 +174,8 @@ const newFrame = (frameOpts, openInForeground, insertionIndex, nextKey) => {
if (openInForeground === undefined) {
openInForeground = true
}

// let defaultUrl = newFrameUrl()
frameOpts.location = frameOpts.location || config.defaultUrl
if (frameOpts.location && UrlUtil.isURL(frameOpts.location)) {
frameOpts.location = UrlUtil.getUrlFromInput(frameOpts.location)
Expand Down

0 comments on commit 908a373

Please sign in to comment.