fix the rich text autocomplete for fx4 oauth
authormixedpuppy <mixedpuppy@gmail.com>
Wed, 27 Oct 2010 14:00:22 -0700
branchoauth
changeset 231 86c223338e7a
parent 230 518ea1882360
child 232 06682aaa89bf
push id187
push usermixedpuppy@gmail.com
push date2010-10-27 21:00 +0000
fix the rich text autocomplete for fx4
chrome.manifest
components/extensibleFormFiller.js
--- a/chrome.manifest
+++ b/chrome.manifest
@@ -16,14 +16,16 @@ component {b6e1d39c-b39c-4b1f-a088-e2fbb
 contract @mozilla.org/network/protocol;1?name=person {b6e1d39c-b39c-4b1f-a088-e2fbb4cff9a6}
 
 component {7bc6728f-9ecf-de44-9fc9-8ce679f7529d} components/nsFormFillOverride.js
 contract @labs.mozilla.com/contacts/form-autocomplete;1 {7bc6728f-9ecf-de44-9fc9-8ce679f7529d}
 category form-autocomplete-handler contacts-addon @labs.mozilla.com/contacts/form-autocomplete;1
 
 component {a90ef7fd-ef96-6f4a-bb0e-075fc2f06e23} components/extensibleFormFiller.js
 contract @mozilla.org/satchel/form-autocomplete;1 {a90ef7fd-ef96-6f4a-bb0e-075fc2f06e23}
+component {099b2bff-8b6e-7b48-a475-dbc09a53f24d} components/extensibleFormFiller.js
+contract @mozilla.org/satchel/inputlist-autocomplete;1 {099b2bff-8b6e-7b48-a475-dbc09a53f24d}
 
 interfaces components/INativeAddressBook.xpt
 interfaces components/INativeAddressCard.xpt
 binary-component platform/Darwin/components/NativeAddressBook.dylib ABI=Darwin_x86-gcc3
 binary-component platform/Darwin/components/NativeAddressBook.dylib ABI=Darwin_x86_64-gcc3
 
--- a/components/extensibleFormFiller.js
+++ b/components/extensibleFormFiller.js
@@ -28,16 +28,17 @@ function _() {
 
 __defineGetter__("FAC", function() {
   _("get FAC");
   delete this.FAC;
   return this.FAC = Components.classesByID["{c11c21b2-71c9-4f87-a0f8-5e13f50495fd}"].
     getService(Ci.nsIFormAutoComplete);
 });
 
+
 function FormAutocomplete() {
   _("new PAC FormAutocomplete");
   
     // Check who is registered in "form-autocomplete-handler" category.
     _("   Gather handlers registered");
     this.handlers = [];
     let foundEntriesCount = 0;
     let catMan = Cc["@mozilla.org/categorymanager;1"].
@@ -70,16 +71,47 @@ FormAutocomplete.prototype = {
         let ac = handler.autoCompleteSearch(name, query, field, prev);
         if (ac) return ac;
     }
     // Use the base form autocomplete for non-people searches
     return FAC.autoCompleteSearch(name, query, field, prev);
   }
 };
 
-let components = [FormAutocomplete];
+/**
+ * In firefox 4, we have to also override satchel/inputlist-autocomplete otherwise
+ * it will modify our search result in a way that prevents use of a rich
+ * autocomplete list.
+ */
+
+__defineGetter__("ILAC", function() {
+  _("get ILAC");
+  delete this.ILAC;
+  return this.ILAC = Components.classesByID["{bf1e01d0-953e-11df-981c-0800200c9a66}"].
+    getService(Ci.nsIInputListAutoComplete);
+});
+
+
+function InputListAutoComplete() {}
+InputListAutoComplete.prototype = {
+  contractID    : "@mozilla.org/satchel/inputlist-autocomplete",
+  classID       : Components.ID("{099b2bff-8b6e-7b48-a475-dbc09a53f24d}"),
+  QueryInterface: XPCOMUtils.generateQI([Ci.nsIInputListAutoComplete]),
+
+  autoCompleteSearch : function (formHistoryResult, aUntrimmedSearchString, aField) {
+    // if using a default autocompleteresult class, don't use satchel/inputlist-autocomplete
+    if (formHistoryResult.wrappedJSObject)
+      return ILAC.autoCompleteSearch(formHistoryResult, aUntrimmedSearchString, aField);
+    return formHistoryResult;
+  },
+
+  getListSuggestions : function (aField) {
+
+  }
+};
+
 if (XPCOMUtils.generateNSGetFactory)
-    var NSGetFactory = XPCOMUtils.generateNSGetFactory(components);
+    var NSGetFactory = XPCOMUtils.generateNSGetFactory([FormAutocomplete, InputListAutoComplete]);
 else
-    var NSGetModule = XPCOMUtils.generateNSGetModule(components);
+    var NSGetModule = XPCOMUtils.generateNSGetModule([FormAutocomplete]);