Open main menu

CDOT Wiki β

Changes

Localized Search in Firefox Search Box

4,246 bytes added, 16:02, 14 February 2008
m
Patch File - localsearchpatch_v032.txt
<pre>
? localsearchpatch_v031.txt
? nohup.out
? objdir-ff-debug
Index: browser/base/content/browser.js
==== Patch File - localsearchpatch_v032.txt ====
 
<pre>
? localsearchpatch_v032.txt
? nohup.out
? objdir-ff-debug
diff -u -8 -p -r1.962 browser.js
--- browser/base/content/browser.js 13 Feb 2008 10:40:03 -0000 1.962
+++ browser/base/content/browser.js 14 Feb 2008 0020:3459:15 -0000
@@ -97,16 +97,19 @@ var gContextMenu = null;
var gBookmarkAllTabsHandler = null;
+// Global variable that holds an a 'dynamically added' nsISearchEngine object.
+var gAddedEngine = null;
+
if (hidden)
@@ -3849,18 +3855,27 28 @@ nsBrowserStatusHandler.prototype =
this.onProgressChange(gBrowser.webProgress, 0, 0, aTotalProgress, 1);
},
+ // Remove the dynamically added search engine if it is on the list.
+ try {
+ if (gAddedEngine)+ searchService.removeEngine(searchService.getEngineByName(gAddedEngine.name));+ searchService.removeEngine(gAddedEngine)= null;
+ } catch (e) {
+ }
} catch (e) {
Index: browser/components/search/nsIBrowserSearchService.idl
===================================================================
RCS file: /cvsroot/mozilla/browser/components/search/nsIBrowserSearchService.idl,v
retrieving revision 1.20
diff -u -8 -p -r1.20 nsIBrowserSearchService.idl
--- browser/components/search/nsIBrowserSearchService.idl 11 Sep 2007 16:07:11 -0000 1.20
+++ browser/components/search/nsIBrowserSearchService.idl 14 Feb 2008 20:59:16 -0000
@@ -187,19 +187,21 @@ interface nsIBrowserSearchService : nsIS
* @param confirm
* A boolean value indicating whether the user should be asked for
* confirmation before this engine is added to the list. If this
* value is false, the engine will be added to the list upon successful
* load, but it will not be selected as the current engine.
*
* @throws NS_ERROR_FAILURE if the type is invalid, or if the description
* file cannot be successfully loaded.
+ *
+ * @returns the created engine.
*/
- void addEngine(in AString engineURL, in long dataType, in AString iconURL,
- in boolean confirm);
+ nsISearchEngine addEngine(in AString engineURL, in long dataType, in AString iconURL,
+ in boolean confirm);
/**
* Adds a new search engine, without asking the user for confirmation and
* without starting to use it right away.
*
* @param name
* The search engine's name. Must be unique. Must not be null.
*
Index: browser/components/search/nsSearchService.js
===================================================================
RCS file: /cvsroot/mozilla/browser/components/search/nsSearchService.js,v
retrieving revision 1.108
diff -u -8 -p -r1.108 nsSearchService.js
--- browser/components/search/nsSearchService.js 29 Jan 2008 19:39:20 -0000 1.108
+++ browser/components/search/nsSearchService.js 14 Feb 2008 20:59:17 -0000
@@ -2731,16 +2731,17 @@ SearchService.prototype = {
var engine = new Engine(uri, aDataType, false);
engine._initFromURI();
} catch (ex) {
LOG("addEngine: Error adding engine:\n" + ex);
throw Cr.NS_ERROR_FAILURE;
}
engine._setIcon(aIconURL, false);
engine._confirm = aConfirm;
+ return engine;
},
removeEngine: function SRCH_SVC_removeEngine(aEngine) {
ENSURE_ARG(aEngine, "no engine passed to removeEngine!");
var engineToRemove = null;
for (var e in this._engines)
if (aEngine.wrappedJSObject == this._engines[e])
Index: browser/components/search/content/search.xml
===================================================================
RCS file: /cvsroot/mozilla/browser/components/search/content/search.xml,v
retrieving revision 1.120
diff -u -8 -p -r1.120 search.xml
--- browser/components/search/content/search.xml 6 Feb 2008 19:00:09 -0000 1.120
+++ browser/components/search/content/search.xml 14 Feb 2008 20:59:18 -0000
@@ -326,16 +326,26 @@
</method>
<!-- Rebuilds the dynamic portion of the popup menu (i.e., the menu items
for new search engines that can be added to the available list). This
is called each time the popup is shown.
-->
<method name="rebuildPopupDynamic">
<body><![CDATA[
+ // Remove the dynamically added search engine if it is on the list when
+ // the popup's menu items are first displayed. The user may then choose
+ // to add the "Add <Search Engine>" item to the list of installed engines.
+ try {
+ if (gAddedEngine)
+ this.searchService.removeEngine(this.searchService.getEngineByName(gAddedEngine.name));
+ gAddedEngine = null;
+ } catch (e) {
+ }
+
// We might not have added the main popup items yet, do that first
// if needed.
if (this._needToBuildPopup)
this.rebuildPopup();
var popup = this._popup;
// Clear any addengine menuitems, including addengine-item entries and
// the addengine-separator. Work backward to avoid invalidating the
</pre>
 
===================================================================
RCS file: /cvsroot/mozilla/browser/components/search/nsIBrowserSearchService.idl,v
1
edit