зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
81efe13915
Коммит
3cb0a39af4
|
@ -6157,7 +6157,7 @@ var SearchEngines = {
|
|||
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);
|
||||
|
||||
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:
|
||||
* {
|
||||
* 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.
|
||||
* }
|
||||
*/
|
||||
|
|
|
@ -1825,23 +1825,10 @@ SearchService.prototype = {
|
|||
return null;
|
||||
},
|
||||
|
||||
async addEngineWithDetails(name, iconURL, alias, description, method, template, extensionID) {
|
||||
async addEngineWithDetails(name, details) {
|
||||
SearchUtils.log("addEngineWithDetails: Adding \"" + name + "\".");
|
||||
let isCurrent = false;
|
||||
var params;
|
||||
|
||||
if (iconURL && typeof iconURL == "object") {
|
||||
params = iconURL;
|
||||
} else {
|
||||
params = {
|
||||
iconURL,
|
||||
alias,
|
||||
description,
|
||||
method,
|
||||
template,
|
||||
extensionID,
|
||||
};
|
||||
}
|
||||
var params = details;
|
||||
|
||||
let isBuiltin = !!params.isBuiltin;
|
||||
// We install search extensions during the init phase, both built in
|
||||
|
|
|
@ -296,61 +296,38 @@ interface nsISearchService : nsISupports
|
|||
* @param name
|
||||
* The search engine's name. Must be unique. Must not be null.
|
||||
*
|
||||
* @param iconURL
|
||||
* Optional: A URL string pointing to the icon to be used to represent
|
||||
* the engine.
|
||||
* This is a jsval so that an object can be passed to replace the
|
||||
* parameters below.
|
||||
* @param details
|
||||
* An object that can contain the following fields:
|
||||
*
|
||||
* @param alias
|
||||
* Optional: A unique shortcut that can be used to retrieve the
|
||||
* search engine.
|
||||
* {iconURL} Optional: A URL string pointing to the icon to be used to
|
||||
* represent the engine.
|
||||
*
|
||||
* @param description
|
||||
* Optional: a description of the search engine.
|
||||
* {alias} Optional: A unique shortcut that can be used to retrieve the
|
||||
* search engine.
|
||||
*
|
||||
* @param method
|
||||
* Optional: The HTTP request method used when submitting a search query.
|
||||
* Case insensitive value of either "get" or "post".
|
||||
* Defaults to "get".
|
||||
* {description} Optional: A description of the search engine.
|
||||
*
|
||||
* @param template
|
||||
* The template for the URL to which search queries should be sent. The
|
||||
* template will be subjected to OpenSearch parameter substitution.
|
||||
* See http://www.opensearch.org/Specifications/OpenSearch
|
||||
* Must not be null.
|
||||
* {method} Optional: The HTTP request method used when submitting a
|
||||
* search query. Case insensitive value of either "get" or "post".
|
||||
* Defaults to "get".
|
||||
*
|
||||
* @param extensionID [optional]
|
||||
* Optional: The correct extensionID if called by an add-on.
|
||||
* {template} The template for the URL to which search queries should be
|
||||
* 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
|
||||
* passed as an object in place of parameter two.
|
||||
* {extensionID} Optional: The correct extensionID if called by an add-on.
|
||||
*
|
||||
* Services.search.addEngineWithDetails("Example engine", {
|
||||
* template: "http://example.com/?search={searchTerms}",
|
||||
* description: "Example search engine description",
|
||||
* suggestURL: http://example.com/?suggest={searchTerms},
|
||||
* });
|
||||
* {suggestURL} Optional: The URL to which search suggestion requests should
|
||||
* be sent.
|
||||
*
|
||||
* Using this method, you can use new parameters:
|
||||
*
|
||||
* @param suggestURL [optional]
|
||||
* 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.
|
||||
* {postData} Optional: For POST requests, a string of URL parameters to send,
|
||||
* seperated by '&'. The string will be subjected to OpenSearch
|
||||
* parameter substitution.
|
||||
*
|
||||
*/
|
||||
Promise addEngineWithDetails(in AString name,
|
||||
in jsval iconURL,
|
||||
[optional] in AString alias,
|
||||
[optional] in AString description,
|
||||
[optional] in AString method,
|
||||
[optional] in AString url,
|
||||
[optional] in AString extensionID);
|
||||
Promise addEngineWithDetails(in AString name, in jsval details);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* 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.
|
||||
* }
|
||||
*/
|
||||
|
|
Загрузка…
Ссылка в новой задаче