зеркало из https://github.com/mozilla/pjs.git
Bug 340122: Do not offer to add an autodiscovered search engine if its title matches one already in the list. r+a181=mconnor
This commit is contained in:
Родитель
4325626661
Коммит
f1896d0408
|
@ -2942,6 +2942,16 @@ const BrowserSearch = {
|
||||||
|
|
||||||
if (!etype)
|
if (!etype)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (target.title) {
|
||||||
|
// If this engine (identified by title) is already in the list, ignore it.
|
||||||
|
// XXX This will need to be changed when engines are identified by URL;
|
||||||
|
// see bug 335102.
|
||||||
|
var searchService = Components.classes["@mozilla.org/browser/search-service;1"]
|
||||||
|
.getService(Components.interfaces.nsIBrowserSearchService);
|
||||||
|
if (searchService.getEngineByName(target.title))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (etype == "application/opensearchdescription+xml" &&
|
if (etype == "application/opensearchdescription+xml" &&
|
||||||
searchRelRegex.test(erel) && searchHrefRegex.test(ehref))
|
searchRelRegex.test(erel) && searchHrefRegex.test(ehref))
|
||||||
|
|
|
@ -109,9 +109,6 @@
|
||||||
|
|
||||||
<method name="init">
|
<method name="init">
|
||||||
<body><![CDATA[
|
<body><![CDATA[
|
||||||
this._popup = document.getAnonymousElementByAttribute(this, "anonid",
|
|
||||||
"searchbar-popup");
|
|
||||||
|
|
||||||
// Refresh the display (updating icon, etc)
|
// Refresh the display (updating icon, etc)
|
||||||
this.rebuildPopup();
|
this.rebuildPopup();
|
||||||
this.updateDisplay();
|
this.updateDisplay();
|
||||||
|
@ -134,9 +131,14 @@
|
||||||
this._textbox.mController.input = null;
|
this._textbox.mController.input = null;
|
||||||
]]></destructor>
|
]]></destructor>
|
||||||
|
|
||||||
<field name="_stringBundle">document.getAnonymousElementByAttribute(this, "anonid", "searchbar-stringbundle");</field>
|
<field name="_stringBundle">document.getAnonymousElementByAttribute(this,
|
||||||
<field name="_textbox">document.getAnonymousElementByAttribute(this, "anonid", "searchbar-textbox");</field>
|
"anonid", "searchbar-stringbundle");</field>
|
||||||
<field name="_popup">null</field>
|
<field name="_textbox">document.getAnonymousElementByAttribute(this,
|
||||||
|
"anonid", "searchbar-textbox");</field>
|
||||||
|
<field name="_popup">document.getAnonymousElementByAttribute(this,
|
||||||
|
"anonid", "searchbar-popup");</field>
|
||||||
|
<field name="_button">document.getAnonymousElementByAttribute(this,
|
||||||
|
"anonid", "search-go-button");</field>
|
||||||
<field name="_ss">null</field>
|
<field name="_ss">null</field>
|
||||||
<field name="_engines">null</field>
|
<field name="_engines">null</field>
|
||||||
|
|
||||||
|
@ -341,21 +343,37 @@
|
||||||
|
|
||||||
<!-- Because this may be called from a command handler, where event.target is
|
<!-- Because this may be called from a command handler, where event.target is
|
||||||
not the correct target for the command, it takes a target rather than an
|
not the correct target for the command, it takes a target rather than an
|
||||||
event as a parameter.
|
event as a parameter. Note that because of the engine-list maintenance
|
||||||
|
performed in this function, it should not be used in a way that leaves the
|
||||||
|
menu open after this function has been called (or if it is, be sure to call
|
||||||
|
rebuildPopupDynamic afterward).
|
||||||
-->
|
-->
|
||||||
<method name="onEnginePopupCommand">
|
<method name="onEnginePopupCommand">
|
||||||
<parameter name="aTarget"/>
|
<parameter name="aTarget"/>
|
||||||
<body><![CDATA[
|
<body><![CDATA[
|
||||||
if (aTarget.getAttribute("class").indexOf("addengine-item") != -1) {
|
if (aTarget.getAttribute("class").indexOf("addengine-item") != -1) {
|
||||||
var searchService = Components
|
var searchService =
|
||||||
.classes["@mozilla.org/browser/search-service;1"]
|
Components.classes["@mozilla.org/browser/search-service;1"]
|
||||||
.getService(Components.interfaces.nsIBrowserSearchService);
|
.getService(Components.interfaces.nsIBrowserSearchService);
|
||||||
if (searchService) {
|
// We only detect OpenSearch files
|
||||||
// We only detect OpenSearch files
|
var type = Components.interfaces.nsISearchEngine.DATA_XML;
|
||||||
var type = Components.interfaces.nsISearchEngine.DATA_XML;
|
searchService.addEngine(aTarget.getAttribute("uri"), type,
|
||||||
searchService.addEngine(aTarget.getAttribute("uri"), type,
|
aTarget.getAttribute("src"));
|
||||||
aTarget.getAttribute("src"));
|
// Remove this engine from the list and refresh the search button.
|
||||||
|
// XXX This will need to be changed when engines are identified
|
||||||
|
// by URL; see bug 335102.
|
||||||
|
var browser = getBrowser().mCurrentBrowser;
|
||||||
|
var removeTitle = aTarget.getAttribute("title");
|
||||||
|
// No need to null-check browser.engines, since it should contain at
|
||||||
|
// least the item the user just chose.
|
||||||
|
for (var i = 0; i < browser.engines.length; i++) {
|
||||||
|
if (browser.engines[i].title == removeTitle) {
|
||||||
|
browser.engines.splice(i, 1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (browser.engines.length == 0)
|
||||||
|
this._button.removeAttribute("addengines");
|
||||||
}
|
}
|
||||||
else if (aTarget.engine) {
|
else if (aTarget.engine) {
|
||||||
this.currentEngine = aTarget.engine;
|
this.currentEngine = aTarget.engine;
|
||||||
|
@ -525,8 +543,7 @@
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
// Don't open search popup if history popup is open
|
// Don't open search popup if history popup is open
|
||||||
if (!this.popupOpen) {
|
if (!this.popupOpen) {
|
||||||
document.getAnonymousElementByAttribute(this._getParentSearchbar(),
|
this._button.open = true;
|
||||||
"anonid", "search-go-button").open = true;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче