Bug 139248

Patch to stop fontdownload dlg in mail/news
r=nhotta; sr=mscott checking in for smontagu
This commit is contained in:
yokoyama%netscape.com 2002-05-17 22:58:46 +00:00
parent ea7969a4bf
commit 64ac2accb9
4 changed files with 53 additions and 1 deletions

View File

@ -118,6 +118,10 @@ nsresult nsFontPackageService::CallDownload(const char *aFontPackID, PRInt8 aInS
if (!have) {
*aOutState = eDownload;
rv = mHandler->NeedFontPackage(aFontPackID);
if (rv == NS_ERROR_ABORT) {
*aOutState = eInit;
rv = NS_OK;
}
}
else {
*aOutState = eInstalled;

View File

@ -38,6 +38,7 @@ REQUIRES = xpcom \
necko \
dom \
windowwatcher \
appshell \
$(NULL)
EXPORTS = \

View File

@ -33,6 +33,7 @@ REQUIRES= xpcom \
necko \
dom \
windowwatcher \
appshell \
$(NULL)
CPP_OBJS=\

View File

@ -51,6 +51,9 @@
#include "nsXPIDLString.h"
#include "nsReadableUtils.h"
#include "nsFontPackageHandler.h"
#include "nsIDOMDocument.h"
#include "nsIDOMElement.h"
#include "nsIWindowMediator.h"
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
@ -76,8 +79,51 @@ NS_IMETHODIMP nsFontPackageHandler::NeedFontPackage(const char *aFontPackID)
// no FontPackage is passed, return
NS_ENSURE_ARG_POINTER(aFontPackID);
// check whether the topmost window is a mailnews window. If it is,
// or if any of the calls fail, return NS_ERROR_ABORT
nsresult rv;
nsCOMPtr<nsIWindowMediator> windowMediator = do_GetService(NS_WINDOWMEDIATOR_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, NS_ERROR_ABORT);
nsCOMPtr<nsISimpleEnumerator> windowEnum;
rv = windowMediator->GetZOrderDOMWindowEnumerator(nsnull, PR_TRUE, getter_AddRefs(windowEnum));
NS_ENSURE_SUCCESS(rv, NS_ERROR_ABORT);
nsCOMPtr<nsISupports> windowSupports;
nsCOMPtr<nsIDOMWindow> topMostWindow;
nsCOMPtr<nsIDOMDocument> domDocument;
nsCOMPtr<nsIDOMElement> domElement;
nsAutoString windowType;
PRBool more;
windowEnum->HasMoreElements(&more);
if (more) {
rv = windowEnum->GetNext(getter_AddRefs(windowSupports));
NS_ENSURE_SUCCESS(rv, NS_ERROR_ABORT);
NS_ENSURE_TRUE(windowSupports, NS_ERROR_ABORT);
topMostWindow = do_QueryInterface(windowSupports, &rv);
NS_ENSURE_SUCCESS(rv, NS_ERROR_ABORT);
NS_ENSURE_TRUE(topMostWindow, NS_ERROR_ABORT);
rv = topMostWindow->GetDocument(getter_AddRefs(domDocument));
NS_ENSURE_SUCCESS(rv, NS_ERROR_ABORT);
NS_ENSURE_TRUE(domDocument, NS_ERROR_ABORT);
rv = domDocument->GetDocumentElement(getter_AddRefs(domElement));
NS_ENSURE_SUCCESS(rv, NS_ERROR_ABORT);
NS_ENSURE_TRUE(domElement, NS_ERROR_ABORT);
rv = domElement->GetAttribute(NS_LITERAL_STRING("windowtype"), windowType);
NS_ENSURE_SUCCESS(rv, NS_ERROR_ABORT);
if (windowType.Equals(NS_LITERAL_STRING("mail:3pane")) ||
windowType.Equals(NS_LITERAL_STRING("mail:messageWindow"))) {
return NS_ERROR_ABORT;
}
}
nsXPIDLCString absUrl;
nsresult rv = CreateURLString(aFontPackID, getter_Copies(absUrl));
rv = CreateURLString(aFontPackID, getter_Copies(absUrl));
if (NS_FAILED(rv))
return rv;