Changes

Jump to: navigation, search

Localized Search in Firefox Search Box

9,304 bytes removed, 10:52, 19 March 2008
m
no edit summary
= '''Project Name''' =
'''Localized Search in Firefox Search Box'''
= '''Project Leader''' =
==== [[http://zenit.senecac.on.ca/wiki/index.php/User:Sinker | Kerry M. Singh]] ====
= '''Project DetailsContributions''' =
== '''Release v.01Web Site List''' ==
This release demonstrates my understanding of how some searchbar features currently work in the Firefox browser. I've uploaded a * Please list web sites that have [http://zenit.senecacdeveloper.onmozilla.caorg/wikien/index.phpdocs/Image:Localsearchpatch_v01.txt.zip patch fileCreating_OpenSearch_plugins_for_Firefox OpenSearch] search plugins that outputs a series of dump(can be "DIAGNOSTIC MESSAGE: function name - what the source code is doingAdded") statements to the terminal window while running a debug build searchbar's list of Firefox (i.e. Minefield)search engines. SpecificallyFor example, what functions/methods are called and what is happening in the source code with respect to the searchbar menu 's drop-down list's button changes blue in color when the following events occur:Firefox detects a web site with an OpenSearch plugin.
* The browser auto-detects a site that has a search plugin available[https://bugzilla.* The user selects the button to display the search engine list when a search plugin is available.* The user selects the option to "Add this search engine".* The user changes the current search engine by selecting it from the search bar drop-down list (menu).* The user moves the position of a search engine using the Search Engine Manager.* The user removes an auto-detected search engine from the list of "installed" search enginesmozilla.org/ Bugzilla@Mozilla]
* [http://www.facebook.com/ Facebook]
=== '''Downloading and applying the patch''' === 1. Download the * [http://zenitwww.senecactheglobeandmail.on.cacom/wiki/index.php/Image:Localsearchpatch_v01.txt.zip patch file] to the root mozilla directory of your source tree The Globe and unzip the file there. I suggest renaming the file localsearchpatch_v01.txt. * '''NOTE:''' This patch requires that you use a DEBUG build of firefox. To see the output messages from the dump() statements in the patch, you have to enable it by setting the preference '''browser.dom.window.dump.enabled''' to '''true'''. You can set this preference in [http://kb.mozillazine.org/About:config about:config] or in a [http://kb.mozillazine.org/User.js_file user.js file]. This preference is not listed in about:config by default, so you may need to create it. Enter <code>about:config</code> in the browser's address bar -> right-click the empty content area -> New -> Boolean. * You can preview the patch here: [[Localized Search in Firefox Search Box: Release v.01Mail]] 2. Apply the patch.<pre> $ cd mozilla $ patch -p0 < localsearchpatch_v01.txt</pre>* '''NOTE:''' Use the -p0 option to strip 0 leading directories from each filename in the patch because it is being applied in the same directory where the patch was created.  3. Build your source tree.<pre> $ cd mozilla $ make -f client.mk build</pre> 
4* [http://www. Run the browser to test the patchibm.<pre> $ cd objdir/distcom/bin $ .ca/firefox --ProfileManager --no-remote<en/pre>IBM Search]
* [http://www.microsoft.com/en/us/default.aspx Microsoft's Live Search]
=== '''How to use the patch''' ===
 
1. Navigate to a web site that offers a search engine plugin:
* [https://bugzilla.mozilla.org/ Bugzilla@Mozilla]
* [http://developer.mozilla.org/en/docs/Main_Page Mozilla Developer Center]
* [http://www.theglobeandmail.com/ The Globe and Mail]
'''Note''' the DIAGNOSTIC MESSAGE in the terminal window* [http://www.yellowpages.ca/ Yellow Pages]
* [http://www.youtube.com/ YouTube]
2* [http://en. Click the searchbar's dropdown menu buttonwikipedia.org/wiki/Main_Page Wikipedia]
* '''Note''' the DIAGNOSTIC MESSAGE in the terminal window and the "Add this engine" option on the searchbar menu.
= '''Project Details''' =
3. Click the "Add this engine" option on the searchbar menu.
* == '''NoteRelease v.01''' the DIAGNOSTIC MESSAGE in the terminal window and the position of the newly added search engine on the searchbar menu.==
This release demonstrates my understanding of how some searchbar features currently work in the Firefox browser. I've created a [http://zenit.senecac.on.ca/wiki/index.php/Image:Localsearchpatch_v01.txt.zip patch file] that outputs a series of dump("DIAGNOSTIC MESSAGE: function name - what the source code is doing") statements to the terminal window while running a debug build of Firefox (i.e. Minefield). Specifically, what functions/methods are called and what is happening in the source code with respect to the searchbar menu when the following events occur:
4* The browser auto-detects a site that has a search plugin available. Select "Manage Search Engines..." from * The user selects the searchbar menu and select button to display the newly installed search engine from the listwhen a search plugin is available. Click * The user selects the option to "Remove" button and then click "OKAdd this search engine". * '''Note''' The user changes the DIAGNOSTIC MESSAGES in the terminal window.  5. Select "Manage Search Engines..." current search engine by selecting it from the searchbar search bar drop-down list (menu and select one of the installed engines on the list. Next, click the "Move Up" and "Move Down" buttons and then click "OK"). * '''Note''' The user moves the DIAGNOSTIC MESSAGES in the terminal window.  6. Click the searchbar's dropdown menu button and select position of a different search engine as using the current engineSearch Engine Manager. * '''Note''' The user removes an auto-detected search engine from the DIAGNOSTIC MESSAGES in the terminal windowlist of "installed" search engines
=== '''How to remove the patchRelease Details''' ===
* You can back-out a patch by using the patch command with the -R or --reverse option==== [[Localized Search in Firefox Search Box: Release v. This swaps the new file with the old one to reverse the patch. <pre> $ cd mozilla $ patch -R -p0 < localsearchpatch_v01.txt</pre>01]] ====
The target for this release was to dynamically "Add" a search engine plugin when Firefox loads a web page with an available search plugin, and then propagate the search engine to the top of the searchbar's menu as the current engine. The propagation of a newly added search engine as the current engine in the searchbar's menu was already a behavioral feature of Firefox 3 so there were no changes required for this part of my release target. Determining how to dynamically "Add" an available search engine plugin was challenging to achieve, but in the end, it only required a few modifications to the code in the [http://lxr.mozilla.org/seamonkey/source/browser/base/content/browser.js browser.js file].
=== '''Release Details''' ===
=== '''Patch File''' = [[Localized Search in Firefox Search Box: Release v.02]] ====
* The modifications to the code in browser.js are shown below in a copy of the patch file for this release:
<pre>? localsearchpatch_v02.txt? nohup.out? objdir-ff-debug? patch.txtIndex: browser/base/content/browser.js=== '''Code ModificationsRelease v.03''' ===
Prior The target for this release was to my code modifications, the [http://lxr.mozillabuild upon Release v.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 02 by dynamically "Removing" 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 dynamically "getAdded" an nsISearchEngine object with a corresponding ''name'' property. If the search engine was on when the list, then it was considered to be a "hidden" engine and it was ''pushed'' onto user navigates away from the ''browser.hiddenEngines'' array. This array is used by web site offering the [http://lxr.mozilla.org/seamonkey/source/browser/components/search/content/search.xml search.xml] file plugin if they do not choose to determine how add the plugin to populate and display the search installed 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 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 === '''newRelease Details''' 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 <Localized 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 the new search plugin is NOT on the list. If it is not on the list, I "Add" the search plugin by calling the [http://lxr.mozilla.org/seamonkey/source/browser/components/search/nsSearchService.js#2726 addEngine() function] 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 of the auto-detected search plugins to 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 <Firefox Search Engine>" menu items.  === How to Use the Patch === 1. Copy and paste all of the text from the [httpBox://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 Release v.01 notes. 2. Navigate to a web site that offers a search engine plugin: * [http://developer.mozilla.org/en/docs/Main_Page Mozilla Developer Center]* [http://www.theglobeandmail.com/ The Globe and Mail03]* [http://www.yellowpages.ca/ Yellow Pages3. Notice that the search plugin has been dynamically loaded and added to the searchbar's list of "hidden" engines. The newly added search engine appears as the current engine and it can be used to search the web site. 4. Notice also that the "Add <Search Engine>" menu item is not displayed and the searchbar's drop-down list button did not turn blue because the search plugin was dynamically loaded. 5. Open the "Manage Search Engines" dialog box and "Remove" the dynamically loaded search engine. It will now appear on the the searchbar's list as an "Add <Search Engine>" menu item. It can then be added back as normal to the searchbar's list. 6. Clicking Firefox's reload button will reload the web page and trigger the code for the search plugin to be dynamically added to the list if it is not already on the searchbar's list of "hidden" engines.  == '''Release Target for v.03''' == * When the user navigates away from the web page with the search engine plugin, dynamically remove the search plugin.  == '''Release Target for v.04''' == * TBA  == '''Release Target for v.05''' == * TBA  == '''Release Target for v.06''' == * TBA  == '''Release Target for v.07''' == * TBA  == '''Release Target for v.08''' == * TBA  == '''Release Target for v.09''' == * TBA  == '''Release Target for v1.0''' == * TBA
For up-to-date information about my project, visit my blog: [http://kmsingh.blogspot.com/ Kerry's Open Source Blog]
 
 
'''[[#Project Name | Return to top]]'''
 
 
[[Category : Localized Search in Firefox Search Box]]
1
edit

Navigation menu