Bug 587691: need a way to access the original default engine (the normal "defaultEngine" can change if the original is hidden by the user), r=Ryan, a=blocker

This commit is contained in:
Gavin Sharp 2010-08-20 17:40:16 -04:00
Родитель a181af746b
Коммит 3120e2b54f
2 изменённых файлов: 18 добавлений и 10 удалений

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

@ -312,17 +312,23 @@ interface nsIBrowserSearchService : nsISupports
void removeEngine(in nsISearchEngine engine);
/**
* The default search engine. May be null if there are no visible
* search engines installed.
* 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.
*/
readonly attribute nsISearchEngine defaultEngine;
/**
* The currently active search engine. May be null if there are no visible
* search engines installed.
* search engines.
*/
attribute nsISearchEngine currentEngine;
/**
* 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.
*/
readonly attribute nsISearchEngine originalDefaultEngine;
};
%{ C++

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

@ -3356,14 +3356,16 @@ SearchService.prototype = {
}
},
get defaultEngine() {
get originalDefaultEngine() {
const defPref = BROWSER_SEARCH_PREF + "defaultenginename";
// Get the default engine - this pref should always exist, but the engine
// might be hidden
this._defaultEngine = this.getEngineByName(getLocalizedPref(defPref, ""));
if (!this._defaultEngine || this._defaultEngine.hidden)
this._defaultEngine = this._getSortedEngines(false)[0] || null;
return this._defaultEngine;
return this.getEngineByName(getLocalizedPref(defPref, ""));
},
get defaultEngine() {
let defaultEngine = this.originalDefaultEngine;
if (!defaultEngine || defaultEngine.hidden)
defaultEngine = this._getSortedEngines(false)[0] || null;
return defaultEngine;
},
get currentEngine() {