Skip to content

Commit

Permalink
Merge pull request #654 from brave/qwant
Browse files Browse the repository at this point in the history
add qwant support
  • Loading branch information
petemill committed Oct 17, 2018
1 parent 5b72784 commit 42dc457
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion components/brave_new_tab_ui/components/privateTab/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { Page, PageWrapper } from 'brave-ui/features/newTab'

// Components group
import PrivateTab from './privateTab'
import QwantTab from './qwantTab'
import QwantTorTab from './qwantTorTab'
import TorTab from './torTab'

interface Props {
Expand All @@ -18,12 +20,30 @@ interface Props {
}

export default class NewPrivateTab extends React.PureComponent<Props, {}> {
get isQwant () {
// This is not technically accurately describing whether
// the browser has been automatically set to a Qwant region.
// Temporarily we are detecting language here, but we should
// use the same setting logic as used during first-run.
// https://github.com/brave/brave-browser/issues/1632
return navigator.language &&
navigator.language.startsWith('de') ||
navigator.language.startsWith('fr')
}

get currentWindow () {
const { isTor, useAlternativePrivateSearchEngine, onChangePrivateSearchEngine } = this.props
if (isTor) {
if (this.isQwant) {
return <QwantTorTab />
}
return <TorTab />
}

if (this.isQwant) {
return <QwantTab />
}

return (
<PrivateTab
useAlternativePrivateSearchEngine={useAlternativePrivateSearchEngine}
Expand All @@ -35,7 +55,7 @@ export default class NewPrivateTab extends React.PureComponent<Props, {}> {
render () {
const { isTor } = this.props
return (
<Page isPrivate={!isTor}>
<Page isPrivate={!isTor && !this.isQwant}>
<PageWrapper>
{this.currentWindow}
</PageWrapper>
Expand Down

0 comments on commit 42dc457

Please sign in to comment.