Skip to content

Commit

Permalink
Add Ecosia as a default search alternative
Browse files Browse the repository at this point in the history
Shown in the following markets:
USA (US), UK (GB), France (FR), Germany (DE), Netherlands (NL), Belgium (BE), Switzerland (CH), Sweden (SE)

Fixes brave/brave-browser#13283
  • Loading branch information
bsclifton committed Dec 28, 2020
1 parent 0fbac64 commit 61030fa
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ const std::vector<BravePrepopulatedEngineID> brave_engines_default = {
};

// Variations of the order / default options by country.
const std::vector<BravePrepopulatedEngineID> brave_engines_with_ecosia = {
PREPOPULATED_ENGINE_ID_GOOGLE,
PREPOPULATED_ENGINE_ID_DUCKDUCKGO,
PREPOPULATED_ENGINE_ID_QWANT,
PREPOPULATED_ENGINE_ID_BING,
PREPOPULATED_ENGINE_ID_STARTPAGE,
PREPOPULATED_ENGINE_ID_ECOSIA,
};

const std::vector<BravePrepopulatedEngineID> brave_engines_with_yahoo = {
PREPOPULATED_ENGINE_ID_YAHOO,
PREPOPULATED_ENGINE_ID_GOOGLE,
Expand All @@ -58,6 +67,16 @@ const std::vector<BravePrepopulatedEngineID> brave_engines_with_yahoo = {
PREPOPULATED_ENGINE_ID_STARTPAGE,
};

const std::vector<BravePrepopulatedEngineID> brave_engines_with_yahoo_ecosia = {
PREPOPULATED_ENGINE_ID_YAHOO,
PREPOPULATED_ENGINE_ID_GOOGLE,
PREPOPULATED_ENGINE_ID_DUCKDUCKGO,
PREPOPULATED_ENGINE_ID_QWANT,
PREPOPULATED_ENGINE_ID_BING,
PREPOPULATED_ENGINE_ID_STARTPAGE,
PREPOPULATED_ENGINE_ID_ECOSIA,
};

const std::vector<BravePrepopulatedEngineID> brave_engines_with_yandex = {
PREPOPULATED_ENGINE_ID_YANDEX,
PREPOPULATED_ENGINE_ID_GOOGLE,
Expand All @@ -74,6 +93,7 @@ const std::vector<BravePrepopulatedEngineID> brave_engines_DE = {
PREPOPULATED_ENGINE_ID_GOOGLE,
PREPOPULATED_ENGINE_ID_BING,
PREPOPULATED_ENGINE_ID_STARTPAGE,
PREPOPULATED_ENGINE_ID_ECOSIA,
};

const std::vector<BravePrepopulatedEngineID> brave_engines_FR = {
Expand All @@ -83,6 +103,7 @@ const std::vector<BravePrepopulatedEngineID> brave_engines_FR = {
PREPOPULATED_ENGINE_ID_DUCKDUCKGO,
PREPOPULATED_ENGINE_ID_BING,
PREPOPULATED_ENGINE_ID_STARTPAGE,
PREPOPULATED_ENGINE_ID_ECOSIA,
};

const std::vector<BravePrepopulatedEngineID> brave_engines_AU_NZ_IE = {
Expand All @@ -91,7 +112,8 @@ const std::vector<BravePrepopulatedEngineID> brave_engines_AU_NZ_IE = {
PREPOPULATED_ENGINE_ID_GOOGLE,
PREPOPULATED_ENGINE_ID_QWANT,
PREPOPULATED_ENGINE_ID_BING,
PREPOPULATED_ENGINE_ID_STARTPAGE};
PREPOPULATED_ENGINE_ID_STARTPAGE,
};

// A map to keep track of a full list of default engines for countries
// that don't use the default list.
Expand All @@ -107,30 +129,30 @@ const std::map<int, const std::vector<BravePrepopulatedEngineID>*>
&brave_engines_with_yahoo},
{country_codes::CountryCharsToCountryID('A', 'U'),
&brave_engines_AU_NZ_IE},
{country_codes::CountryCharsToCountryID('B', 'E'),
&brave_engines_with_ecosia},
{country_codes::CountryCharsToCountryID('B', 'R'),
&brave_engines_with_yahoo},
{country_codes::CountryCharsToCountryID('B', 'Y'),
&brave_engines_with_yandex},
{country_codes::CountryCharsToCountryID('C', 'A'),
&brave_engines_with_yahoo},
{country_codes::CountryCharsToCountryID('C', 'H'),
&brave_engines_with_yahoo},
&brave_engines_with_yahoo_ecosia},
{country_codes::CountryCharsToCountryID('C', 'L'),
&brave_engines_with_yahoo},
{country_codes::CountryCharsToCountryID('C', 'O'),
&brave_engines_with_yahoo},
{country_codes::CountryCharsToCountryID('D', 'E'),
&brave_engines_DE},
{country_codes::CountryCharsToCountryID('D', 'E'), &brave_engines_DE},
{country_codes::CountryCharsToCountryID('D', 'K'),
&brave_engines_with_yahoo},
{country_codes::CountryCharsToCountryID('E', 'S'),
&brave_engines_with_yahoo},
{country_codes::CountryCharsToCountryID('F', 'I'),
&brave_engines_with_yahoo},
{country_codes::CountryCharsToCountryID('F', 'R'),
&brave_engines_FR},
{country_codes::CountryCharsToCountryID('F', 'R'), &brave_engines_FR},
{country_codes::CountryCharsToCountryID('G', 'B'),
&brave_engines_with_yahoo},
&brave_engines_with_yahoo_ecosia},
{country_codes::CountryCharsToCountryID('H', 'K'),
&brave_engines_with_yahoo},
{country_codes::CountryCharsToCountryID('I', 'D'),
Expand All @@ -152,7 +174,7 @@ const std::map<int, const std::vector<BravePrepopulatedEngineID>*>
{country_codes::CountryCharsToCountryID('M', 'Y'),
&brave_engines_with_yahoo},
{country_codes::CountryCharsToCountryID('N', 'L'),
&brave_engines_with_yahoo},
&brave_engines_with_yahoo_ecosia},
{country_codes::CountryCharsToCountryID('N', 'O'),
&brave_engines_with_yahoo},
{country_codes::CountryCharsToCountryID('N', 'Z'),
Expand All @@ -164,7 +186,7 @@ const std::map<int, const std::vector<BravePrepopulatedEngineID>*>
{country_codes::CountryCharsToCountryID('R', 'U'),
&brave_engines_with_yandex},
{country_codes::CountryCharsToCountryID('S', 'E'),
&brave_engines_with_yahoo},
&brave_engines_with_yahoo_ecosia},
{country_codes::CountryCharsToCountryID('S', 'G'),
&brave_engines_with_yahoo},
{country_codes::CountryCharsToCountryID('T', 'H'),
Expand All @@ -176,7 +198,7 @@ const std::map<int, const std::vector<BravePrepopulatedEngineID>*>
{country_codes::CountryCharsToCountryID('T', 'W'),
&brave_engines_with_yahoo},
{country_codes::CountryCharsToCountryID('U', 'S'),
&brave_engines_with_yahoo},
&brave_engines_with_yahoo_ecosia},
{country_codes::CountryCharsToCountryID('U', 'Z'),
&brave_engines_with_yandex},
{country_codes::CountryCharsToCountryID('V', 'E'),
Expand Down
13 changes: 12 additions & 1 deletion components/search_engines/brave_prepopulated_engines.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace TemplateURLPrepopulateData {

// IMPORTANT! Make sure to bump this value if you make changes to the
// engines below or add/remove engines.
const int kBraveCurrentDataVersion = 8;
const int kBraveCurrentDataVersion = 9;
// DO NOT CHANGE THIS ONE. Used for backfilling kBraveDefaultSearchVersion.
const int kBraveFirstTrackedDataVersion = 6;

Expand Down Expand Up @@ -62,6 +62,7 @@ const std::map<BravePrepopulatedEngineID, const PrepopulatedEngine*>
{PREPOPULATED_ENGINE_ID_DUCKDUCKGO_AU_NZ_IE, &duckduckgo_au_nz_ie},
{PREPOPULATED_ENGINE_ID_QWANT, &qwant},
{PREPOPULATED_ENGINE_ID_STARTPAGE, &startpage},
{PREPOPULATED_ENGINE_ID_ECOSIA, &brave_ecosia},
};

PrepopulatedEngine ModifyEngineParams(const PrepopulatedEngine& engine,
Expand Down Expand Up @@ -152,6 +153,16 @@ const PrepopulatedEngine duckduckgo_lite = {
};
#endif

const PrepopulatedEngine brave_ecosia =
ModifyEngineParams(ecosia,
NULL,
L":e",
"https://www.ecosia.org/search?tt="
"42b8ae98"
"&q={{searchTerms}}",
"https://ac.ecosia.org/?q={searchTerms}",
PREPOPULATED_ENGINE_ID_ECOSIA);

const PrepopulatedEngine qwant = {
L"Qwant",
L":q",
Expand Down
3 changes: 2 additions & 1 deletion components/search_engines/brave_prepopulated_engines.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ enum BravePrepopulatedEngineID : unsigned int {
PREPOPULATED_ENGINE_ID_GOOGLE = 1,
PREPOPULATED_ENGINE_ID_BING = 3,
PREPOPULATED_ENGINE_ID_YANDEX = 15,
PREPOPULATED_ENGINE_ID_ECOSIA = 101,
// These engine IDs are not defined in Chromium
BRAVE_PREPOPULATED_ENGINES_START = 500,
PREPOPULATED_ENGINE_ID_AMAZON = 500, // No longer in defaults (2/2019).
PREPOPULATED_ENGINE_ID_DUCKDUCKGO,
#if defined(OS_ANDROID)
PREPOPULATED_ENGINE_ID_DUCKDUCKGO_LITE, // No longer in defaults (7/2020).
#endif
PREPOPULATED_ENGINE_ID_ECOSIA, // No longer in defaults (2/2019).
PREPOPULATED_ENGINE_ID_FINDX, // No longer exists (11/2018).
PREPOPULATED_ENGINE_ID_GITHUB, // No longer in defaults (2/2019).
PREPOPULATED_ENGINE_ID_INFOGALACTIC, // No longer in defaults (2/2019).
Expand Down Expand Up @@ -95,6 +95,7 @@ extern const PrepopulatedEngine duckduckgo_au_nz_ie;
#if defined(OS_ANDROID)
extern const PrepopulatedEngine duckduckgo_lite;
#endif
extern const PrepopulatedEngine brave_ecosia;
extern const PrepopulatedEngine qwant;
extern const PrepopulatedEngine startpage;
extern const PrepopulatedEngine brave_yandex;
Expand Down

0 comments on commit 61030fa

Please sign in to comment.