diff --git a/content/base/src/Makefile.in b/content/base/src/Makefile.in index 43360033e3f1..ac4f9c7a2570 100644 --- a/content/base/src/Makefile.in +++ b/content/base/src/Makefile.in @@ -82,6 +82,7 @@ REQUIRES = xpcom \ appshell \ shistory \ editor \ + windowwatcher \ $(NULL) ifdef ACCESSIBILITY diff --git a/content/base/src/nsXMLHttpRequest.cpp b/content/base/src/nsXMLHttpRequest.cpp index 8b1a007d741a..8e0bf741e319 100644 --- a/content/base/src/nsXMLHttpRequest.cpp +++ b/content/base/src/nsXMLHttpRequest.cpp @@ -88,6 +88,8 @@ #include "nsIMultiPartChannel.h" #include "nsIScriptObjectPrincipal.h" #include "nsIStorageStream.h" +#include "nsIPromptFactory.h" +#include "nsIWindowWatcher.h" #define LOAD_STR "load" #define ERROR_STR "error" @@ -2335,6 +2337,8 @@ nsXMLHttpRequest::OnStatus(nsIRequest *aRequest, nsISupports *aContext, nsresult NS_IMETHODIMP nsXMLHttpRequest::GetInterface(const nsIID & aIID, void **aResult) { + nsresult rv; + // Make sure to return ourselves for the channel event sink interface and // progress event sink interface, no matter what. We can forward these to // mNotificationCallbacks if it wants to get notifications for them. But we @@ -2354,7 +2358,7 @@ nsXMLHttpRequest::GetInterface(const nsIID & aIID, void **aResult) // Now give mNotificationCallbacks (if non-null) a chance to return the // desired interface. if (mNotificationCallbacks) { - nsresult rv = mNotificationCallbacks->GetInterface(aIID, aResult); + rv = mNotificationCallbacks->GetInterface(aIID, aResult); if (NS_SUCCEEDED(rv)) { NS_ASSERTION(*aResult, "Lying nsIInterfaceRequestor implementation!"); return rv; @@ -2362,7 +2366,6 @@ nsXMLHttpRequest::GetInterface(const nsIID & aIID, void **aResult) } if (mState & XML_HTTP_REQUEST_BACKGROUND) { - nsresult rv; nsCOMPtr badCertHandler(do_CreateInstance(NS_BADCERTHANDLER_CONTRACTID, &rv)); // Ignore failure to get component, we may not have all its dependencies @@ -2373,6 +2376,24 @@ nsXMLHttpRequest::GetInterface(const nsIID & aIID, void **aResult) return rv; } } + else if (aIID.Equals(NS_GET_IID(nsIAuthPrompt)) || + aIID.Equals(NS_GET_IID(nsIAuthPrompt2))) { + nsCOMPtr wwatch = + do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv); + NS_ENSURE_SUCCESS(rv, rv); + + // Get the an auth prompter for our window so that the parenting + // of the dialogs works as it should when using tabs. + + nsCOMPtr window; + if (mOwner) { + window = mOwner->GetOuterWindow(); + } + + return wwatch->GetPrompt(window, aIID, + reinterpret_cast(aResult)); + + } return QueryInterface(aIID, aResult); }