Skip to content

Remove DDG search toggle from private tabs #10413

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 8, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "brave/browser/search_engines/private_window_search_engine_provider_service.h"

#include "brave/browser/search_engines/search_engine_provider_util.h"
#include "chrome/browser/profiles/profile.h"
#include "components/prefs/pref_service.h"
#include "components/search_engines/default_search_manager.h"
Expand All @@ -16,6 +17,10 @@ PrivateWindowSearchEngineProviderService(Profile* otr_profile)
: SearchEngineProviderService(otr_profile) {
DCHECK(otr_profile->IsIncognitoProfile());

if (brave::UseAlternativeSearchEngineProviderEnabled(otr_profile)) {
brave::SetShowAlternativeSearchEngineProviderToggle(otr_profile);
}

const bool use_extension_provider = ShouldUseExtensionSearchProvider();
otr_profile->GetPrefs()->SetBoolean(prefs::kDefaultSearchProviderByExtension,
use_extension_provider);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ SearchEngineProviderServiceFactory::ServiceIsCreatedWithBrowserContext() const {
void SearchEngineProviderServiceFactory::RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* registry) {
registry->RegisterBooleanPref(kUseAlternativeSearchEngineProvider, false);
registry->RegisterBooleanPref(kShowAlternativeSearchEngineProviderToggle,
false);
registry->RegisterBooleanPref(prefs::kDefaultSearchProviderByExtension,
false);
registry->RegisterBooleanPref(prefs::kAddOpenSearchEngines, false);
Expand Down
13 changes: 13 additions & 0 deletions browser/search_engines/search_engine_provider_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ bool UseAlternativeSearchEngineProviderEnabled(Profile* profile) {
kUseAlternativeSearchEngineProvider);
}

bool ShowAlternativeSearchEngineProviderToggleEnabled(Profile* profile) {
return profile->GetOriginalProfile()->GetPrefs()->GetBoolean(
kShowAlternativeSearchEngineProviderToggle);
}

void ToggleUseAlternativeSearchEngineProvider(Profile* profile) {
if (brave::IsRegionForQwant(profile))
return;
Expand All @@ -29,6 +34,14 @@ void ToggleUseAlternativeSearchEngineProvider(Profile* profile) {
!UseAlternativeSearchEngineProviderEnabled(profile));
}

void SetShowAlternativeSearchEngineProviderToggle(Profile* profile) {
if (brave::IsRegionForQwant(profile))
return;

profile->GetOriginalProfile()->GetPrefs()->SetBoolean(
kShowAlternativeSearchEngineProviderToggle, true);
}

bool IsRegionForQwant(Profile* profile) {
return TemplateURLPrepopulateData::GetPrepopulatedDefaultSearch(
profile->GetPrefs())->prepopulate_id ==
Expand Down
4 changes: 4 additions & 0 deletions browser/search_engines/search_engine_provider_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ namespace brave {

bool UseAlternativeSearchEngineProviderEnabled(Profile* profile);

bool ShowAlternativeSearchEngineProviderToggleEnabled(Profile* profile);

void ToggleUseAlternativeSearchEngineProvider(Profile* profile);

void SetShowAlternativeSearchEngineProviderToggle(Profile* profile);

bool IsRegionForQwant(Profile* profile);

} // namespace brave
Expand Down
2 changes: 2 additions & 0 deletions browser/ui/webui/brave_webui_source.cc
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ void CustomizeWebUIHTMLSource(const std::string &name,
// Private Tab - Header Private Window
{ "headerTitle", IDS_BRAVE_PRIVATE_NEW_TAB_PRIVATE_WINDOW },
{ "headerText", IDS_BRAVE_PRIVATE_NEW_TAB_PRIVATE_WINDOW_DESC },
{ "headerText1", IDS_BRAVE_PRIVATE_NEW_TAB_PRIVATE_WINDOW_DESC1 },
{ "headerText2", IDS_BRAVE_PRIVATE_NEW_TAB_PRIVATE_WINDOW_DESC2 },
{ "headerButton", IDS_BRAVE_PRIVATE_NEW_TAB_PRIVATE_WINDOW_BUTTON },

// Private Tab - Header Private Window with Tor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ base::DictionaryValue GetPrivatePropertiesDictionary(PrefService* prefs) {
private_data.SetBoolean(
"useAlternativePrivateSearchEngine",
prefs->GetBoolean(kUseAlternativeSearchEngineProvider));
private_data.SetBoolean(
"showAlternativePrivateSearchEngineToggle",
prefs->GetBoolean(kShowAlternativeSearchEngineProviderToggle));
return private_data;
}

Expand Down
2 changes: 2 additions & 0 deletions common/pref_names.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ const char kWidevineOptedIn[] = "brave.widevine_opted_in";
const char kAskWidevineInstall[] = "brave.ask_widevine_install";
const char kUseAlternativeSearchEngineProvider[] =
"brave.use_alternate_private_search_engine";
const char kShowAlternativeSearchEngineProviderToggle[] =
"brave.show_alternate_private_search_engine_toggle";
const char kAlternativeSearchEngineProviderInTor[] =
"brave.alternate_private_search_engine_in_tor";
const char kLocationBarIsWide[] = "brave.location_bar_is_wide";
Expand Down
1 change: 1 addition & 0 deletions common/pref_names.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ extern const char kStatsReportingEnabled[];
extern const char kWidevineOptedIn[];
extern const char kAskWidevineInstall[];
extern const char kUseAlternativeSearchEngineProvider[];
extern const char kShowAlternativeSearchEngineProviderToggle[];
extern const char kAlternativeSearchEngineProviderInTor[];
extern const char kBraveThemeType[];
extern const char kUseOverriddenBraveThemeType[];
Expand Down
1 change: 1 addition & 0 deletions components/brave_new_tab_ui/api/privateTabData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import * as Cr from 'chrome://resources/js/cr.m'

export type PrivateTabData = {
useAlternativePrivateSearchEngine: boolean
showAlternativePrivateSearchEngineToggle: boolean
}

type PrivateTabDataUpdatedHandler = (data: PrivateTabData) => void
Expand Down
33 changes: 25 additions & 8 deletions components/brave_new_tab_ui/components/private/box/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ export const Box = styled('section')<{}>`
border: 1px solid rgba(255,255,255,0.25);
`

export const ControlBox = styled('section')<{}>`
box-sizing: border-box;
-webkit-font-smoothing: antialiased;
padding: 10px 20px 10px;
border-radius: 12px;
border: 1px solid rgba(255,255,255,0.25);
display: flex;
justify-content: center;
width: 60%;
margin: 10px auto;
`

export const HeaderBox = styled('section')<{}>`
box-sizing: border-box;
-webkit-font-smoothing: antialiased;
Expand All @@ -31,7 +43,7 @@ export const DuckDuckGoImage = styled(DuckDuckGoIcon)`
box-sizing: border-box;
display: block;
width: 40px;
margin-bottom: 20px;
margin-right: 10px;
`

export const TorLockImage = styled(TorLockIcon)`
Expand All @@ -45,10 +57,14 @@ export const PrivateImage = styled('img')<{}>`
box-sizing: border-box;
display: block;
width: 293px;
margin: auto;
`

@media screen and (max-width: 1170px) {
margin: auto;
}
export const PrivacyEyeImage = styled('img')<{}>`
box-sizing: border-box;
display: block;
width: 73px;
margin: auto;
`

export const TorImage = styled('img')<{}>`
Expand Down Expand Up @@ -78,8 +94,9 @@ export const Title = styled(Heading)`
letter-spacing: 0.02px;
font-weight: 500;
color: #fff;
margin: 0 0 0px;
margin: auto;
`

export const Text = styled('p')<{}>`
font-family: ${p => p.theme.fontFamily.body};
letter-spacing: 0.19px;
Expand All @@ -105,14 +122,14 @@ export const PurpleButton = styled(Button as ComponentType<ButtonProps>)`
`
export const Link = styled('a')<{}>`
font-family: ${p => p.theme.fontFamily.heading};
font-size: 14px;
color: #814EFF;
font-size: 15px;
color: #fff;
font-style: normal;
line-height: 1;
align-self: center;
margin: 25px 20px 0 0;
cursor: pointer;
text-decoration: none;
text-decoration: underline;
`

interface FakeButtonProps {
Expand Down
68 changes: 66 additions & 2 deletions components/brave_new_tab_ui/components/private/grid/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,63 @@ export const Grid2Columns = styled('section')<{}>`
}
`

export const Grid3Columns = styled('section')<{}>`
box-sizing: border-box;
display: grid;
height: 100%;
grid-template-columns: 10% 45% 45%;
grid-template-areas:
"header header header"
"image content1 content2";

grid-auto-rows: auto;
grid-gap: 20px 20px;
padding: 0;
justify-items: center;

> *:first-child {
grid-area: header;
}

> *:nth-child(2) {
grid-area: image;
}

> *:nth-child(3) {
grid-area: content1;
}

> *:nth-child(4) {
grid-area: content2;
}

@media screen and (max-width: 1170px) {
grid-template-columns: 460px;
justify-content: center;
grid-template-areas:
"header"
"content1"
"content2";

> *:nth-child(2) {
display: none;
}
}

@media screen and (max-width: 490px) {
/* TODO: @cezaraugusto this needs more love */
zoom: 0.8;
}
`

export const HeaderGrid = styled('section')<{}>`
box-sizing: border-box;
display: grid;
height: 100%;
grid-template-columns: auto 1fr;
grid-template-areas: "image content";
grid-template-columns: 1fr;
grid-template-areas:
"image"
"content";

grid-auto-rows: auto;
grid-gap: 50px;
Expand Down Expand Up @@ -115,3 +166,16 @@ export const ButtonGroup = styled('footer')<{}>`
flex: 1;
justify-content: flex-start;
`

export const ToggleGroup = styled('footer')<{}>`
display: flex;
flex: 1;
justify-content: space-between;
align-items: center;
`

export const IconText = styled('div')<{}>`
display: flex;
justify: space-between;
align-items: center;
`
17 changes: 16 additions & 1 deletion components/brave_new_tab_ui/components/private/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,23 @@ import {
Footer
} from './modal'
import { Page, PageWrapper } from './page'
import { Grid, Grid2Columns, HeaderGrid, ButtonGroup } from './grid'
import {
Grid,
Grid2Columns,
Grid3Columns,
HeaderGrid,
ButtonGroup,
ToggleGroup,
IconText
} from './grid'
import {
Box,
Content,
ControlBox,
HeaderBox,
DuckDuckGoImage,
TorLockImage,
PrivacyEyeImage,
PrivateImage,
TorImage,
SubTitle,
Expand All @@ -39,13 +49,18 @@ export {
PageWrapper,
Grid,
Grid2Columns,
Grid3Columns,
HeaderGrid,
ButtonGroup,
ToggleGroup,
IconText,
Box,
Content,
ControlBox,
HeaderBox,
DuckDuckGoImage,
TorLockImage,
PrivacyEyeImage,
PrivateImage,
TorImage,
SubTitle,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface PageProps {
export const Page = styled('div')<PageProps>`
box-sizing: border-box;
-webkit-font-smoothing: antialiased;
background: linear-gradient(${p => p.isPrivate ? '#381980' : '#5F0C8A'}, #0C041E);
background: linear-gradient(${p => p.isPrivate ? '180deg, #0C041E -8.41%, #4E21B7 98.85%' : '#5F0C8A, #0C041E'});
min-height: 100vh;
height: initial;
`
Expand Down
Loading