Bug 425078: Not showing authentication dialog box when request is made throught XMLHttpRequest in chrome window. r/sr=jst

This commit is contained in:
jonas@sicking.cc 2008-04-08 17:27:50 -07:00
Родитель c36cfad0ae
Коммит d9168e1128
2 изменённых файлов: 24 добавлений и 2 удалений

Просмотреть файл

@ -82,6 +82,7 @@ REQUIRES = xpcom \
appshell \
shistory \
editor \
windowwatcher \
$(NULL)
ifdef ACCESSIBILITY

Просмотреть файл

@ -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<nsIInterfaceRequestor> 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<nsIPromptFactory> 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<nsIDOMWindow> window;
if (mOwner) {
window = mOwner->GetOuterWindow();
}
return wwatch->GetPrompt(window, aIID,
reinterpret_cast<void**>(aResult));
}
return QueryInterface(aIID, aResult);
}