1
edit
Changes
no edit summary
=== '''How to use Use the patchPatch''' ===
1. Navigate to a web site that offers a search engine plugin:
=== '''How to remove Remove the patchPatch''' ===
* You can back-out a patch by using the patch command with the -R or --reverse option. This swaps the new file with the old one to reverse the patch.
if (aEngine.wrappedJSObject == this._engines[e])
</pre>
==== Code Modifications ====
1. [http://lxr.mozilla.org/seamonkey/source/browser/base/content/browser.js browser.js]
* Declare a global variable named ''gAddedEngine'' to hold a dynamically "Added" '''nsISearchEngine''' object and set its initial value to be '''null'''.
* [http://lxr.mozilla.org/seamonkey/source/browser/base/content/browser.js#2770 addEngine() function]: If the auto-detected search plugin is NOT on the search service's list of engines, then dynamically "Add" the search engine and assign it to the ''gAddedEngine'' global variable.
* [http://lxr.mozilla.org/seamonkey/source/browser/base/content/browser.js#3852 startDocumentLoad() function]: When the user navigates to a different web site, get an instance of '''nsIBrowserSearchService''' and assign it to the variable ''searchService''. Use a try-catch block to first check that the global variable ''gAddedEngine'' has a non-null value. Then, use the search service's [http://lxr.mozilla.org/seamonkey/source/browser/components/search/nsSearchService.js#2697 getEngineByName() function] to "get" the engine if it is on the list and use the search service's [http://lxr.mozilla.org/seamonkey/source/browser/components/search/nsSearchService.js#2741 removeEngine() function] to remove it from the list. Set the global variable ''gAddedEngine'' to '''null'''.
2. [http://lxr.mozilla.org/seamonkey/source/browser/components/search/nsIBrowserSearchService.idl nsIBrowserSearchService.idl]
* [http://lxr.mozilla.org/seamonkey/source/browser/components/search/nsIBrowserSearchService.idl#196 addEngine() Interface]: Change the return type of the interface from '''void''' to an '''nsISearchEngine''' object.
3. [http://lxr.mozilla.org/seamonkey/source/browser/components/search/nsSearchService.js nsSearchService.js]
* [http://lxr.mozilla.org/seamonkey/source/browser/components/search/nsSearchService.js#2726 addEngine() function]: Return an '''nsISearchEngine''' object.
==== How to Use the Patch ====
1. Copy and paste all of the text from the [http://zenit.senecac.on.ca/wiki/index.php/Localized_Search_in_Firefox_Search_Box#Patch_File patch file] into a text file and name the file localsearchpatch_v02.txt. Save the file to your root mozilla directory. Then, [http://zenit.senecac.on.ca/wiki/index.php/Localized_Search_in_Firefox_Search_Box#Downloading_and_applying_the_patch apply the patch and recompile] your mozilla source code as described in the release v.01 notes.
2. Start-up Firefox 3 (i.e. Minefield) and go to a [http://zenit.senecac.on.ca/wiki/index.php?title=Localized_Search_in_Firefox_Search_Box#Web_Site_List web site that offers a search engine plugin].
3. Notice that the search plugin has been dynamically loaded and added to the searchbar's list of installed engines. The newly added search engine appears as the current engine and it can be used to search the web site.
4. Navigate to a different web site that offers a search engine plugin. Observe that the search engine that was dynamically "Added" at the previous web site is no longer on the list of installed engines but the search plugin for the current web site has been dynamically loaded and it appears as the current engine for searching the site.
5. Open the Search Engine Manager's dialog and "Remove" the dynamically "Added" search engine. Notice that it is no longer on the list of installed engines and it is now listed as an "Add <Search Engine>" menu item. If you choose to "Add" the engine back to the list of installed engines, it will remain as an installed engine when you navigate to a different web site.
6. Navigate to a web site that offers a search engine plugin and then to a different site that does NOT offer a search plugin. Observe that the dynamically "Added" search engine is no longer on the list of installed engines.