Open main menu

CDOT Wiki β

Changes

Localized Search in Firefox Search Box

2,130 bytes added, 21:53, 10 February 2008
'''Release v.02'''
? patch.txt
Index: browser/base/content/browser.js
===================================================================
RCS file: /cvsroot/mozilla/browser/base/content/browser.js,v
retrieving revision 1.961
diff -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 10 Feb 2008 20:07:04 -0000
@@ -2771,38 +2771,30 @@ const BrowserSearch = {
if (!this.searchBar)
return;
var browser = gBrowser.getBrowserForDocument(targetDoc);
// Append the URI and an appropriate title to the browser data.
var iconURL = null;
if (gBrowser.shouldLoadFavIcon(browser.currentURI))
iconURL = browser.currentURI.prePath + "/favicon.ico";
- var hidden = false;
// 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;
- var engines = (hidden ? browser.hiddenEngines : browser.engines) || [];
-
- engines.push({ uri: engine.href,
- title: engine.title,
- icon: iconURL });
-
- if (hidden)
+ if (!searchService.getEngineByName(engine.title)) {
+ searchService.addEngine(engine.href, Components.interfaces.nsISearchEngine.DATA_XML, iconURL, false);
+ var engines = browser.hiddenEngines || [];
+ engines.push({ uri: engine.href,
+ title: engine.title,
+ icon: iconURL });
browser.hiddenEngines = engines;
- else {
- browser.engines = engines;
- if (browser == gBrowser || browser == gBrowser.mCurrentBrowser)
- this.updateSearchButton();
}
},
/**
* Update the browser UI to show whether or not additional engines are
* available when a page is loaded or the user switches tabs to a page that
* has search engines.
*/
 
</pre>
 
 
=== '''Code Modifications''' ===
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 <Search Engine>" menu items.
=== '''Code Modifications''' ===
Prior to my code modifications== '''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  = '''Resources''' = [https://bugzilla.mozilla.org/ Bugzilla@Mozilla] [http://lxrmxr.mozilla.org/seamonkeyMozilla Cross-Reference] [http://developer.mozilla.org/sourceen/browserdocs/baseMain_Page MDC- Mozilla Developer Center] [http:/content/browserwiki.mozilla.jsorg/Search_Service:Code_Design#2770 addEngine() functionAutomatic_Detection Search Service: Code Design - Automatic Detection] received a reference to an anonymous JavaScript  [https://addons.mozilla.org/nl/firefox/addon/3544 SearchLoad Options :: Firefox Add-ons] == '''Files''' == [http://lxrmxr.mozilla.org/seamonkeyfirefox/source/browser/base/content/browser.js#2758 engine objectbrowser.js] which was passed as a parameter to the function by the  [http://lxrmxr.mozilla.org/seamonkeyfirefox/source/browser/basecomponents/search/content/browserengineManager.js engineManager.js#2669 onLinkAdded() function] that created it [http://mxr.mozilla.org/firefox/source/browser/components/search/nsIBrowserSearchService. Then, addEngine() used an idl 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'' propertyidl] [http://mxr.mozilla. If the org/firefox/source/browser/components/search engine was on the list, then it was considered to be a "hidden" engine and it was ''pushed'' onto the ''browser/nsSearchService.hiddenEngines'' arrayjs nsSearchService. This array is used by the js] [http://lxrmxr.mozilla.org/seamonkeyfirefox/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    = '''pushedProject-Related Bugs'' onto ' = [https://bugzilla.mozilla.org/show_bug.cgi?id=236587 Bug 236587 - Allow bookmark keyword searches from the "nonsearch bar] [https://bugzilla.mozilla.org/show_bug.cgi?id=249481 Bug 249481 – User-hidden"defined searches available not only as bookmark keywords, ''browserbut also from the Search box] [https://bugzilla.mozilla.engines'' arrayorg/show_bug. The cgi?id=374268 Bug 374268 – Quicksearch/keyword should be integrated into search engine would then be displayed as an manager] [https://bugzilla.mozilla.org/show_bug.cgi?id=261124 Bug 261124 – Textbox context menu should have "Add <to Search Engine>Bar..." item on the searchbar menu ] [https://bugzilla.mozilla.org/show_bug.cgi?id=335448 Bug 335448 – Autodetect repeated use of a search field, and ask the searchbar button's background color would be changed to blue after a call user if they want that engine added to the browser search box] [httphttps://bugzilla.mozilla.org/show_bug.cgi?id=360907 Bug 360907 – Search current site with OpenSearch] [https://lxrbugzilla.mozilla.org/seamonkeyshow_bug.cgi?id=408244 Bug 408244 – show opensearch plugin availability same as feed availability] [https:/source/browserbugzilla.mozilla.org/show_bug.cgi?id=405443 Bug 405443 – Making search engine discovery more discoverable] [https:/base/contentbugzilla.mozilla.org/browsershow_bug.js#2809 updateSearchButton() functioncgi?id=356332 Bug 356332 – Select default search engine again after searching with another[https://bugzilla.mozilla.org/show_bug.cgi?id=384124 Bug 384124 – Option to reset search bar engine to default when starting Firefox]  = '''Project News''' =
My code modifications alter the original addEngine() function by using the nsIBrowserSearchService object For up-to check if the new search plugin is NOT on the list. If it is not on the list-date information about my project, I "Add" the search plugin by calling the [httpvisit my blog://lxr.mozilla.org/seamonkey/source/browser/components/search/nsSearchService.js#2726 addEngine() function] in the [http://lxrkmsingh.mozillablogspot.orgcom/seamonkey/source/browser/components/search/nsSearchService.js nsSearchService.js] file. This function completes the important step of creating a '''new'Kerry'' 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()s Open Source Blog]. 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 <Search Engine>" menu items.
== '''Release Target for v.03''' ==
1
edit