Bug 1588570 - Port |Bug 1203524 - search.xml should use Services.jsm| to SeaMonkey r=frg

This commit is contained in:
Ian Neal 2019-10-20 17:40:58 +02:00
Родитель da8704c311
Коммит 8cc23706ef
1 изменённых файлов: 17 добавлений и 28 удалений

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

@ -81,7 +81,7 @@
Services.obs.addObserver(this, "browser-search-engine-modified");
this._initialized = true;
this.searchService.init(this);
Services.search.init(this);
]]></constructor>
<destructor><![CDATA[
@ -108,10 +108,6 @@
"anonid", "searchbar-popup");</field>
<field name="searchButton">document.getAnonymousElementByAttribute(this,
"anonid", "searchbar-engine-button");</field>
<field name="_searchService">
Cc["@mozilla.org/browser/search-service;1"]
.getService(Ci.nsIBrowserSearchService);
</field>
<field name="usePrivateBrowsing" readonly="true">
window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
@ -129,21 +125,20 @@
<property name="engines" readonly="true">
<getter><![CDATA[
if (!this._engines)
this._engines = this.searchService.getVisibleEngines();
this._engines = Services.search.getVisibleEngines();
return this._engines;
]]></getter>
</property>
<property name="currentEngine">
<setter><![CDATA[
this.searchService.currentEngine = val;
var os = Cc["@mozilla.org/observer-service;1"]
.getService(Ci.nsIObserverService);
os.notifyObservers(null, "browser-search-engine-modified", "engine-current");
Services.search.currentEngine = val;
Services.obs.notifyObservers(null, "browser-search-engine-modified",
"engine-current");
return val;
]]></setter>
<getter><![CDATA[
var currentEngine = this.searchService.currentEngine;
var currentEngine = Services.search.currentEngine;
// Return a dummy engine if there is no currentEngine
return currentEngine || {name: "", uri: null};
]]></getter>
@ -154,9 +149,6 @@
<property name="textbox" readonly="true"
onget="return this._textbox;"/>
<property name="searchService" readonly="true"
onget="return this._searchService;"/>
<property name="value" onget="return this._textbox.value;"
onset="return this._textbox.value = val;"/>
@ -453,7 +445,7 @@
where = whereToOpenLink(aEvent, false, true);
}
else {
var newTabPref = textBox._prefBranch.getBoolPref("browser.search.openintab");
var newTabPref = Services.prefs.getBoolPref("browser.search.openintab");
if ((aEvent && aEvent.altKey) ^ newTabPref)
where = "tabfocused";
}
@ -495,9 +487,9 @@
// We only detect OpenSearch files
var type = Ci.nsISearchEngine.DATA_XML;
// Select the installed engine if the installation succeeds
this.searchService.addEngine(target.getAttribute("uri"), type,
target.getAttribute("image"), false,
this);
Services.search.addEngine(target.getAttribute("uri"), type,
target.getAttribute("image"), false,
this);
}
else
return;
@ -530,7 +522,7 @@
"toolbarpaletteitem")
return;
if (this._prefBranch.getBoolPref("browser.urlbar.clickSelectsAll"))
if (Services.prefs.getBoolPref("browser.urlbar.clickSelectsAll"))
this.setAttribute("clickSelectsAll", true);
// Add items to context menu and attach controller to handle them
@ -538,13 +530,13 @@
document.getBindingParent(this)._textboxInitialized = true;
// Add observer for suggest preference
this._prefBranch.addObserver("browser.search.suggest.enabled", this);
Services.prefs.addObserver("browser.search.suggest.enabled", this);
this._inputBox.setAttribute("suggestchecked", this._suggestEnabled);
]]></constructor>
<destructor><![CDATA[
this._prefBranch.removeObserver("browser.search.suggest.enabled", this);
Services.prefs.removeObserver("browser.search.suggest.enabled", this);
// Because XBL and the customize toolbar code interacts poorly,
// there may not be anything to remove here
@ -552,14 +544,11 @@
this.controllers.removeController(this.searchbarController);
} catch (ex) { }
]]></destructor>
<field name="_prefBranch">
Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
</field>
<field name="_inputBox">
document.getAnonymousElementByAttribute(this, "anonid", "textbox-input-box");
</field>
<field name="_suggestEnabled">
this._prefBranch.getBoolPref("browser.search.suggest.enabled");
Services.prefs.getBoolPref("browser.search.suggest.enabled");
</field>
<method name="observe">
@ -569,7 +558,7 @@
<body><![CDATA[
if (aTopic == "nsPref:changed") {
this._suggestEnabled =
this._prefBranch.getBoolPref("browser.search.suggest.enabled");
Services.prefs.getBoolPref("browser.search.suggest.enabled");
this._inputBox.setAttribute("suggestchecked", this._suggestEnabled);
}
]]></body>
@ -616,8 +605,8 @@
case "cmd_togglesuggest":
// The pref observer will update _suggestEnabled and the menu
// checkmark.
this._prefBranch.setBoolPref("browser.search.suggest.enabled",
!this._suggestEnabled);
Services.prefs.setBoolPref("browser.search.suggest.enabled",
!this._suggestEnabled);
break;
default:
// do nothing with unrecognized command