nsISearchEngine 编辑

netwerk/base/public/nsIBrowserSearchService.idlScriptable Please add a summary to this article.   Last changed in Gecko 1.8 (Firefox 1.5 / Thunderbird 1.5 / SeaMonkey 1.0)

Inherits from: nsISupports

Method overview

void addParam(in AString name, in AString value, in AString responseType);
nsISearchSubmission getSubmission(in AString data, [optional] in AString responseType,[optional] in AString purpose);
boolean supportsResponseType(in AString responseType);

Attributes

AttributeTypeDescription
aliasAStringAn optional shortcut alias for the engine. When non-null, this is a unique identifier.
descriptionAStringA text description describing the engine. Read only.
hiddenbooleanWhether the engine should be hidden from the user.
iconURInsIURIA nsIURI corresponding to the engine's icon, stored locally. May be null. Read only.
nameAStringThe display name of the search engine. This is a unique identifier. Read only.
searchFormAStringA URL string pointing to the engine's search form. Read only.
typelongThe search engine type. Read only.

Constants

Search engine type constants

ConstantValueDescription
TYPE_MOZSEARCH1 
TYPE_SHERLOCK2 
TYPE_OPENSEARCH3 

Search engine data type constants

ConstantValueDescription
DATA_XML1Data type is XML
DATA_TEXT2Data type is Text.

Methods

addParam()

Adds a parameter to the search engine's submission data. This should only be called on engines created via nsIBrowserSearchService.addEngineWithDetails().

void addParam(
  in AString name,
  in AString value,
  in AString responseType
);
Parameters
name
The name of the parameter to add.
value
The value to pass. If value is "{searchTerms}", it will be substituted with the user-entered data when retrieving the submission. Must not be null.
responseType
Since an engine can have several different request URLs, differentiated by response types, this parameter selects a request to add parameters to. If null, will default to "text/html"
Exceptions thrown
NS_ERROR_INVALID_ARG
If name or value are null.
NS_ERROR_FAILURE
If the search engine is read-only.

getSubmission()

Gets a nsISearchSubmission object that contains information about what to send to the search engine, including the URI and postData, if applicable.

nsISearchSubmission getSubmission(
  in AString data,
  [optional] in AString responseType,
  [optional] in AString purpose
);
Parameters
data
Data to add to the submission object. That is the search terms.
responseType
[optional] The MIME type that we'd like to receive in response to this submission. If null, will default to "text/html".
purpose
[optional] A string meant to indicate the context of the search request. This allows the search service to provide a different nsISearchSubmission depending on e.g. where the search is triggered in the UI. Possible values depend on the application's installed search engines.
Return value

An nsISearchSubmission

supportsResponseType()

Determines whether the engine can return responses in the given MIME type.

boolean supportsResponseType(
  in AString responseType
);
Parameters
responseType
The MIME type to check for.
Return value

Returns true if the engine spec has a URL with the given responseType, false otherwise.

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:109 次

字数:8796

最后编辑:8年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文