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 127844 448765c6360b44b5ea3ec255936bfb086f8545c5
parent 127842 45835d0c9d58d23af167821879fafd2570764e5a
child 127845 8262a337d5be6b3296f467a42e783f58fbeef72d
push id24513
push userphilringnalda@gmail.com
push dateSat, 06 Apr 2013 03:53:52 +0000
treeherdermozilla-central@768af8d8fad4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmayhemer
bugs369180
milestone23.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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.