Changes

Jump to: navigation, search

Localized Search in Firefox Search Box

1,734 bytes removed, 15:54, 11 February 2008
no edit summary
? patch.txt
Index: browser/base/content/browser.js
=== '''Code Modifications''' ================================================================RCS file: /cvsroot/mozilla/browser/base/content/browser.js,vretrieving revision 1.961diff -u -8 -p -r1.961 browser.js--- browser/base/content/browser.js 10 Feb 2008 06:57:05 -0000 1.961+++ browser/base/content/browser.js 11 Feb 2008 19:20:16 -0000@@ -2780,16 +2780,19 @@ const BrowserSearch = { // If this engine (identified by title) is already in the list, add it // to the list of hidden engines rather than to the main list. // XXX This will need to be changed when engines are identified by URL; // see bug 335102. var searchService = Cc["@mozilla.org/browser/search-service;1"]. getService(Ci.nsIBrowserSearchService); if (searchService.getEngineByName(engine.title)) hidden = true;+ else+ // Dynamically "Add" the web site's search engine plugin.+ searchService.addEngine(engine.href, Components.interfaces.nsISearchEngine.DATA_XML, iconURL, false); var engines = (hidden ? browser.hiddenEngines : browser.engines) || []; engines.push({ uri: engine.href, title: engine.title, icon: iconURL }); if (hidden)
Prior to my code modifications, the [http://lxr.mozilla.org/seamonkey/source/browser/base/content/browser.js#2770 addEngine() function] received a reference to an anonymous JavaScript [http://lxr.mozilla.org/seamonkey/source/browser/base/content/browser.js#2758 engine object] which was passed as a parameter to the function by the [http://lxr.mozilla.org/seamonkey/source/browser/base/content/browser.js#2669 onLinkAdded() function] that created it. Then, addEngine() used an nsIBrowserSearchService object to determine if the search engine was already on the list of engines. The addEngine() function used the ''title'' property of the ''engine'' object to "get" an nsISearchEngine object with a corresponding ''name'' property. If the search engine was on the list, then it was considered to be a "hidden" engine and it was ''pushed'' onto the ''browser.hiddenEngines'' array. This array is used by the [http:<//lxr.mozilla.org/seamonkey/source/browser/components/search/content/search.xml search.xml] file to determine how to populate and display the search engines on the searchbar menu. If the search engine was not on the list, it was ''pushed'' onto the "non-hidden", ''browser.engines'' array. The search engine would then be displayed as an "Add <Search Enginepre>" item on the searchbar menu and the searchbar button's background color would be changed to blue after a call to the [http://lxr.mozilla.org/seamonkey/source/browser/base/content/browser.js#2809 updateSearchButton() function].
My code modifications alter the original addEngine() function by adding the new search plugin if is NOT on the list. The search plugin is dynamically "Added" by calling the [http://lxr.mozilla.org/seamonkey/source/browser/components/search/nsSearchService.js#2726 addEngine() function] defined in the [http://lxr.mozilla.org/seamonkey/source/browser/components/search/nsSearchService.js nsSearchService.js] file. This function completes the important step of creating a '''new''' nsISearchEngine object. It is this type of object that is required by important methods in search.xml, such as [http://lxr.mozilla.org/seamonkey/source/browser/components/search/content/search.xml#208 observe()],[http://lxr.mozilla.org/seamonkey/source/browser/components/search/content/search.xml#262 offerNewEngine()] and [http://lxr.mozilla.org/seamonkey/source/browser/components/search/content/search.xml#290 hideNewEngine()]. The remainder of the code follows the normal code paths.
=== '''Code Modifications''' ===
Prior to my code modifications, the [http://lxr.mozilla.org/seamonkey/source/browser/base/content/browser.js#2770 addEngine() function] received a reference to an anonymous JavaScript [http://lxr.mozilla.org/seamonkey/source/browser/base/content/browser.js#2758 engine object] which was passed as a parameter to the function by the [http://lxr.mozilla.org/seamonkey/source/browser/base/content/browser.js#2669 onLinkAdded() function] that created it. Then, addEngine() used an nsIBrowserSearchService object to determine if the search engine was already on the list of engines. The addEngine() function used the ''title'' property of the ''engine'' object to "get" an nsISearchEngine object with a corresponding ''name'' property. If the search engine was on the list, then it was considered to be a "hidden" engine and it was ''pushed'' onto the ''browser.hiddenEngines'' array. This array is used by the [http://lxr.mozilla.org/seamonkey/source/browser/components/search/content/search.xml search.xml] file to determine how to populate and display the search engines on the searchbar menu. If the search engine was not on the list, it was ''pushed'' onto the "non-hidden", ''browser.engines'' array. The search engine would then be displayed as an "Add <Search Engine>" item on the searchbar menu and the searchbar button's background color would be changed to blue after a call to the [http://lxr.mozilla.org/seamonkey/source/browser/base/content/browser.js#2809 updateSearchButton() function].
My code modifications alter the original addEngine() function by using the nsIBrowserSearchService object to check if adding the new search plugin if is NOT on the list. If it The search plugin is not on the list, I dynamically "AddAdded" the search plugin by calling the [http://lxr.mozilla.org/seamonkey/source/browser/components/search/nsSearchService.js#2726 addEngine() function] defined in the [http://lxr.mozilla.org/seamonkey/source/browser/components/search/nsSearchService.js nsSearchService.js] file. This function completes the important step of creating a '''new''' nsISearchEngine object. It is this type of object that is required by important methods in search.xml, such as [http://lxr.mozilla.org/seamonkey/source/browser/components/search/content/search.xml#208 observe()],[http://lxr.mozilla.org/seamonkey/source/browser/components/search/content/search.xml#262 offerNewEngine()] and [http://lxr.mozilla.org/seamonkey/source/browser/components/search/content/search.xml#290 hideNewEngine()]. I then push the anonymous JavaScript ''engine'' object onto the the list of "hidden" search engines, the ''browser.hiddenEngines'' array. It is not necessary for me to add any The remainder of the auto-detected search plugins to code follows the ''browser.engines'' array at this point. My objective is to dynamically "Add" the auto-detected search engines, therefore they are all considered to be "hidden" engines for now and they are not displayed on the searchbar as "Add <Search Engine>" menu itemsnormal code paths.
1
edit

Navigation menu