Bug 586317 - Add Search Engine option is always offered even after adding [r=mfinkle]
authorVivien Nicolas <21@vingtetun.org>
Tue, 17 Aug 2010 19:04:00 +0200
changeset 66452 722be6c5a15f2a77d3da1741d3f7691c6ce94ecc
parent 66451 b13fdc7e4a421a9e9a6474625957e0b0ce56bce8
child 66453 89dd39bfdf438fd9b8eb2f72ec281ca460f94ffb
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs586317
Bug 586317 - Add Search Engine option is always offered even after adding [r=mfinkle]
mobile/chrome/content/browser.js
--- a/mobile/chrome/content/browser.js
+++ b/mobile/chrome/content/browser.js
@@ -53,19 +53,16 @@ let Ci = Components.interfaces;
 let Cu = Components.utils;
 
 function getBrowser() {
   return Browser.selectedBrowser;
 }
 
 const kDefaultBrowserWidth = 800;
 
-// how many milliseconds before the mousedown and the overlay of an element
-const kTapOverlayTimeout = 200;
-
 // Override sizeToContent in the main window. It breaks things (bug 565887)
 window.sizeToContent = function() {
   Components.utils.reportError("window.sizeToContent is not allowed in this window");
 }
 
 #ifdef MOZ_CRASH_REPORTER
 XPCOMUtils.defineLazyServiceGetter(this, "CrashReporter",
   "@mozilla.org/xre/app-info;1", "nsICrashReporter");
@@ -1527,38 +1524,44 @@ const BrowserSearch = {
 
   get engines() {
     if (this._engines)
       return this._engines;
     return this._engines = Services.search.getVisibleEngines({ });
   },
 
   updatePageSearchEngines: function updatePageSearchEngines(aNode) {
-    let items = Browser.selectedBrowser.searchEngines;
+    let items = Browser.selectedBrowser.searchEngines.filter(this.isPermanentSearchEngine);
     if (!items.length)
       return false;
 
     // XXX limit to the first search engine for now
     let engine = items[0];
     aNode.setAttribute("description", engine.title);
     aNode.onclick = function() {
       BrowserSearch.addPermanentSearchEngine(engine);
       PageActions.hideItem(aNode);
     };
     return true;
   },
 
-  addPermanentSearchEngine: function (aEngine) {
+  addPermanentSearchEngine: function addPermanentSearchEngine(aEngine) {
     let iconURL = BrowserUI._favicon.src;
     Services.search.addEngine(aEngine.href, Ci.nsISearchEngine.DATA_XML, iconURL, false);
 
     this._engines = null;
   },
 
-  updateSearchButtons: function() {
+  isPermanentSearchEngine: function isPermanentSearchEngine(aEngine) {
+    return !BrowserSearch.engines.some(function(item) {
+      return aEngine.title == item.name;
+    });
+  },
+
+  updateSearchButtons: function updateSearchButtons() {
     let container = document.getElementById("search-buttons");
     if (this._engines && container.hasChildNodes())
       return;
 
     // Clean the previous search engines button
     while (container.hasChildNodes())
       container.removeChild(container.lastChild);