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

Commit

Permalink
Implement DDG changes for #14459
Browse files Browse the repository at this point in the history
Test Plan: Check that the DDG switch in regular private tabs doesn't
affect tor tabs and that the DDG switch in about:preferences for Tor
tabs doesn't affect regular private tabs. Also check that DDG is default
on for tor tabs.
  • Loading branch information
diracdeltas committed Jun 22, 2018
1 parent edffc8f commit c0e0e16
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 11 deletions.
2 changes: 2 additions & 0 deletions app/extensions/brave/locales/en-US/newtab.properties
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ privateTabText1=Whether or not you use Tor, private tabs are not logged in page
privateTabTitle=This is a Private Tab
privateTabTorTitle=Make private tabs much more private with
privateTabTorText1=Tor hides your IP address from the sites you visit, and hides the sites you visit from your ISP or your employer. Tor can slow down browsing. Some sites treat anonymous users differently, or might not work at all. Some sites might even ask you to prove you’re human.
privateTabTorText2=By default, DuckDuckGo is the search engine for Private Tabs with Tor.
searchPreferences=Search Preferences...
privateTabSearchSectionTitle=Private search with
privateTabSearchText1=With private search, Brave will use DuckDuckGo to answer your searches while you are in this private tab. DuckDuckGo is a search engine that does not track your search history, enabling you to search privately.
removeBookmarkButton.title=Remove bookmark
Expand Down
1 change: 1 addition & 0 deletions app/extensions/brave/locales/en-US/preferences.properties
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ showHomeButton=Show home button on URL bar
showLess=Show Less
privateTabsSearchSettingsTitle=Private Tabs
useDuckDuckGoForPrivateSearch=Use DuckDuckGo by default for search in Private Tabs
useDuckDuckGoForPrivateSearchTor=Use DuckDuckGo by default for search in Private Tabs with Tor
showOpenedTabMatches=Show tab matches
showTabPreviews=Show tab previews on hover
showTopsiteSuggestions=Show top site suggestions
Expand Down
5 changes: 3 additions & 2 deletions app/renderer/reducers/urlBarReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
const windowConstants = require('../../../js/constants/windowConstants')
const appConstants = require('../../../js/constants/appConstants')
const {isURL} = require('../../../js/lib/urlutil')
const {activeFrameStatePath, frameStatePath, getFrameByTabId} = require('../../../js/state/frameStateUtil')
const {activeFrameStatePath, frameStatePath, getFrameByTabId, isTor} = require('../../../js/state/frameStateUtil')
const searchProviders = require('../../../js/data/searchProviders')
const Immutable = require('immutable')
const {navigateSiteClickHandler} = require('../suggestionClickHandlers')
Expand Down Expand Up @@ -42,7 +42,8 @@ const updateSearchEngineInfoFromInput = (state, frameProps) => {
}
if (frameProps.get('isPrivate')) {
// handle private tab search with default search provider
const useAlternateDefaultPrivateSearchProvider = getSetting(settings.USE_ALTERNATIVE_PRIVATE_SEARCH_ENGINE)
const useAlternateDefaultPrivateSearchProvider =
getSetting(isTor(frameProps) ? settings.USE_ALTERNATIVE_PRIVATE_SEARCH_ENGINE_TOR : settings.USE_ALTERNATIVE_PRIVATE_SEARCH_ENGINE)
if (useAlternateDefaultPrivateSearchProvider === true) {
// DuckDuckGo hard-coded as Private Tab default provider
// if asked to use a privacy-centric 'alternative'
Expand Down
22 changes: 19 additions & 3 deletions js/about/newprivatetab.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class NewPrivateTab extends React.Component {
<div className={css(styles.textWrapper)}>
<h1 className={css(styles.title)} data-l10n-id='privateTabTitle' />
{
!isTor &&
this.props.newTabData.hasIn(useAlternativePrivateSearchEngineDataKeys) &&
<div className={css(styles.privateSearch)}>
<div className={css(styles.privateSearch__setting)}>
Expand All @@ -67,7 +68,7 @@ class NewPrivateTab extends React.Component {
<span className={css(styles.text_sectionTitle)} data-l10n-id='privateTabSearchSectionTitle' />
<strong className={css(styles.text_sectionTitle, styles.text_sectionTitleHighlight)}>&nbsp;DuckDuckGo</strong>
</h2>
<p className={css(styles.text, styles.text_privateSearch)} data-l10n-id='privateTabSearchText1' />
<p className={css(styles.text)} data-l10n-id='privateTabSearchText1' />
</span>
<SettingCheckbox
large
Expand All @@ -88,8 +89,8 @@ class NewPrivateTab extends React.Component {
<span className={css(styles.text_sectionTitle)} data-l10n-id='privateTabTorTitle' />
<strong className={css(styles.text_sectionTitle, styles.text_sectionTitleHighlight)}>&nbsp;Tor</strong>
</h2>
<p className={css(styles.text, styles.text_privateSearch)} data-l10n-id='privateTabTorText1' />
<p className={css(styles.text, styles.text_privateSearch, styles.text_clickable)} onClick={aboutActions.createTabRequested.bind(null, {url: torFAQ, isPrivate: true, isTor})} data-l10n-id='learnMore' />
<p className={css(styles.text)} data-l10n-id='privateTabTorText1' />
<p className={css(styles.text, styles.text_clickable)} onClick={aboutActions.createTabRequested.bind(null, {url: torFAQ, isPrivate: true, isTor})} data-l10n-id='learnMore' />
</span>
<SettingCheckbox
large
Expand All @@ -101,6 +102,17 @@ class NewPrivateTab extends React.Component {
</div>
</div>
}
{
isTor &&
<div className={css(styles.privateSearch)}>
<div className={css(styles.privateSearch__setting)}>
<p>
<span className={css(styles.text, styles.text_DDG)} data-l10n-id='privateTabTorText2' />
<span className={css(styles.text, styles.text_clickable)} data-l10n-id='searchPreferences' onClick={aboutActions.createTabRequested.bind(null, {url: 'about:preferences#search'})} />
</p>
</div>
</div>
}
</div>
</div>
<div className={css(styles.section_privateTab)}>
Expand Down Expand Up @@ -216,6 +228,10 @@ const styles = StyleSheet.create({
paddingRight: '40px'
},

text_DDG: {
paddingRight: '10px'
},

text_footer: {
lineHeight: '1.5',
fontSize: '13px',
Expand Down
1 change: 1 addition & 0 deletions js/about/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ class SearchTab extends ImmutableComponent {
<SettingsList>
<DefaultSectionTitle data-l10n-id='privateTabsSearchSettingsTitle' />
<SettingCheckbox dataL10nId='useDuckDuckGoForPrivateSearch' prefKey={settings.USE_ALTERNATIVE_PRIVATE_SEARCH_ENGINE} settings={this.props.settings} onChangeSetting={this.props.onChangeSetting} />
<SettingCheckbox dataL10nId='useDuckDuckGoForPrivateSearchTor' prefKey={settings.USE_ALTERNATIVE_PRIVATE_SEARCH_ENGINE_TOR} settings={this.props.settings} onChangeSetting={this.props.onChangeSetting} />
</SettingsList>
<DefaultSectionTitle data-l10n-id='locationBarSettings' />
<SettingsList>
Expand Down
3 changes: 2 additions & 1 deletion js/constants/appConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ module.exports = {
'general.spellcheck-languages': Immutable.fromJS(['en-US']),
'search.default-search-engine': 'Google',
'search.offer-search-suggestions': false, // false by default for privacy reasons
'search.use-alternate-private-search-engine': true,
'search.use-alternate-private-search-engine': false,
'search.use-alternate-private-search-engine-tor': true,
'tabs.switch-to-new-tabs': false,
'tabs.paint-tabs': true,
'tabs.tabs-per-page': 20,
Expand Down
1 change: 1 addition & 0 deletions js/constants/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const settings = {
// Search tab
DEFAULT_SEARCH_ENGINE: 'search.default-search-engine',
USE_ALTERNATIVE_PRIVATE_SEARCH_ENGINE: 'search.use-alternate-private-search-engine',
USE_ALTERNATIVE_PRIVATE_SEARCH_ENGINE_TOR: 'search.use-alternate-private-search-engine-tor',
OFFER_SEARCH_SUGGESTIONS: 'search.offer-search-suggestions',
// Tabs tab
SWITCH_TO_NEW_TABS: 'tabs.switch-to-new-tabs',
Expand Down
10 changes: 5 additions & 5 deletions test/tab-components/torTabTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@ describe('tor tab tests', function () {
})

it('uses ddg if setting is on', function * () {
yield this.app.client.changeSetting(settings.USE_ALTERNATIVE_PRIVATE_SEARCH_ENGINE, true)
yield this.app.client.changeSetting(settings.USE_ALTERNATIVE_PRIVATE_SEARCH_ENGINE_TOR, true)
yield this.app.client
.newTab({ isPrivate: true })
.pause(1000)
.newTab({ isPrivate: true, isTor: true })
.pause(10000) // wait for tor init
.setValue(urlInput, 'zzz')
.keys(Brave.keys.ENTER)
.windowByUrl(Brave.browserWindowUrl)
.waitForInputText(urlInput, /duckduckgo/)
})
it('does not use ddg if setting is off', function * () {
yield this.app.client.changeSetting(settings.USE_ALTERNATIVE_PRIVATE_SEARCH_ENGINE, false)
yield this.app.client.changeSetting(settings.USE_ALTERNATIVE_PRIVATE_SEARCH_ENGINE_TOR, false)
yield this.app.client
.newTab({ isPrivate: true })
.newTab({ isPrivate: true, isTor: true })
.setValue(urlInput, 'test')
.keys(Brave.keys.ENTER)
.windowByUrl(Brave.browserWindowUrl)
Expand Down

0 comments on commit c0e0e16

Please sign in to comment.