Bug 537782 - e10s HTTP: authentication. r=jduell

This commit is contained in:
Honza Bambas 2010-06-24 15:20:42 -07:00
parent 4719dd0705
commit 3503b61a07
3 changed files with 43 additions and 4 deletions

View File

@ -1,5 +1,5 @@
/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8; -*- */
/* vim: set sw=4 ts=8 et tw=80 : */
/* vim: set sw=2 ts=8 et tw=80 : */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -65,6 +65,8 @@
#include "nsIDOMNSHTMLFrameElement.h"
#include "nsIDialogCreator.h"
#include "nsThreadUtils.h"
#include "nsIPromptFactory.h"
#include "nsIContent.h"
using mozilla::ipc::DocumentRendererParent;
using mozilla::ipc::DocumentRendererShmemParent;
@ -78,7 +80,7 @@ using mozilla::dom::ContentProcessParent;
namespace mozilla {
namespace dom {
NS_IMPL_ISUPPORTS2(TabParent, nsITabParent, nsIWebProgress)
NS_IMPL_ISUPPORTS3(TabParent, nsITabParent, nsIWebProgress, nsIAuthPromptProvider)
TabParent::TabParent()
{
@ -616,6 +618,33 @@ TabParent::GetIsLoadingDocument(PRBool *aIsLoadingDocument)
return NS_ERROR_NOT_IMPLEMENTED;
}
// nsIAuthPromptProvider
// This method is largely copied from nsDocShell::GetAuthPrompt
NS_IMETHODIMP
TabParent::GetAuthPrompt(PRUint32 aPromptReason, const nsIID& iid,
void** aResult)
{
// a priority prompt request will override a false mAllowAuth setting
PRBool priorityPrompt = (aPromptReason == PROMPT_PROXY);
// we're either allowing auth, or it's a proxy request
nsresult rv;
nsCOMPtr<nsIPromptFactory> wwatch =
do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDOMWindow> window;
nsCOMPtr<nsIContent> frame = do_QueryInterface(mFrameElement);
if (frame)
window = do_QueryInterface(frame->GetOwnerDoc()->GetWindow());
// Get an auth prompter for our window so that the parenting
// of the dialogs works as it should when using tabs.
return wwatch->GetPrompt(window, iid,
reinterpret_cast<void**>(aResult));
}
PContentDialogParent*
TabParent::AllocPContentDialog(const PRUint32& aType,
const nsCString& aName,

View File

@ -51,6 +51,7 @@
#include "nsIWebProgressListener.h"
#include "nsWeakReference.h"
#include "nsIDialogParamBlock.h"
#include "nsIAuthPromptProvider.h"
class nsIURI;
class nsIDOMElement;
@ -86,7 +87,10 @@ bool operator==(const TabParentListenerInfo& lhs, const TabParentListenerInfo& r
class ContentDialogParent : public PContentDialogParent {};
class TabParent : public PIFrameEmbeddingParent, public nsITabParent, public nsIWebProgress
class TabParent : public PIFrameEmbeddingParent
, public nsITabParent
, public nsIWebProgress
, public nsIAuthPromptProvider
{
public:
TabParent();
@ -182,6 +186,7 @@ public:
NS_DECL_ISUPPORTS
NS_DECL_NSIWEBPROGRESS
NS_DECL_NSIAUTHPROMPTPROVIDER
void HandleDelayedDialogs();
protected:

View File

@ -289,7 +289,6 @@ HttpChannelParent::GetInterface(const nsIID& aIID, void **result)
// See nsHttpChannel::GetAuthPrompt(). So if we can return any one of these,
// HTTP auth should be all set. The other two if checks can be eventually
// deleted.
aIID.Equals(NS_GET_IID(nsIAuthPromptProvider)) ||
aIID.Equals(NS_GET_IID(nsIAuthPrompt2)) ||
aIID.Equals(NS_GET_IID(nsIAuthPrompt)) ||
// FIXME: redirects (bug 536294):
@ -310,6 +309,12 @@ HttpChannelParent::GetInterface(const nsIID& aIID, void **result)
return QueryInterface(aIID, result);
}
if (aIID.Equals(NS_GET_IID(nsIAuthPromptProvider))) {
if (!mTabParent)
return NS_NOINTERFACE;
return mTabParent->QueryInterface(aIID, result);
}
// Interface we haven't dealt with yet. Make sure we know by dying.
// - use "grep -ri [uuid] ROOT_SRC_DIR" with the uuid from the printf to
// find the offending interface.