зеркало из https://github.com/mozilla/pjs.git
nsIPrompt interface requests are now fielded to the service, rather than the enclosing chrome window. bug 72112 r=blizzard,ccarlen
This commit is contained in:
Родитель
c29bc95f12
Коммит
74e9b4035b
|
@ -107,37 +107,39 @@ NS_INTERFACE_MAP_END
|
|||
|
||||
NS_IMETHODIMP nsDocShellTreeOwner::GetInterface(const nsIID& aIID, void** aSink)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aSink);
|
||||
NS_ENSURE_ARG_POINTER(aSink);
|
||||
|
||||
if(NS_SUCCEEDED(QueryInterface(aIID, aSink)))
|
||||
if(NS_SUCCEEDED(QueryInterface(aIID, aSink)))
|
||||
return NS_OK;
|
||||
|
||||
if (aIID.Equals(NS_GET_IID(nsIPrompt))) {
|
||||
nsIPrompt *prompt;
|
||||
EnsurePrompter();
|
||||
prompt = mPrompter;
|
||||
if (prompt) {
|
||||
NS_ADDREF(prompt);
|
||||
*aSink = prompt;
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
if(mOwnerRequestor) {
|
||||
if (aIID.Equals(NS_GET_IID(nsIAuthPrompt))) {
|
||||
if (!mAuthPrompter) {
|
||||
|
||||
// Get the prompt UI from the owner
|
||||
nsCOMPtr<nsIPrompt> prompt;
|
||||
nsresult rv = mOwnerRequestor->GetInterface(NS_GET_IID(nsIPrompt), getter_AddRefs(prompt));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Attempt to create a single signon. If that fails, create a simple non-persistent nsIAuthPrompt.
|
||||
mAuthPrompter = do_CreateInstance(NS_SINGLESIGNONPROMPT_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
mAuthPrompter = new nsNonPersistAuthPrompt;
|
||||
NS_ENSURE_TRUE(mAuthPrompter, NS_ERROR_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISingleSignOnPrompt> siPrompt(do_QueryInterface(mAuthPrompter, &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
siPrompt->SetPromptDialogs(prompt);
|
||||
}
|
||||
return mAuthPrompter->QueryInterface(aIID, aSink);
|
||||
}
|
||||
return mOwnerRequestor->GetInterface(aIID, aSink);
|
||||
}
|
||||
if (aIID.Equals(NS_GET_IID(nsIAuthPrompt))) {
|
||||
nsIAuthPrompt *prompt;
|
||||
EnsureAuthPrompter();
|
||||
prompt = mAuthPrompter;
|
||||
if (prompt) {
|
||||
NS_ADDREF(prompt);
|
||||
*aSink = prompt;
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
return NS_NOINTERFACE;
|
||||
if(mOwnerRequestor)
|
||||
return mOwnerRequestor->GetInterface(aIID, aSink);
|
||||
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
|
@ -291,6 +293,34 @@ nsresult nsDocShellTreeOwner::FindItemWithNameAcrossWindows(
|
|||
return rv;
|
||||
}
|
||||
|
||||
void nsDocShellTreeOwner::EnsurePrompter()
|
||||
{
|
||||
if (mPrompter)
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1"));
|
||||
if (wwatch && mWebBrowser) {
|
||||
nsCOMPtr<nsIDOMWindow> domWindow;
|
||||
mWebBrowser->GetContentDOMWindow(getter_AddRefs(domWindow));
|
||||
if (domWindow)
|
||||
wwatch->GetNewPrompter(domWindow, getter_AddRefs(mPrompter));
|
||||
}
|
||||
}
|
||||
|
||||
void nsDocShellTreeOwner::EnsureAuthPrompter()
|
||||
{
|
||||
if (mAuthPrompter)
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1"));
|
||||
if (wwatch && mWebBrowser) {
|
||||
nsCOMPtr<nsIDOMWindow> domWindow;
|
||||
mWebBrowser->GetContentDOMWindow(getter_AddRefs(domWindow));
|
||||
if (domWindow)
|
||||
wwatch->GetNewAuthPrompter(domWindow, getter_AddRefs(mAuthPrompter));
|
||||
}
|
||||
}
|
||||
|
||||
void nsDocShellTreeOwner::AddToWatcher() {
|
||||
|
||||
if (mWebBrowser) {
|
||||
|
@ -677,6 +707,10 @@ void nsDocShellTreeOwner::WebBrowser(nsWebBrowser* aWebBrowser)
|
|||
{
|
||||
if ( !aWebBrowser )
|
||||
RemoveChromeListeners();
|
||||
if (aWebBrowser != mWebBrowser) {
|
||||
mPrompter = 0;
|
||||
mAuthPrompter = 0;
|
||||
}
|
||||
|
||||
mWebBrowser = aWebBrowser;
|
||||
}
|
||||
|
@ -784,7 +818,6 @@ nsDocShellTreeOwner :: RemoveChromeListeners ( )
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
#ifdef XP_MAC
|
||||
#pragma mark -
|
||||
#endif
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include "nsIDOMMouseMotionListener.h"
|
||||
#include "nsIDOMContextMenuListener.h"
|
||||
#include "nsITimer.h"
|
||||
#include "nsIPrompt.h"
|
||||
#include "nsIAuthPrompt.h"
|
||||
|
||||
#include "nsCommandHandler.h"
|
||||
|
@ -105,6 +106,9 @@ protected:
|
|||
nsresult FindItemWithNameAcrossWindows(const PRUnichar* aName,
|
||||
nsIDocShellTreeItem **aFoundItem);
|
||||
|
||||
void EnsurePrompter();
|
||||
void EnsureAuthPrompter();
|
||||
|
||||
void AddToWatcher();
|
||||
void RemoveFromWatcher();
|
||||
|
||||
|
@ -118,13 +122,14 @@ protected:
|
|||
nsIWebBrowserChrome* mWebBrowserChrome;
|
||||
nsIEmbeddingSiteWindow* mOwnerWin;
|
||||
nsIInterfaceRequestor* mOwnerRequestor;
|
||||
|
||||
|
||||
// the objects that listen for chrome events like context menus and tooltips.
|
||||
// They are separate objects to avoid circular references between |this|
|
||||
// and the DOM. These are strong, owning refs.
|
||||
ChromeTooltipListener* mChromeTooltipListener;
|
||||
ChromeContextMenuListener* mChromeContextMenuListener;
|
||||
|
||||
|
||||
nsCOMPtr<nsIPrompt> mPrompter;
|
||||
nsCOMPtr<nsIAuthPrompt> mAuthPrompter;
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче