Bug 733802 - Fix various issues in webSearchProvider.js, make it work properly. r=Standard8
authorChris Coulson <chris.coulson@canonical.com>
Tue, 20 Mar 2012 13:54:25 +0000
changeset 9689 29d89350dce1355d0aa9aee4e93cfcf541c98690
parent 9688 5fe8af14e49387a4a8c390331138e8ae0e7a18a4
child 9690 ffb73852234379b5cc60245d4f0ce023ed189095
push idunknown
push userunknown
push dateunknown
reviewersStandard8
bugs733802
Bug 733802 - Fix various issues in webSearchProvider.js, make it work properly. r=Standard8
mail/components/mailComponents.manifest
mail/components/webSearchProvider.js
--- a/mail/components/mailComponents.manifest
+++ b/mail/components/mailComponents.manifest
@@ -14,9 +14,9 @@ contract @mozilla.org/uriloader/content-
 contract @mozilla.org/uriloader/content-handler;1?type=text/plain {1c73f03a-b817-4640-b984-18c3478a9ae3}
 
 component {eb239c82-fac9-431e-98d7-11cacd0f71b8} mailGlue.js
 contract @mozilla.org/mail/mailglue;1 {eb239c82-fac9-431e-98d7-11cacd0f71b8}
 category app-startup MailGlue service,@mozilla.org/mail/mailglue;1
 
 component {76a80bff-8c3f-4b78-ad2c-80099e35375d} webSearchProvider.js
 contract @mozilla.org/mail/web-search-provider;1 {76a80bff-8c3f-4b78-ad2c-80099e35375d}
-category xpcom-directory-providers web-search-directory-provider service,@mozilla.org/mail/web-search-provider;1
+category xpcom-directory-providers web-search-directory-provider @mozilla.org/mail/web-search-provider;1
--- a/mail/components/webSearchProvider.js
+++ b/mail/components/webSearchProvider.js
@@ -32,41 +32,54 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 const NS_APP_SEARCH_DIR_LIST = "SrchPluginsDL";
 const NS_APP_USER_SEARCH_DIR = "UsrSrchPlugns";
 const NS_APP_SEARCH_DIR = "SrchPlugns";
-const NS_XPCOM_CURRENT_PROCESS_DIR = "XCurProdD";
+const NS_XPCOM_CURRENT_PROCESS_DIR = "XCurProcD";
 const XRE_EXTENSIONS_DIR_LIST = "XREExtDL";
 
 const Cc = Components.classes;
 const Ci = Components.interfaces;
+const Cu = Components.utils;
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 
 function AppendingEnumerator(base, append) {
   this.base = base;
   this.append = append;
+  this.next = null;
+
+  this.getNext();
 }
 
 AppendingEnumerator.prototype = {
   QueryInterface: XPCOMUtils.generateQI([Ci.nsISimpleEnumerator]),
 
   hasMoreElements: function() {
-    return this.base.hasMoreElements();
+    return this.next != null;
   },
 
   getNext: function() {
-    let file = this.base.getNext().QueryInterface(Ci.nsIFile);
-    file.append(this.append);
-    return file;
+    let res = this.next;
+    let next = null;
+
+    while (this.base.hasMoreElements() && !next) {
+      let file = this.base.getNext().QueryInterface(Ci.nsIFile);
+      file.append(this.append);
+      if (file.exists())
+        next = file;
+    }
+
+    this.next = next;
+    return res;
   },
 };
 
 function UnionEnumerator(first, second) {
   this.first = first;
   this.second = second;
 }
 
@@ -159,16 +172,16 @@ WebSearchProvider.prototype = {
         array.appendElement(defLocalePlugins, false);
     }
     catch(e) {}
   },
 
   appendFileKey: function(key, array) {
     try {
       let file = Services.dirsvc.get(key, Ci.nsIFile);
-      if (!file.exists())
+      if (file.exists())
         array.appendElement(file, false);
     }
     catch(e) {}
   },
 };
 
 const NSGetFactory = XPCOMUtils.generateNSGetFactory([WebSearchProvider]);