nsISupports
Last changed in Gecko 2.0 (Firefox 4 / Thunderbird 3.3 / SeaMonkey 2.1)Implemented by: @mozilla.org/browser/search-service;1
. To access this service, use:
var browserSearchService = Components.classes["@mozilla.org/browser/search-service;1"] .getService(Components.interfaces.nsIBrowserSearchService);
Attempting to use any method or attribute of this interface before init()
has completed will force the service to fall back to a slower, synchronous, initialization. This is not an issue if your code is executed in reaction to a user interaction, as initialization is complete by then, but this is an issue if your code is executed during startup.
If you need to write code that is executed during startup and makes use of nsIBrowserSearchService, you should make sure that this code is executed from the callback to init()
.
void addEngine(in AString engineURL, in long dataType, in AString iconURL, in boolean confirm, [optional] in nsISearchInstallCallback callback); |
void addEngineWithDetails(in AString name, in AString iconURL, in AString alias, in AString description, in AString method, in AString url); |
void getDefaultEngines([optional] out unsigned long engineCount, [retval, array, size_is(engineCount)] out nsISearchEngine engines); |
nsISearchEngine getEngineByAlias(in AString alias); |
nsISearchEngine getEngineByName(in AString aEngineName); |
void getEngines([optional] out unsigned long engineCount, [retval, array, size_is(engineCount)] out nsISearchEngine engines); |
void getVisibleEngines([optional] out unsigned long engineCount, [retval, array, size_is(engineCount)] out nsISearchEngine engines); |
void init([optional] in nsIBrowserSearchInitObserver observer ); |
void moveEngine(in nsISearchEngine engine, in long newIndex); |
void removeEngine(in nsISearchEngine engine); |
void restoreDefaultEngines(); |
Attribute | Type | Description |
currentEngine |
|
The currently active search engine. May be null if there are no visible search engines. |
defaultEngine |
|
The default search engine. Returns the first visible engine if the default engine is hidden. May be null if there are no visible search engines. Read only. |
originalDefaultEngine |
|
The original default engine. This differs from the "defaultEngine " attribute in that it always returns a given build's default engine, regardless of whether it is hidden. Read only. |
Adds a new search engine from the file at the supplied URI, optionally asking the user for confirmation first. If a confirmation dialog is shown, it will offer the option to begin using the newly added engine right away; if no confirmation dialog is shown, the new engine will be used right away automatically.
void addEngine( in AString engineURL, in long dataType, in AString iconURL, in boolean confirm, [optional] in nsISearchInstallCallback callback );
engineURL
dataType
iconURL
confirm
false
, the engine will be added to the list upon successful load, but it will not be selected as the current engine.callback
addEngine
throws an exception.NS_ERROR_FAILURE
Adds a new search engine, without asking the user for confirmation and without starting to use it right away.
void addEngineWithDetails( in AString name, in AString iconURL, in AString alias, in AString description, in AString method, in AString url );
name
null
.iconURL
alias
description
method
url
null
.Returns an array of all default search engines. This includes all loaded engines that aren't in the user's profile directory (NS_APP_USER_SEARCH_DIR).
void getDefaultEngines( [optional] out unsigned long engineCount, [retval, array, size_is(engineCount)] out nsISearchEngine engines );
engineCount
engines
nsISearchEngine
s.Returns an engine with the specified alias.
nsISearchEngine getEngineByAlias( in AString alias );
alias
Returns an engine with the specified name.
nsISearchEngine getEngineByName( in AString aEngineName );
aEngineName
The specified nsISearchEngine
.
Returns an array of all installed search engines.
void getEngines( [optional] out unsigned long engineCount, [retval, array, size_is(engineCount)] out nsISearchEngine engines );
engineCount
engines
nsISearchEngine
s.Returns an array of all installed search engines whose hidden attribute is false
.
void getVisibleEngines( [optional] out unsigned long engineCount, [retval, array, size_is(engineCount)] out nsISearchEngine engines );
engineCount
engines
nsISearchEngine
s.Initialize the service, or if the service is already initialized, do nothing.
This method was introduced in Firefox 16.
Attempting to call any method of this interface before init()
has completed will force the service to fall back to a slower, synchronous, initialization.
If your code requires nsIBrowserSearchService and is executed during startup, you should make sure that this code is executed from the callback to init()
.
void init( [optional] in nsIBrowserSearchInitObserver observer );
Moves a visible search engine.
void moveEngine( in nsISearchEngine engine, in long newIndex );
engine
newIndex
NS_ERROR_FAILURE
Removes the search engine. If the search engine is installed in a global location, this will just hide the engine. If the engine is in the user's profile directory, it will be removed from disk.
void removeEngine( in nsISearchEngine engine );
engine
Un-hides all engines installed in the directory corresponding to the directory service's NS_APP_SEARCH_DIR key. (that is the set of engines returned by getDefaultEngines()
)
void restoreDefaultEngines();
None.