Bug 369180: override nsIAuthPromptProvider implementation on search suggestion callbacks to avoid proxy authentication dialog popping up while entering text in the search bar, r=mayhemer
authorGavin Sharp <gavin@gavinsharp.com>
Fri, 29 Mar 2013 13:07:14 -0400
changeset 134534 aaae69fde5623b8ae0325f5485a7e168b8caf4d7
parent 134533 9b50f98dee9147180a746a529535067a77b5515e
child 134535 bc159983a018b10ff2e3a0572d8a1e70783f49e4
push idunknown
push userunknown
push dateunknown
reviewersmayhemer
bugs369180
milestone23.0a1
Bug 369180: override nsIAuthPromptProvider implementation on search suggestion callbacks to avoid proxy authentication dialog popping up while entering text in the search bar, r=mayhemer
toolkit/components/search/nsSearchSuggestions.js
--- a/toolkit/components/search/nsSearchSuggestions.js
+++ b/toolkit/components/search/nsSearchSuggestions.js
@@ -459,16 +459,17 @@ SuggestAutoComplete.prototype = {
     // Actually do the search
     this._request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].
                     createInstance(Ci.nsIXMLHttpRequest);
     var submission = engine.getSubmission(searchString,
                                           SEARCH_RESPONSE_SUGGESTION_JSON);
     this._suggestURI = submission.uri;
     var method = (submission.postData ? "POST" : "GET");
     this._request.open(method, this._suggestURI.spec, true);
+    this._request.channel.notificationCallbacks = new AuthPromptOverride();
     if (this._request.channel instanceof Ci.nsIPrivateBrowsingChannel) {
       this._request.channel.setPrivate(privacyMode);
     }
 
     var self = this;
     function onReadyStateChange() {
       self.onReadyStateChange();
     }
@@ -518,16 +519,41 @@ SuggestAutoComplete.prototype = {
     Services.obs.removeObserver(this, XPCOM_SHUTDOWN_TOPIC);
   },
 
   // nsISupports
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIAutoCompleteSearch,
                                          Ci.nsIAutoCompleteObserver])
 };
 
+function AuthPromptOverride() {
+}
+AuthPromptOverride.prototype = {
+  // nsIAuthPromptProvider
+  getAuthPrompt: function (reason, iid) {
+    // Return a no-op nsIAuthPrompt2 implementation.
+    return {
+      promptAuth: function () {
+        throw Cr.NS_ERROR_NOT_IMPLEMENTED;
+      },
+      asyncPromptAuth: function () {
+        throw Cr.NS_ERROR_NOT_IMPLEMENTED;
+      }
+    };
+  },
+
+  // nsIInterfaceRequestor
+  getInterface: function SSLL_getInterface(iid) {
+    return this.QueryInterface(iid);
+  },
+
+  // nsISupports
+  QueryInterface: XPCOMUtils.generateQI([Ci.nsIAuthPromptProvider,
+                                         Ci.nsIInterfaceRequestor])
+};
 /**
  * SearchSuggestAutoComplete is a service implementation that handles suggest
  * results specific to web searches.
  * @constructor
  */
 function SearchSuggestAutoComplete() {
   // This calls _init() in the parent class (SuggestAutoComplete) via the
   // prototype, below.