Bug 1553237 - Simplify nsISearchService.addEngineWithDetails to one signature. r=Standard8

Differential Revision: https://phabricator.services.mozilla.com/D34709

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Karan Sapolia 2019-06-13 20:35:23 +00:00
Родитель 81efe13915
Коммит 3cb0a39af4
5 изменённых файлов: 27 добавлений и 63 удалений

Просмотреть файл

@ -6157,7 +6157,7 @@ var SearchEngines = {
name = title.value + " " + i; name = title.value + " " + i;
} }
await Services.search.addEngineWithDetails(name, data, null, null, method, formURL); await Services.search.addEngineWithDetails(name, details);
Snackbars.show(Strings.browser.formatStringFromName("alertSearchEngineAddedToast", [name]), Snackbars.LENGTH_LONG); Snackbars.show(Strings.browser.formatStringFromName("alertSearchEngineAddedToast", [name]), Snackbars.LENGTH_LONG);
let engine = Services.search.getEngineByName(name); let engine = Services.search.getEngineByName(name);

Просмотреть файл

@ -12,7 +12,7 @@ var {Task} = ChromeUtils.import("resource://testing-common/Task.jsm");
* Array of objects with the following properties: * Array of objects with the following properties:
* { * {
* name: Engine name, used to wait for it to be loaded. * name: Engine name, used to wait for it to be loaded.
* details: Array containing the parameters of addEngineWithDetails, * details: Object containing the parameters of addEngineWithDetails,
* except for the engine name. Alternative to xmlFileName. * except for the engine name. Alternative to xmlFileName.
* } * }
*/ */

Просмотреть файл

@ -1825,23 +1825,10 @@ SearchService.prototype = {
return null; return null;
}, },
async addEngineWithDetails(name, iconURL, alias, description, method, template, extensionID) { async addEngineWithDetails(name, details) {
SearchUtils.log("addEngineWithDetails: Adding \"" + name + "\"."); SearchUtils.log("addEngineWithDetails: Adding \"" + name + "\".");
let isCurrent = false; let isCurrent = false;
var params; var params = details;
if (iconURL && typeof iconURL == "object") {
params = iconURL;
} else {
params = {
iconURL,
alias,
description,
method,
template,
extensionID,
};
}
let isBuiltin = !!params.isBuiltin; let isBuiltin = !!params.isBuiltin;
// We install search extensions during the init phase, both built in // We install search extensions during the init phase, both built in

Просмотреть файл

@ -296,61 +296,38 @@ interface nsISearchService : nsISupports
* @param name * @param name
* The search engine's name. Must be unique. Must not be null. * The search engine's name. Must be unique. Must not be null.
* *
* @param iconURL * @param details
* Optional: A URL string pointing to the icon to be used to represent * An object that can contain the following fields:
* the engine.
* This is a jsval so that an object can be passed to replace the
* parameters below.
* *
* @param alias * {iconURL} Optional: A URL string pointing to the icon to be used to
* Optional: A unique shortcut that can be used to retrieve the * represent the engine.
* search engine.
* *
* @param description * {alias} Optional: A unique shortcut that can be used to retrieve the
* Optional: a description of the search engine. * search engine.
* *
* @param method * {description} Optional: A description of the search engine.
* Optional: The HTTP request method used when submitting a search query.
* Case insensitive value of either "get" or "post".
* Defaults to "get".
* *
* @param template * {method} Optional: The HTTP request method used when submitting a
* The template for the URL to which search queries should be sent. The * search query. Case insensitive value of either "get" or "post".
* template will be subjected to OpenSearch parameter substitution. * Defaults to "get".
* See http://www.opensearch.org/Specifications/OpenSearch
* Must not be null.
* *
* @param extensionID [optional] * {template} The template for the URL to which search queries should be
* Optional: The correct extensionID if called by an add-on. * sent. The template will be subjected to OpenSearch parameter
* substitution.
* See http://www.opensearch.org/Specifications/OpenSearch
* Must not be null.
* *
* Alternatively, all of these parameters except for name can be * {extensionID} Optional: The correct extensionID if called by an add-on.
* passed as an object in place of parameter two.
* *
* Services.search.addEngineWithDetails("Example engine", { * {suggestURL} Optional: The URL to which search suggestion requests should
* template: "http://example.com/?search={searchTerms}", * be sent.
* description: "Example search engine description",
* suggestURL: http://example.com/?suggest={searchTerms},
* });
* *
* Using this method, you can use new parameters: * {postData} Optional: For POST requests, a string of URL parameters to send,
* * seperated by '&'. The string will be subjected to OpenSearch
* @param suggestURL [optional] * parameter substitution.
* Optional: The URL to which search suggestion requests
* should be sent.
*
* @param postData [optional]
* Optional: For POST requests, a string of URL parameters
* to send, separated by '&'. The string will be subjected
* to OpenSearch parameter substitution.
* *
*/ */
Promise addEngineWithDetails(in AString name, Promise addEngineWithDetails(in AString name, in jsval details);
in jsval iconURL,
[optional] in AString alias,
[optional] in AString description,
[optional] in AString method,
[optional] in AString url,
[optional] in AString extensionID);
/** /**
* Adds search providers to the search service. If the search * Adds search providers to the search service. If the search

Просмотреть файл

@ -368,7 +368,7 @@ function checkRequest(requests, cohort = "") {
* { * {
* name: Engine name, used to wait for it to be loaded. * name: Engine name, used to wait for it to be loaded.
* xmlFileName: Name of the XML file in the "data" folder. * xmlFileName: Name of the XML file in the "data" folder.
* details: Array containing the parameters of addEngineWithDetails, * details: Object containing the parameters of addEngineWithDetails,
* except for the engine name. Alternative to xmlFileName. * except for the engine name. Alternative to xmlFileName.
* } * }
*/ */