Bug 1633143 - Update urlbarBindings for Services and Observers - search init part. r=frg

This commit is contained in:
Ian Neal 2020-04-25 12:28:47 +01:00
Родитель 37fc9d94e8
Коммит ed424e7376
1 изменённых файлов: 23 добавлений и 4 удалений

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

@ -347,19 +347,23 @@
<xul:box role="search-box" class="autocomplete-search-box"/>
</content>
<implementation implements="nsIObserver">
<implementation implements="nsIObserver, nsIBrowserSearchInitObserver">
<constructor><![CDATA[
// listen for changes to default search engine
Services.prefs.addObserver("browser.search", this);
Services.prefs.addObserver("browser.urlbar", this);
Services.obs.addObserver(this, "browser-search-engine-modified");
this.updateEngines();
this._initialized = true;
Services.search.init(this);
]]></constructor>
<destructor><![CDATA[
Services.prefs.removeObserver("browser.search", this);
Services.prefs.removeObserver("browser.urlbar", this);
Services.obs.removeObserver(this, "browser-search-engine-modified");
if (this._initialized) {
this._initialized = false;
Services.obs.removeObserver(this, "browser-search-engine-modified");
}
]]></destructor>
<property name="showSearch" onget="return this.mShowSearch;">
@ -399,6 +403,7 @@
});
]]></field>
<field name="_initialized">false</field>
<field name="mEnginesReady">false</field>
<property name="overrideValue" readonly="true">
@ -423,7 +428,7 @@
break;
case "nsPref:changed":
if (/^browser\.search\./.test(aData))
this.updateEngines();
Services.search.init(this);
else if (aData == "browser.urlbar.showSearch")
this.updateShowSearch();
break;
@ -438,6 +443,20 @@
]]></body>
</method>
<method name="onInitComplete">
<parameter name="aStatus"/>
<body><![CDATA[
if (!this._initialized)
return;
if (Components.isSuccessCode(aStatus)) {
// Refresh the engines.
this.updateEngines();
} else {
Cu.reportError("Cannot initialize search service, bailing out: " + aStatus);
}
]]></body>
</method>
<method name="addEngine">
<parameter name="aName"/>
<parameter name="aIcon"/>