Skip to content

Commit

Permalink
Add Brave Search as an alternative search
Browse files Browse the repository at this point in the history
  • Loading branch information
bsclifton committed Jun 14, 2021
1 parent 114c50e commit 5623e40
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 2 deletions.
3 changes: 3 additions & 0 deletions browser/search_engines/search_engine_tracker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ void RecordSearchEngineP3A(const GURL& search_engine_url,
if (base::EndsWith(search_engine_url.host(), "startpage.com",
base::CompareCase::INSENSITIVE_ASCII)) {
answer = SearchEngineP3A::kStartpage;
} else if (base::EndsWith(search_engine_url.host(), "brave.com",
base::CompareCase::INSENSITIVE_ASCII)) {
answer = SearchEngineP3A::kBrave;
}
}

Expand Down
3 changes: 2 additions & 1 deletion browser/search_engines/search_engine_tracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ enum class SearchEngineP3A {
kQwant,
kYandex,
kEcosia,
kMaxValue = kEcosia,
kBrave,
kMaxValue = kBrave,
};

class SearchEngineTrackerFactory : public BrowserContextKeyedServiceFactory {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ namespace {
// Default order in which engines will appear in the UI.
const std::vector<BravePrepopulatedEngineID> brave_engines_default = {
PREPOPULATED_ENGINE_ID_GOOGLE,
PREPOPULATED_ENGINE_ID_BRAVE,
PREPOPULATED_ENGINE_ID_DUCKDUCKGO,
PREPOPULATED_ENGINE_ID_QWANT,
PREPOPULATED_ENGINE_ID_BING,
Expand All @@ -48,6 +49,7 @@ 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_BRAVE,
PREPOPULATED_ENGINE_ID_DUCKDUCKGO,
PREPOPULATED_ENGINE_ID_QWANT,
PREPOPULATED_ENGINE_ID_BING,
Expand All @@ -57,6 +59,7 @@ const std::vector<BravePrepopulatedEngineID> brave_engines_with_ecosia = {

const std::vector<BravePrepopulatedEngineID> brave_engines_with_yandex = {
PREPOPULATED_ENGINE_ID_YANDEX,
PREPOPULATED_ENGINE_ID_BRAVE,
PREPOPULATED_ENGINE_ID_GOOGLE,
PREPOPULATED_ENGINE_ID_DUCKDUCKGO,
PREPOPULATED_ENGINE_ID_QWANT,
Expand All @@ -66,6 +69,7 @@ const std::vector<BravePrepopulatedEngineID> brave_engines_with_yandex = {

const std::vector<BravePrepopulatedEngineID> brave_engines_DE = {
PREPOPULATED_ENGINE_ID_DUCKDUCKGO_DE,
PREPOPULATED_ENGINE_ID_BRAVE,
PREPOPULATED_ENGINE_ID_QWANT,
PREPOPULATED_ENGINE_ID_GOOGLE,
PREPOPULATED_ENGINE_ID_BING,
Expand All @@ -75,6 +79,7 @@ const std::vector<BravePrepopulatedEngineID> brave_engines_DE = {

const std::vector<BravePrepopulatedEngineID> brave_engines_FR = {
PREPOPULATED_ENGINE_ID_QWANT,
PREPOPULATED_ENGINE_ID_BRAVE,
PREPOPULATED_ENGINE_ID_GOOGLE,
PREPOPULATED_ENGINE_ID_DUCKDUCKGO,
PREPOPULATED_ENGINE_ID_BING,
Expand All @@ -84,6 +89,7 @@ const std::vector<BravePrepopulatedEngineID> brave_engines_FR = {

const std::vector<BravePrepopulatedEngineID> brave_engines_AU_IE = {
PREPOPULATED_ENGINE_ID_DUCKDUCKGO_AU_NZ_IE,
PREPOPULATED_ENGINE_ID_BRAVE,
PREPOPULATED_ENGINE_ID_GOOGLE,
PREPOPULATED_ENGINE_ID_QWANT,
PREPOPULATED_ENGINE_ID_BING,
Expand All @@ -93,6 +99,7 @@ const std::vector<BravePrepopulatedEngineID> brave_engines_AU_IE = {

const std::vector<BravePrepopulatedEngineID> brave_engines_NZ = {
PREPOPULATED_ENGINE_ID_DUCKDUCKGO_AU_NZ_IE,
PREPOPULATED_ENGINE_ID_BRAVE,
PREPOPULATED_ENGINE_ID_GOOGLE,
PREPOPULATED_ENGINE_ID_QWANT,
PREPOPULATED_ENGINE_ID_BING,
Expand Down
31 changes: 30 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 = 12;
const int kBraveCurrentDataVersion = 13;
// DO NOT CHANGE THIS ONE. Used for backfilling kBraveDefaultSearchVersion.
const int kBraveFirstTrackedDataVersion = 6;

Expand All @@ -30,6 +30,7 @@ const std::map<BravePrepopulatedEngineID, const PrepopulatedEngine*>
{PREPOPULATED_ENGINE_ID_QWANT, &qwant},
{PREPOPULATED_ENGINE_ID_STARTPAGE, &startpage},
{PREPOPULATED_ENGINE_ID_ECOSIA, &brave_ecosia},
{PREPOPULATED_ENGINE_ID_BRAVE, &brave_search},
};

PrepopulatedEngine ModifyEngineParams(const PrepopulatedEngine& engine,
Expand Down Expand Up @@ -193,6 +194,34 @@ const PrepopulatedEngine brave_yandex =
"part={searchTerms}&v=3&sn=5&srv=brave_desktop",
PREPOPULATED_ENGINE_ID_YANDEX);


const PrepopulatedEngine brave_search = {
L"Brave Search beta",
L":br",
"https://cdn.search.brave.com/serp/favicon.ico",
"https://search.brave.com/search?q={searchTerms}&source="
#if defined(OS_ANDROID)
"android",
#else
"desktop",
#endif
"UTF-8",
"https://search.brave.com/api/suggest?q={searchTerms}",
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
0,
SEARCH_ENGINE_OTHER,
PREPOPULATED_ENGINE_ID_BRAVE,
};


const std::map<BravePrepopulatedEngineID, const PrepopulatedEngine*>&
GetBraveEnginesMap() {
return brave_engines_map;
Expand Down
3 changes: 3 additions & 0 deletions components/search_engines/brave_prepopulated_engines.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ enum BravePrepopulatedEngineID : unsigned int {
PREPOPULATED_ENGINE_ID_YAHOO_UK,
PREPOPULATED_ENGINE_ID_YAHOO_VE,
PREPOPULATED_ENGINE_ID_YAHOO_VN,

PREPOPULATED_ENGINE_ID_BRAVE,
};

extern const PrepopulatedEngine duckduckgo;
Expand All @@ -101,6 +103,7 @@ extern const PrepopulatedEngine brave_ecosia;
extern const PrepopulatedEngine qwant;
extern const PrepopulatedEngine startpage;
extern const PrepopulatedEngine brave_yandex;
extern const PrepopulatedEngine brave_search;

const std::map<BravePrepopulatedEngineID, const PrepopulatedEngine*>&
GetBraveEnginesMap();
Expand Down

0 comments on commit 5623e40

Please sign in to comment.