Bug 722332 - Adapt main clients to asynchronous nsIBrowserSearchService API. r=gavin

This commit is contained in:
David Rajchenbach-Teller 2012-04-19 16:08:09 +02:00
Родитель ccc6f3119c
Коммит 8bebb8777d
2 изменённых файлов: 35 добавлений и 15 удалений

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

@ -67,25 +67,25 @@
<constructor><![CDATA[
if (this.parentNode.parentNode.localName == "toolbarpaletteitem")
return;
setTimeout(function (a) { a.init(); }, 0, this);
]]></constructor>
// Make sure we rebuild the popup in onpopupshowing
this._needToBuildPopup = true;
<method name="init">
<body><![CDATA[
// Make sure we rebuild the popup in onpopupshowing
this._needToBuildPopup = true;
// Refresh the display (updating icon, etc)
this.updateDisplay();
var os =
var os =
Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService);
os.addObserver(this, "browser-search-engine-modified", false);
os.addObserver(this, "browser-search-engine-modified", false);
this._addedObserver = true;
]]></body>
</method>
this._addedObserver = true;
this.searchService.init((function search_init_cb(aStatus) {
if (Components.isSuccessCode(aStatus)) {
// Refresh the display (updating icon, etc)
this.updateDisplay();
} else {
Components.utils.reportError("Cannot initialize search service, bailing out: " + aStatus);
}
}).bind(this));
]]></constructor>
<destructor><![CDATA[
if (this._addedObserver) {

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

@ -399,6 +399,26 @@ SuggestAutoComplete.prototype = {
if (!previousResult)
this._formHistoryResult = null;
// Start search immediately if possible, otherwise once the search
// service is initialized
if (Services.search.isInitialized) {
this._triggerSearch(searchString, searchParam, listener);
return;
}
Services.search.init((function startSearch_cb(aResult) {
if (!Components.isSuccessCode(aResult)) {
Cu.reportError("Could not initialize search service, bailing out: " + aResult);
return;
}
this._triggerSearch(searchString, searchParam, listener);
}).bind(this));
},
/**
* Actual implementation of search.
*/
_triggerSearch: function(searchString, searchParam, listener) {
// If there's an existing request, stop it. There is no smart filtering
// here as there is when looking through history/form data because the
// result set returned by the server is different for every typed value -