Skip to content

Commit

Permalink
MB 213: Customize the search engines list
Browse files Browse the repository at this point in the history
  • Loading branch information
ruihildt authored and PieroV committed Jan 15, 2024
1 parent d2214c8 commit 3e79437
Show file tree
Hide file tree
Showing 14 changed files with 220 additions and 24 deletions.
19 changes: 19 additions & 0 deletions browser/components/search/extensions/brave/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions browser/components/search/extensions/brave/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "Brave Search",
"manifest_version": 2,
"version": "1.0",
"applications": {
"gecko": {
"id": "[email protected]"
}
},
"hidden": true,
"icons": {
"16": "favicon.svg",
"32": "favicon.svg",
"96": "favicon.svg",
"128": "favicon.svg"
},
"web_accessible_resources": [
"favicon.svg"
],
"chrome_settings_overrides": {
"search_provider": {
"name": "Brave Search",
"keyword": ["@brave", "@bv"],
"search_form": "https://search.brave.com/search",
"search_url": "https://search.brave.com/search",
"search_url_get_params": "q={searchTerms}",
"suggest_url": "https://search.brave.com/api/suggest",
"suggest_url_get_params": "q={searchTerms}"
}
}
}
Binary file not shown.
27 changes: 27 additions & 0 deletions browser/components/search/extensions/ddg-html/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "DuckDuckGo HTML",
"description": "Search DuckDuckGo HTML",
"manifest_version": 2,
"version": "1.4",
"browser_specific_settings": {
"gecko": {
"id": "[email protected]"
}
},
"hidden": true,
"icons": {
"16": "favicon.ico"
},
"web_accessible_resources": ["favicon.ico"],
"chrome_settings_overrides": {
"search_provider": {
"keyword": ["@duckduckgohtml", "@ddgh"],
"name": "DuckDuckGo HTML",
"search_url": "https://html.duckduckgo.com/html/",
"search_form": "https://html.duckduckgo.com/html/",
"search_url_get_params": "q={searchTerms}",
"suggest_url": "https://duckduckgo.com/ac/",
"suggest_url_get_params": "q={searchTerms}&type=list"
}
}
}
2 changes: 1 addition & 1 deletion browser/components/search/extensions/ddg/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"name": "DuckDuckGo",
"search_url": "https://duckduckgo.com/",
"search_form": "https://duckduckgo.com/",
"search_url_get_params": "t=ffab&q={searchTerms}",
"search_url_get_params": "q={searchTerms}",
"suggest_url": "https://ac.duckduckgo.com/ac/",
"suggest_url_get_params": "q={searchTerms}&type=list"
}
Expand Down
Binary file not shown.
27 changes: 27 additions & 0 deletions browser/components/search/extensions/metager/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "MetaGer (en)",
"manifest_version": 2,
"version": "1.0",
"applications": {
"gecko": {
"id": "[email protected]"
}
},
"hidden": true,
"icons": {
"16": "favicon.ico",
"32": "favicon.ico",
"96": "favicon.ico",
"128": "favicon.ico"
},
"web_accessible_resources": [
"favicon.ico"
],
"chrome_settings_overrides": {
"search_provider": {
"name": "MetaGer",
"keyword": ["@metager", "@mg"],
"search_url": "https://metager.org/meta/meta.ger3?eingabe={searchTerms}"
}
}
}
Binary file not shown.
24 changes: 24 additions & 0 deletions browser/components/search/extensions/mojeek/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "Mojeek",
"manifest_version": 2,
"version": "1.0",
"browser_specific_settings": {
"gecko": {
"id": "[email protected]"
}
},
"hidden": true,
"icons": {
"16": "favicon.ico",
"32": "favicon.ico"
},
"web_accessible_resources": ["favicon.ico"],
"chrome_settings_overrides": {
"search_provider": {
"keyword": ["@mj", "@mojeek"],
"name": "Mojeek",
"search_url": "https://www.mojeek.com/search",
"search_url_get_params": "q={searchTerms}"
}
}
}
25 changes: 25 additions & 0 deletions browser/components/search/extensions/mullvad-leta/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions browser/components/search/extensions/mullvad-leta/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "Mullvad Leta",
"manifest_version": 2,
"version": "1.0",
"browser_specific_settings": {
"gecko": {
"id": "[email protected]"
}
},
"hidden": true,
"icons": {
"16": "favicon.svg",
"32": "favicon.svg",
"96": "favicon.svg",
"128": "favicon.svg"
},
"web_accessible_resources": ["favicon.svg"],
"chrome_settings_overrides": {
"search_provider": {
"keyword": ["@leta", "@mullvad", "@ml"],
"name": "Mullvad Leta",
"search_url": "https://leta.mullvad.net/",
"search_url_get_params": "q={searchTerms}"
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions browser/components/search/extensions/startpage/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "Startpage",
"description": "Startpage",
"manifest_version": 2,
"version": "1.0",
"applications": {
"gecko": {
"id": "[email protected]"
}
},
"hidden": true,
"icons": {
"16": "favicon.png"
},
"web_accessible_resources": [
"favicon.png"
],
"chrome_settings_overrides": {
"search_provider": {
"name": "Startpage",
"keyword": ["@startpage", "@sp"],
"search_url": "https://www.startpage.com/sp/search",
"search_form": "https://www.startpage.com/sp/search/",
"search_url_post_params": "q={searchTerms}"
}
}
}
36 changes: 13 additions & 23 deletions toolkit/components/search/SearchService.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1327,11 +1327,6 @@ export class SearchService {

let result = Cr.NS_OK;
try {
// Create the search engine selector.
this.#engineSelector = new lazy.SearchEngineSelector(
this.#handleConfigurationUpdated.bind(this)
);

// See if we have a settings file so we don't have to parse a bunch of XML.
let settings = await this._settings.get();

Expand Down Expand Up @@ -2278,23 +2273,18 @@ export class SearchService {
// This is prefixed with _ rather than # because it is
// called in test_remove_engine_notification_box.js
async _fetchEngineSelectorEngines() {
let searchEngineSelectorProperties = {
locale: Services.locale.appLocaleAsBCP47,
region: lazy.Region.home || "default",
channel: lazy.SearchUtils.MODIFIED_APP_CHANNEL,
experiment:
lazy.NimbusFeatures.searchConfiguration.getVariable("experiment") ?? "",
distroID: lazy.SearchUtils.distroID ?? "",
};

for (let [key, value] of Object.entries(searchEngineSelectorProperties)) {
this._settings.setMetaDataAttribute(key, value);
}

let { engines, privateDefault } =
await this.#engineSelector.fetchEngineConfiguration(
searchEngineSelectorProperties
);
const engines = [
{ webExtension: { id: "[email protected]" }, orderHint: 100 },
{ webExtension: { id: "[email protected]" }, orderHint: 90 },
{
webExtension: { id: "[email protected]" },
orderHint: 80,
},
{ webExtension: { id: "[email protected]" }, orderHint: 70 },
{ webExtension: { id: "[email protected]" }, orderHint: 60 },
{ webExtension: { id: "[email protected]" }, orderHint: 50 },
{ webExtension: { id: "[email protected]" }, orderHint: 40 },
];

for (let e of engines) {
if (!e.webExtension) {
Expand All @@ -2304,7 +2294,7 @@ export class SearchService {
e.webExtension?.locale ?? lazy.SearchUtils.DEFAULT_TAG;
}

return { engines, privateDefault };
return { engines, privateDefault: undefined };
}

#setDefaultAndOrdersFromSelector(engines, privateDefault) {
Expand Down

0 comments on commit 3e79437

Please sign in to comment.