From f1896d0408fa61428d1ce125e4788399bda29e6b Mon Sep 17 00:00:00 2001 From: "pamg.bugs%gmail.com" Date: Mon, 12 Jun 2006 22:01:52 +0000 Subject: [PATCH] Bug 340122: Do not offer to add an autodiscovered search engine if its title matches one already in the list. r+a181=mconnor --- browser/base/content/browser.js | 10 ++++ browser/components/search/content/search.xml | 51 +++++++++++++------- 2 files changed, 44 insertions(+), 17 deletions(-) diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index 0dcfd9362f7..85cfb33c3c4 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -2942,6 +2942,16 @@ const BrowserSearch = { if (!etype) 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" && searchRelRegex.test(erel) && searchHrefRegex.test(ehref)) diff --git a/browser/components/search/content/search.xml b/browser/components/search/content/search.xml index a8ed7deb4d7..b505fc36ea8 100644 --- a/browser/components/search/content/search.xml +++ b/browser/components/search/content/search.xml @@ -109,9 +109,6 @@ - document.getAnonymousElementByAttribute(this, "anonid", "searchbar-stringbundle"); - document.getAnonymousElementByAttribute(this, "anonid", "searchbar-textbox"); - null + document.getAnonymousElementByAttribute(this, + "anonid", "searchbar-stringbundle"); + document.getAnonymousElementByAttribute(this, + "anonid", "searchbar-textbox"); + document.getAnonymousElementByAttribute(this, + "anonid", "searchbar-popup"); + document.getAnonymousElementByAttribute(this, + "anonid", "search-go-button"); null null @@ -341,21 +343,37 @@