diff --git a/mozilla/caps/src/nsCodebasePrincipal.cpp b/mozilla/caps/src/nsCodebasePrincipal.cpp index 27157087146..5a03c6ff884 100644 --- a/mozilla/caps/src/nsCodebasePrincipal.cpp +++ b/mozilla/caps/src/nsCodebasePrincipal.cpp @@ -93,10 +93,12 @@ nsCodebasePrincipal::CanEnableCapability(const char *capability, if (NS_FAILED(prefs->GetBoolPref(pref, &enabled)) || !enabled) { // Deny unless subject is executing from file: or resource: - nsXPIDLCString scheme; - if (NS_FAILED(mURI->GetScheme(getter_Copies(scheme))) || - (PL_strcmp(scheme, "file") != 0 && - PL_strcmp(scheme, "resource") != 0)) + PRBool isFile = PR_FALSE; + PRBool isRes = PR_FALSE; + + if (NS_FAILED(mURI->SchemeIs(nsIURI::FILE, &isFile)) || + NS_FAILED(mURI->SchemeIs(nsIURI::RESOURCE, &isRes)) || + (!isFile && !isRes)) { *result = nsIPrincipal::ENABLE_DENIED; return NS_OK; diff --git a/mozilla/caps/src/nsScriptSecurityManager.cpp b/mozilla/caps/src/nsScriptSecurityManager.cpp index 6aac1996453..d693f84528f 100644 --- a/mozilla/caps/src/nsScriptSecurityManager.cpp +++ b/mozilla/caps/src/nsScriptSecurityManager.cpp @@ -484,11 +484,12 @@ nsScriptSecurityManager::CheckLoadURIFromScript(JSContext *cx, // See if we're attempting to load a file: URI. If so, let a // UniversalFileRead capability trump the above check. - nsXPIDLCString scheme; - if (NS_FAILED(aURI->GetScheme(getter_Copies(scheme)))) + PRBool isFile = PR_FALSE; + PRBool isRes = PR_FALSE; + if (NS_FAILED(aURI->SchemeIs(nsIURI::FILE, &isFile)) || + NS_FAILED(aURI->SchemeIs(nsIURI::RESOURCE, &isRes))) return NS_ERROR_FAILURE; - if (nsCRT::strcasecmp(scheme, "file") == 0 || - nsCRT::strcasecmp(scheme, "resource") == 0) + if (isFile || isRes) { PRBool enabled; if (NS_FAILED(IsCapabilityEnabled("UniversalFileRead", &enabled))) diff --git a/mozilla/chrome/src/nsChromeRegistry.cpp b/mozilla/chrome/src/nsChromeRegistry.cpp index 2d80b9ca2a1..b00d5e22619 100644 --- a/mozilla/chrome/src/nsChromeRegistry.cpp +++ b/mozilla/chrome/src/nsChromeRegistry.cpp @@ -20,6 +20,7 @@ * Original Author: David W. Hyatt (hyatt@netscape.com) * * Contributor(s): + * Gagan Saksena */ #include @@ -1079,16 +1080,10 @@ NS_IMETHODIMP nsChromeRegistry::RefreshSkins() static PRBool IsChromeURI(nsIURI* aURI) { - nsresult rv; - nsXPIDLCString protocol; - rv = aURI->GetScheme(getter_Copies(protocol)); - if (NS_SUCCEEDED(rv)) { - if (PL_strcmp(protocol, "chrome") == 0) { + PRBool isChrome=PR_FALSE; + if (NS_SUCCEEDED(aURI->SchemeIs(nsIURI::CHROME, &isChrome)) && isChrome) return PR_TRUE; - } - } - - return PR_FALSE; + return PR_FALSE; } NS_IMETHODIMP nsChromeRegistry::RefreshWindow(nsIDOMWindowInternal* aWindow) diff --git a/mozilla/content/base/src/nsDocument.cpp b/mozilla/content/base/src/nsDocument.cpp index cc27b8ec8e7..ef5795fe93a 100644 --- a/mozilla/content/base/src/nsDocument.cpp +++ b/mozilla/content/base/src/nsDocument.cpp @@ -804,10 +804,13 @@ nsDocument::Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup) nsCOMPtr uri; (void) aChannel->GetOriginalURI(getter_AddRefs(uri)); - nsXPIDLCString scheme; - (void)uri->GetScheme(getter_Copies(scheme)); - if (scheme && ((0 == PL_strncmp((const char*)scheme, "chrome", 6)) || - (0 == PL_strncmp((const char*)scheme, "resource", 8)))) + + PRBool isChrome = PR_FALSE; + PRBool isRes = PR_FALSE; + (void)uri->SchemeIs(nsIURI::CHROME, &isChrome); + (void)uri->SchemeIs(nsIURI::RESOURCE, &isRes); + + if (isChrome || isRes) (void)aChannel->GetOriginalURI(&mDocumentURL); else (void)aChannel->GetURI(&mDocumentURL); @@ -1861,7 +1864,6 @@ nsDocument::GetDoctype(nsIDOMDocumentType** aDoctype) NS_ENSURE_ARG_POINTER(aDoctype); *aDoctype = nsnull; - PRUint32 i, count; mChildren->Count(&count); nsCOMPtr rootContentNode( do_QueryInterface(mRootContent) ); @@ -2689,7 +2691,6 @@ nsDocument::ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild, nsIDOMNod ContentInserted(nsnull, content, index); content->SetDocument(this, PR_TRUE, PR_TRUE); - *aReturn = aOldChild; NS_ADDREF(aOldChild); diff --git a/mozilla/content/xbl/src/nsXBLPrototypeHandler.cpp b/mozilla/content/xbl/src/nsXBLPrototypeHandler.cpp index 8e19ba95889..38aae623f0c 100644 --- a/mozilla/content/xbl/src/nsXBLPrototypeHandler.cpp +++ b/mozilla/content/xbl/src/nsXBLPrototypeHandler.cpp @@ -19,6 +19,7 @@ * * Original Author: David W. Hyatt (hyatt@netscape.com) * + * Contributor(s): */ #include "nsCOMPtr.h" @@ -199,9 +200,13 @@ nsXBLPrototypeHandler::ExecuteHandler(nsIDOMEventReceiver* aReceiver, nsIDOMEven nsCOMPtr document; mHandlerElement->GetDocument(*getter_AddRefs(document)); nsCOMPtr url = getter_AddRefs(document->GetDocumentURL()); - nsXPIDLCString scheme; - url->GetScheme(getter_Copies(scheme)); - if (PL_strcmp(scheme, "chrome") != 0 && PL_strcmp(scheme, "resource") != 0) + + PRBool isChrome = PR_FALSE; + PRBool isRes = PR_FALSE; + + url->SchemeIs(nsIURI::CHROME, &isChrome); + url->SchemeIs(nsIURI::RESOURCE, &isRes); + if (!isChrome && !isRes) return NS_OK; // We are the default action for this command. diff --git a/mozilla/content/xbl/src/nsXBLService.cpp b/mozilla/content/xbl/src/nsXBLService.cpp index 8be09396cc1..0a0c53f0021 100644 --- a/mozilla/content/xbl/src/nsXBLService.cpp +++ b/mozilla/content/xbl/src/nsXBLService.cpp @@ -81,29 +81,19 @@ static NS_DEFINE_CID(kChromeRegistryCID, NS_CHROMEREGISTRY_CID); static PRBool IsChromeOrResourceURI(nsIURI* aURI) { - nsresult rv; - nsXPIDLCString protocol; - rv = aURI->GetScheme(getter_Copies(protocol)); - if (NS_SUCCEEDED(rv)) { - if (!PL_strcmp(protocol, "chrome") || !PL_strcmp(protocol, "resource")) { - return PR_TRUE; - } - } - + PRBool isChrome = PR_FALSE; + PRBool isResource = PR_FALSE; + if (NS_SUCCEEDED(aURI->SchemeIs(nsIURI::CHROME, &isChrome)) && + NS_SUCCEEDED(aURI->SchemeIs(nsIURI::RESOURCE, &isResource))) + return (isChrome || isResource); return PR_FALSE; } static PRBool IsResourceURI(nsIURI* aURI) { - nsresult rv; - nsXPIDLCString protocol; - rv = aURI->GetScheme(getter_Copies(protocol)); - if (NS_SUCCEEDED(rv)) { - if (!PL_strcmp(protocol, "resource")) { - return PR_TRUE; - } - } - + PRBool isResource = PR_FALSE; + if (NS_SUCCEEDED(aURI->SchemeIs(nsIURI::RESOURCE, &isResource)) && isResource) + return PR_TRUE; return PR_FALSE; } diff --git a/mozilla/content/xul/document/src/nsXULDocument.cpp b/mozilla/content/xul/document/src/nsXULDocument.cpp index 83c5616582c..98ba666eae5 100644 --- a/mozilla/content/xul/document/src/nsXULDocument.cpp +++ b/mozilla/content/xul/document/src/nsXULDocument.cpp @@ -165,6 +165,15 @@ static NS_DEFINE_CID(kRangeCID, NS_RANGE_CID); static NS_DEFINE_IID(kIParserIID, NS_IPARSER_IID); +static PRBool IsChromeURI(nsIURI* aURI) +{ + // why is this check a member function of nsXULDocument? -gagan + PRBool isChrome=PR_FALSE; + if (NS_SUCCEEDED(aURI->SchemeIs(nsIURI::CHROME, &isChrome)) && isChrome) + return PR_TRUE; + return PR_FALSE; +} + //---------------------------------------------------------------------- // // Miscellaneous Constants @@ -6378,20 +6387,6 @@ nsXULDocument::RemoveElement(nsIContent* aParent, nsIContent* aChild) -PRBool -nsXULDocument::IsChromeURI(nsIURI* aURI) -{ - nsresult rv; - nsXPIDLCString protocol; - rv = aURI->GetScheme(getter_Copies(protocol)); - if (NS_SUCCEEDED(rv)) { - if (PL_strcmp(protocol, "chrome") == 0) { - return PR_TRUE; - } - } - - return PR_FALSE; -} void nsXULDocument::GetElementFactory(PRInt32 aNameSpaceID, nsIElementFactory** aResult) diff --git a/mozilla/content/xul/document/src/nsXULDocument.h b/mozilla/content/xul/document/src/nsXULDocument.h index 61ecfe3e6ca..3a83bb3cfad 100644 --- a/mozilla/content/xul/document/src/nsXULDocument.h +++ b/mozilla/content/xul/document/src/nsXULDocument.h @@ -725,10 +725,6 @@ protected: nsresult RemoveElement(nsIContent* aParent, nsIContent* aChild); - static - PRBool - IsChromeURI(nsIURI* aURI); - /** * The current prototype that we are walking to construct the * content model. diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index b9e7c392dd7..33a258e6952 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -3259,10 +3259,10 @@ NS_IMETHODIMP nsDocShell::DoURILoad(nsIURI* aURI, nsIURI* aReferrerURI, // attribute execute in the correct window, this only works if the // target window exists when the link is clicked. if (aWindowTarget && *aWindowTarget) { - nsXPIDLCString urlScheme; - aURI->GetScheme(getter_Copies(urlScheme)); + PRBool isJSURL = PR_FALSE; // do it only for javascript urls! - if (urlScheme && !nsCRT::strcasecmp(jsSchemeName, urlScheme)) { + if (NS_SUCCEEDED(aURI->SchemeIs(nsIURI::JAVASCRIPT, &isJSURL)) && isJSURL) + { nsAutoString targetName; targetName.AssignWithConversion(aWindowTarget); nsCOMPtr targetDocShell; @@ -3328,9 +3328,7 @@ NS_IMETHODIMP nsDocShell::DoURILoad(nsIURI* aURI, nsIURI* aReferrerURI, nsCOMPtr ioChannel(do_QueryInterface(channel)); if(ioChannel) // Might be a javascript: URL load, need to set owner { - nsXPIDLCString scheme; - aURI->GetScheme(getter_Copies(scheme)); - isJSOrData = (PL_strcasecmp(scheme, jsSchemeName) == 0); + aURI->SchemeIs(nsIURI::JAVASCRIPT, &isJSOrData); } else { // Also set owner for data: URLs @@ -3949,6 +3947,10 @@ void nsDocShell::SetReferrerURI(nsIURI* aURI) //***************************************************************************** PRBool nsDocShell::ShouldAddToSessionHistory(nsIURI* aURI) { + // I believe none of the about: urls should go in the history. But then + // that could just be me... If the intent is only deny about:blank then we + // should just do a spec compare, rather than two gets of the scheme and + // then the path. -Gagan nsresult rv; nsXPIDLCString buffer; nsCAutoString schemeStr; @@ -4249,28 +4251,36 @@ NS_IMETHODIMP nsDocShell::ShouldAddToGlobalHistory(nsIURI* aURI, PRBool* aShould if(!mGlobalHistory || !aURI || (typeContent != mItemType)) return NS_OK; - nsXPIDLCString scheme; - NS_ENSURE_SUCCESS(aURI->GetScheme(getter_Copies(scheme)), NS_ERROR_FAILURE); - - nsAutoString schemeStr; schemeStr.AssignWithConversion(scheme); - // The model is really if we don't know differently then add which basically // means we are suppose to try all the things we know not to allow in and // then if we don't bail go on and allow it in. But here lets compare // against the most common case we know to allow in and go on and say yes // to it. - if(schemeStr.EqualsWithConversion("http") || schemeStr.EqualsWithConversion("https")) - { - *aShouldAdd = PR_TRUE; - return NS_OK; - } + PRBool isHTTP = PR_FALSE; + PRBool isHTTPS = PR_FALSE; + NS_ENSURE_SUCCESS(aURI->SchemeIs(nsIURI::HTTP, &isHTTP), NS_ERROR_FAILURE); + NS_ENSURE_SUCCESS(aURI->SchemeIs(nsIURI::HTTPS, &isHTTPS), NS_ERROR_FAILURE); - if(schemeStr.EqualsWithConversion("about") || schemeStr.EqualsWithConversion("imap") || - schemeStr.EqualsWithConversion("news") || schemeStr.EqualsWithConversion("mailbox")) + if (isHTTP || isHTTPS) + { + *aShouldAdd = PR_TRUE; + return NS_OK; + } + + PRBool isAbout = PR_FALSE; + PRBool isImap = PR_FALSE; + PRBool isNews = PR_FALSE; + PRBool isMailbox = PR_FALSE; + + NS_ENSURE_SUCCESS(aURI->SchemeIs(nsIURI::ABOUT, &isAbout), NS_ERROR_FAILURE); + NS_ENSURE_SUCCESS(aURI->SchemeIs(nsIURI::IMAP, &isImap), NS_ERROR_FAILURE); + NS_ENSURE_SUCCESS(aURI->SchemeIs(nsIURI::NEWS, &isNews), NS_ERROR_FAILURE); + NS_ENSURE_SUCCESS(aURI->SchemeIs(nsIURI::MAILBOX, &isMailbox), NS_ERROR_FAILURE); + + if (isAbout || isImap || isNews || isMailbox) return NS_OK; *aShouldAdd = PR_TRUE; - return NS_OK; } diff --git a/mozilla/editor/base/nsEditorShell.cpp b/mozilla/editor/base/nsEditorShell.cpp index 88ded6ceb97..69fb8798acd 100644 --- a/mozilla/editor/base/nsEditorShell.cpp +++ b/mozilla/editor/base/nsEditorShell.cpp @@ -554,15 +554,13 @@ nsEditorShell::PrepareDocumentForEditing(nsIDOMWindow* aDOMWindow, nsIURI *aUrl) // get the URL of the page we are editing if (aUrl) { - nsXPIDLCString pageScheme; - aUrl->GetScheme(getter_Copies(pageScheme)); - - nsCAutoString schemeStr(pageScheme); // if this is a file URL of a file that exists locally, we'll stash the nsIFile // in the disk document, so that later saves save back to the same file. nsCOMPtr pageFileURL(do_QueryInterface(aUrl)); - if (schemeStr.EqualsIgnoreCase("file") && pageFileURL) + PRBool isFile=PR_FALSE; + rv = aUrl->SchemeIs(nsIURI::FILE, &isFile); + if (NS_SUCCEEDED(rv) && isFile && pageFileURL) { nsCOMPtr pageFile; pageFileURL->GetFile(getter_AddRefs(pageFile)); diff --git a/mozilla/editor/composer/src/nsEditorShell.cpp b/mozilla/editor/composer/src/nsEditorShell.cpp index 88ded6ceb97..69fb8798acd 100644 --- a/mozilla/editor/composer/src/nsEditorShell.cpp +++ b/mozilla/editor/composer/src/nsEditorShell.cpp @@ -554,15 +554,13 @@ nsEditorShell::PrepareDocumentForEditing(nsIDOMWindow* aDOMWindow, nsIURI *aUrl) // get the URL of the page we are editing if (aUrl) { - nsXPIDLCString pageScheme; - aUrl->GetScheme(getter_Copies(pageScheme)); - - nsCAutoString schemeStr(pageScheme); // if this is a file URL of a file that exists locally, we'll stash the nsIFile // in the disk document, so that later saves save back to the same file. nsCOMPtr pageFileURL(do_QueryInterface(aUrl)); - if (schemeStr.EqualsIgnoreCase("file") && pageFileURL) + PRBool isFile=PR_FALSE; + rv = aUrl->SchemeIs(nsIURI::FILE, &isFile); + if (NS_SUCCEEDED(rv) && isFile && pageFileURL) { nsCOMPtr pageFile; pageFileURL->GetFile(getter_AddRefs(pageFile)); diff --git a/mozilla/extensions/xmlextras/base/src/nsXMLHttpRequest.cpp b/mozilla/extensions/xmlextras/base/src/nsXMLHttpRequest.cpp index ddaef35113b..f58c87b0c07 100644 --- a/mozilla/extensions/xmlextras/base/src/nsXMLHttpRequest.cpp +++ b/mozilla/extensions/xmlextras/base/src/nsXMLHttpRequest.cpp @@ -699,11 +699,10 @@ nsXMLHttpRequest::OpenRequest(const char *method, if (NS_FAILED(rv)) return rv; // Only http URLs are allowed - nsXPIDLCString protocol; - uri->GetScheme(getter_Copies(protocol)); - if (nsCRT::strncmp("http", (const char*)protocol, 4) != 0) { - return NS_ERROR_INVALID_ARG; - } + PRBool isHTTP = PR_FALSE; + uri->SchemeIs(nsIURI::HTTP, &isHTTP); + if (!isHTTP) + return NS_ERROR_INVALID_ARG; if (user) { nsCAutoString prehost; diff --git a/mozilla/htmlparser/src/nsExpatTokenizer.cpp b/mozilla/htmlparser/src/nsExpatTokenizer.cpp index 8dad05d59c0..fcbdb3438cd 100644 --- a/mozilla/htmlparser/src/nsExpatTokenizer.cpp +++ b/mozilla/htmlparser/src/nsExpatTokenizer.cpp @@ -63,7 +63,6 @@ typedef struct _XMLParserState { static NS_DEFINE_IID(kHTMLTokenizerIID, NS_HTMLTOKENIZER_IID); static NS_DEFINE_IID(kClassIID, NS_EXPATTOKENIZER_IID); -static const char* kChromeProtocol = "chrome"; static const char* kDTDDirectory = "dtd/"; static const char kHTMLNameSpaceURI[] = "http://www.w3.org/1999/xhtml"; @@ -718,7 +717,6 @@ void nsExpatTokenizer::HandleUnparsedEntityDecl(void *userData, static PRBool IsLoadableDTD(nsCOMPtr* aDTD) { - char* scheme = nsnull; PRBool isLoadable = PR_FALSE; nsresult res = NS_OK; @@ -728,12 +726,7 @@ IsLoadableDTD(nsCOMPtr* aDTD) } // Return true if the url is a chrome url - res = (*aDTD)->GetScheme(&scheme); - if (NS_SUCCEEDED(res) && nsnull != scheme) { - if (PL_strcmp(scheme, kChromeProtocol) == 0) - isLoadable = PR_TRUE; - nsCRT::free(scheme); - } + res = (*aDTD)->SchemeIs(nsIURI::CHROME, &isLoadable); // If the url is not a chrome url, check to see if a DTD file of the same name // exists in the special DTD directory diff --git a/mozilla/layout/base/nsPresContext.cpp b/mozilla/layout/base/nsPresContext.cpp index 19b6a3cefa6..ad309db8541 100644 --- a/mozilla/layout/base/nsPresContext.cpp +++ b/mozilla/layout/base/nsPresContext.cpp @@ -426,14 +426,15 @@ nsPresContext::SetShell(nsIPresShell* aShell) doc->GetBaseURL(*getter_AddRefs(mBaseURL)); if (mBaseURL) { - char* scheme = 0; - mBaseURL->GetScheme(&scheme); - if (nsCRT::strncmp(scheme, "chrome", 6) && - nsCRT::strncmp(scheme, "resource", 8)) + PRBool isChrome = PR_FALSE; + PRBool isRes = PR_FALSE; + mBaseURL->SchemeIs(nsIURI::CHROME, &isChrome); + mBaseURL->SchemeIs(nsIURI::RESOURCE, &isRes); + + if (!isChrome && !isRes) mImageAnimationMode = mImageAnimationModePref; else mImageAnimationMode = eImageAnimation_Normal; - nsMemory::Free(scheme); } if (mLangService) { diff --git a/mozilla/layout/base/src/nsDocument.cpp b/mozilla/layout/base/src/nsDocument.cpp index cc27b8ec8e7..ef5795fe93a 100644 --- a/mozilla/layout/base/src/nsDocument.cpp +++ b/mozilla/layout/base/src/nsDocument.cpp @@ -804,10 +804,13 @@ nsDocument::Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup) nsCOMPtr uri; (void) aChannel->GetOriginalURI(getter_AddRefs(uri)); - nsXPIDLCString scheme; - (void)uri->GetScheme(getter_Copies(scheme)); - if (scheme && ((0 == PL_strncmp((const char*)scheme, "chrome", 6)) || - (0 == PL_strncmp((const char*)scheme, "resource", 8)))) + + PRBool isChrome = PR_FALSE; + PRBool isRes = PR_FALSE; + (void)uri->SchemeIs(nsIURI::CHROME, &isChrome); + (void)uri->SchemeIs(nsIURI::RESOURCE, &isRes); + + if (isChrome || isRes) (void)aChannel->GetOriginalURI(&mDocumentURL); else (void)aChannel->GetURI(&mDocumentURL); @@ -1861,7 +1864,6 @@ nsDocument::GetDoctype(nsIDOMDocumentType** aDoctype) NS_ENSURE_ARG_POINTER(aDoctype); *aDoctype = nsnull; - PRUint32 i, count; mChildren->Count(&count); nsCOMPtr rootContentNode( do_QueryInterface(mRootContent) ); @@ -2689,7 +2691,6 @@ nsDocument::ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild, nsIDOMNod ContentInserted(nsnull, content, index); content->SetDocument(this, PR_TRUE, PR_TRUE); - *aReturn = aOldChild; NS_ADDREF(aOldChild); diff --git a/mozilla/layout/base/src/nsPresContext.cpp b/mozilla/layout/base/src/nsPresContext.cpp index 19b6a3cefa6..ad309db8541 100644 --- a/mozilla/layout/base/src/nsPresContext.cpp +++ b/mozilla/layout/base/src/nsPresContext.cpp @@ -426,14 +426,15 @@ nsPresContext::SetShell(nsIPresShell* aShell) doc->GetBaseURL(*getter_AddRefs(mBaseURL)); if (mBaseURL) { - char* scheme = 0; - mBaseURL->GetScheme(&scheme); - if (nsCRT::strncmp(scheme, "chrome", 6) && - nsCRT::strncmp(scheme, "resource", 8)) + PRBool isChrome = PR_FALSE; + PRBool isRes = PR_FALSE; + mBaseURL->SchemeIs(nsIURI::CHROME, &isChrome); + mBaseURL->SchemeIs(nsIURI::RESOURCE, &isRes); + + if (!isChrome && !isRes) mImageAnimationMode = mImageAnimationModePref; else mImageAnimationMode = eImageAnimation_Normal; - nsMemory::Free(scheme); } if (mLangService) { diff --git a/mozilla/layout/forms/nsIsIndexFrame.cpp b/mozilla/layout/forms/nsIsIndexFrame.cpp index d90b95cd7c4..121216f810d 100644 --- a/mozilla/layout/forms/nsIsIndexFrame.cpp +++ b/mozilla/layout/forms/nsIsIndexFrame.cpp @@ -423,12 +423,12 @@ nsIsIndexFrame::OnSubmit(nsIPresContext* aPresContext) // Get the scheme of the URI. nsCOMPtr actionURL; nsXPIDLCString scheme; + PRBool isJSURL = PR_FALSE; if (NS_SUCCEEDED(result = NS_NewURI(getter_AddRefs(actionURL), href, docURL))) { - result = actionURL->GetScheme(getter_Copies(scheme)); + result = actionURL->SchemeIs(nsIURI::JAVASCRIPT, &isJSURL); } - nsAutoString theScheme; theScheme.AssignWithConversion( NS_STATIC_CAST(const char*, scheme) ); // Append the URI encoded variable/value pairs for GET's - if (!theScheme.EqualsIgnoreCase("javascript")) { // Not for JS URIs, see bug 26917 + if (!isJSURL) { // Not for JS URIs, see bug 26917 if (href.FindChar('?', PR_FALSE, 0) == kNotFound) { // Add a ? if needed href.AppendWithConversion('?'); } else { // Adding to existing query string diff --git a/mozilla/layout/html/forms/src/nsFormFrame.cpp b/mozilla/layout/html/forms/src/nsFormFrame.cpp index fb49f5da3c2..38b538c4de5 100644 --- a/mozilla/layout/html/forms/src/nsFormFrame.cpp +++ b/mozilla/layout/html/forms/src/nsFormFrame.cpp @@ -805,12 +805,13 @@ nsFormFrame::OnSubmit(nsIPresContext* aPresContext, nsIFrame* aFrame) } nsXPIDLCString scheme; - if (actionURL && NS_FAILED(result = actionURL->GetScheme(getter_Copies(scheme)))) + PRBool isMailto = PR_FALSE; + if (actionURL && NS_FAILED(result = actionURL->SchemeIs(nsIURI::MAILTO, + &isMailto))) return result; - if (nsCRT::strcmp(scheme, "mailto") == 0) { + if (isMailto) { PRBool enabled; - if (NS_FAILED(result = securityManager->IsCapabilityEnabled("UniversalSendMail", - &enabled))) + if (NS_FAILED(result = securityManager->IsCapabilityEnabled("UniversalSendMail", &enabled))) { return result; } diff --git a/mozilla/layout/html/forms/src/nsIsIndexFrame.cpp b/mozilla/layout/html/forms/src/nsIsIndexFrame.cpp index d90b95cd7c4..121216f810d 100644 --- a/mozilla/layout/html/forms/src/nsIsIndexFrame.cpp +++ b/mozilla/layout/html/forms/src/nsIsIndexFrame.cpp @@ -423,12 +423,12 @@ nsIsIndexFrame::OnSubmit(nsIPresContext* aPresContext) // Get the scheme of the URI. nsCOMPtr actionURL; nsXPIDLCString scheme; + PRBool isJSURL = PR_FALSE; if (NS_SUCCEEDED(result = NS_NewURI(getter_AddRefs(actionURL), href, docURL))) { - result = actionURL->GetScheme(getter_Copies(scheme)); + result = actionURL->SchemeIs(nsIURI::JAVASCRIPT, &isJSURL); } - nsAutoString theScheme; theScheme.AssignWithConversion( NS_STATIC_CAST(const char*, scheme) ); // Append the URI encoded variable/value pairs for GET's - if (!theScheme.EqualsIgnoreCase("javascript")) { // Not for JS URIs, see bug 26917 + if (!isJSURL) { // Not for JS URIs, see bug 26917 if (href.FindChar('?', PR_FALSE, 0) == kNotFound) { // Add a ? if needed href.AppendWithConversion('?'); } else { // Adding to existing query string diff --git a/mozilla/layout/xbl/src/nsXBLPrototypeHandler.cpp b/mozilla/layout/xbl/src/nsXBLPrototypeHandler.cpp index 8e19ba95889..38aae623f0c 100644 --- a/mozilla/layout/xbl/src/nsXBLPrototypeHandler.cpp +++ b/mozilla/layout/xbl/src/nsXBLPrototypeHandler.cpp @@ -19,6 +19,7 @@ * * Original Author: David W. Hyatt (hyatt@netscape.com) * + * Contributor(s): */ #include "nsCOMPtr.h" @@ -199,9 +200,13 @@ nsXBLPrototypeHandler::ExecuteHandler(nsIDOMEventReceiver* aReceiver, nsIDOMEven nsCOMPtr document; mHandlerElement->GetDocument(*getter_AddRefs(document)); nsCOMPtr url = getter_AddRefs(document->GetDocumentURL()); - nsXPIDLCString scheme; - url->GetScheme(getter_Copies(scheme)); - if (PL_strcmp(scheme, "chrome") != 0 && PL_strcmp(scheme, "resource") != 0) + + PRBool isChrome = PR_FALSE; + PRBool isRes = PR_FALSE; + + url->SchemeIs(nsIURI::CHROME, &isChrome); + url->SchemeIs(nsIURI::RESOURCE, &isRes); + if (!isChrome && !isRes) return NS_OK; // We are the default action for this command. diff --git a/mozilla/layout/xbl/src/nsXBLService.cpp b/mozilla/layout/xbl/src/nsXBLService.cpp index 8be09396cc1..0a0c53f0021 100644 --- a/mozilla/layout/xbl/src/nsXBLService.cpp +++ b/mozilla/layout/xbl/src/nsXBLService.cpp @@ -81,29 +81,19 @@ static NS_DEFINE_CID(kChromeRegistryCID, NS_CHROMEREGISTRY_CID); static PRBool IsChromeOrResourceURI(nsIURI* aURI) { - nsresult rv; - nsXPIDLCString protocol; - rv = aURI->GetScheme(getter_Copies(protocol)); - if (NS_SUCCEEDED(rv)) { - if (!PL_strcmp(protocol, "chrome") || !PL_strcmp(protocol, "resource")) { - return PR_TRUE; - } - } - + PRBool isChrome = PR_FALSE; + PRBool isResource = PR_FALSE; + if (NS_SUCCEEDED(aURI->SchemeIs(nsIURI::CHROME, &isChrome)) && + NS_SUCCEEDED(aURI->SchemeIs(nsIURI::RESOURCE, &isResource))) + return (isChrome || isResource); return PR_FALSE; } static PRBool IsResourceURI(nsIURI* aURI) { - nsresult rv; - nsXPIDLCString protocol; - rv = aURI->GetScheme(getter_Copies(protocol)); - if (NS_SUCCEEDED(rv)) { - if (!PL_strcmp(protocol, "resource")) { - return PR_TRUE; - } - } - + PRBool isResource = PR_FALSE; + if (NS_SUCCEEDED(aURI->SchemeIs(nsIURI::RESOURCE, &isResource)) && isResource) + return PR_TRUE; return PR_FALSE; } diff --git a/mozilla/mailnews/addrbook/src/nsAddbookUrl.cpp b/mozilla/mailnews/addrbook/src/nsAddbookUrl.cpp index 521d25356f0..59e1ffaf391 100644 --- a/mozilla/mailnews/addrbook/src/nsAddbookUrl.cpp +++ b/mozilla/mailnews/addrbook/src/nsAddbookUrl.cpp @@ -375,6 +375,11 @@ NS_IMETHODIMP nsAddbookUrl::SetPath(const char * aPath) return m_baseURL->SetPath(aPath); } +NS_IMETHODIMP nsAddbookUrl::SchemeIs(PRUint32 aScheme, PRBool *_retval) +{ + return m_baseURL->SchemeIs(aScheme, _retval); +} + NS_IMETHODIMP nsAddbookUrl::Equals(nsIURI *other, PRBool *_retval) { return m_baseURL->Equals(other, _retval); diff --git a/mozilla/mailnews/base/util/nsMsgMailNewsUrl.cpp b/mozilla/mailnews/base/util/nsMsgMailNewsUrl.cpp index 2b6d8d459e7..6609a8540a3 100644 --- a/mozilla/mailnews/base/util/nsMsgMailNewsUrl.cpp +++ b/mozilla/mailnews/base/util/nsMsgMailNewsUrl.cpp @@ -478,6 +478,10 @@ NS_IMETHODIMP nsMsgMailNewsUrl::Equals(nsIURI *other, PRBool *_retval) return m_baseURL->Equals(other, _retval); } +NS_IMETHODIMP nsMsgMailNewsUrl::SchemeIs(PRUint32 aScheme, PRBool *_retval) +{ + return m_baseURL->SchemeIs(aScheme, _retval); +} NS_IMETHODIMP nsMsgMailNewsUrl::Clone(nsIURI **_retval) { diff --git a/mozilla/mailnews/compose/src/nsMsgCompUtils.cpp b/mozilla/mailnews/compose/src/nsMsgCompUtils.cpp index 1627a97a5a0..366c82dd094 100644 --- a/mozilla/mailnews/compose/src/nsMsgCompUtils.cpp +++ b/mozilla/mailnews/compose/src/nsMsgCompUtils.cpp @@ -1799,16 +1799,11 @@ GenerateFileNameFromURI(nsIURI *aURL) if (!hostStr) hostStr = cp2; - nsXPIDLCString protocol; - if (NS_SUCCEEDED(aURL->GetScheme(getter_Copies(protocol))) && (protocol)) + PRBool isHTTP = PR_FALSE; + if (NS_SUCCEEDED(aURL->SchemeIs(nsIURI::HTTP, &isHTTP)) && isHTTP) { - if (PL_strcasecmp(protocol, "http") == 0) - { returnString = PR_smprintf("%s.html", hostStr); PR_FREEIF(hostStr); - } - else - returnString = hostStr; } else returnString = hostStr; diff --git a/mozilla/mailnews/compose/src/nsMsgCopy.cpp b/mozilla/mailnews/compose/src/nsMsgCopy.cpp index 53bb2124aa2..3e53cbf9fa8 100644 --- a/mozilla/mailnews/compose/src/nsMsgCopy.cpp +++ b/mozilla/mailnews/compose/src/nsMsgCopy.cpp @@ -562,7 +562,6 @@ MessageFolderIsLocal(nsIMsgIdentity *userIdentity, PRBool *aResult) { nsresult rv; - nsXPIDLCString scheme; if (!aFolderURI) return NS_ERROR_NULL_POINTER; @@ -573,16 +572,9 @@ MessageFolderIsLocal(nsIMsgIdentity *userIdentity, rv = url->SetSpec(aFolderURI); if (NS_FAILED(rv)) return rv; - rv = url->GetScheme(getter_Copies(scheme)); - if (NS_FAILED(rv)) return rv; - /* mailbox:/ means its local (on disk) */ - if (PL_strcmp("mailbox", (const char *)scheme) == 0) { - *aResult = PR_TRUE; - } - else { - *aResult = PR_FALSE; - } + rv = url->SchemeIs(nsIURI::MAILBOX, aResult); + if (NS_FAILED(rv)) return rv; return NS_OK; } diff --git a/mozilla/mailnews/compose/src/nsSmtpUrl.cpp b/mozilla/mailnews/compose/src/nsSmtpUrl.cpp index 420326f3694..796a5ff633f 100644 --- a/mozilla/mailnews/compose/src/nsSmtpUrl.cpp +++ b/mozilla/mailnews/compose/src/nsSmtpUrl.cpp @@ -378,6 +378,11 @@ NS_IMETHODIMP nsMailtoUrl::SetPath(const char * aPath) return m_baseURL->SetPath(aPath); } +NS_IMETHODIMP nsMailtoUrl::SchemeIs(PRUint32 aScheme, PRBool *_retval) +{ + return m_baseURL->SchemeIs(aScheme, _retval); +} + NS_IMETHODIMP nsMailtoUrl::Equals(nsIURI *other, PRBool *_retval) { return m_baseURL->Equals(other, _retval); diff --git a/mozilla/modules/libimg/src/if.cpp b/mozilla/modules/libimg/src/if.cpp index 174fd10e6c1..34ecff36dc8 100644 --- a/mozilla/modules/libimg/src/if.cpp +++ b/mozilla/modules/libimg/src/if.cpp @@ -1750,16 +1750,12 @@ PRBool il_PermitLoad(const char * image_url, nsIImageRequestObserver * aObserver } /* extract scheme -- we block loading of only http and https images */ - char * scheme; - rv = uri->GetScheme(&scheme); - if (NS_FAILED(rv)) { + PRBool isHTTP = PR_FALSE; + PRBool isHTTPS = PR_FALSE; + if (NS_FAILED(uri->SchemeIs(nsIURI::HTTP, &isHTTP)) || + NS_FAILED(uri->SchemeIs(nsIURI::HTTPS, &isHTTPS)) || + (!isHTTP && !isHTTPS)) return PR_TRUE; - } - if (PL_strcasecmp(scheme, "http") && PL_strcasecmp(scheme, "https")) { - Recycle(scheme); - return PR_TRUE; - } - Recycle(scheme); /* extract host */ char * host; diff --git a/mozilla/modules/libjar/nsJARURI.cpp b/mozilla/modules/libjar/nsJARURI.cpp index ea640fa7da2..447ffc4f530 100644 --- a/mozilla/modules/libjar/nsJARURI.cpp +++ b/mozilla/modules/libjar/nsJARURI.cpp @@ -30,7 +30,8 @@ static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); //////////////////////////////////////////////////////////////////////////////// nsJARURI::nsJARURI() - : mJAREntry(nsnull) + : mJAREntry(nsnull), + mSchemeType(nsIURI::JAR) { NS_INIT_REFCNT(); } @@ -115,6 +116,7 @@ nsJARURI::SetSpec(const char * aSpec) if (nsCRT::strncmp("jar", &aSpec[startPos], endPos - startPos - 1) != 0) return NS_ERROR_MALFORMED_URI; + mSchemeType = nsIURI::JAR; // Search backward from the end for the "!/" delimiter. Remember, jar URLs // can nest, e.g.: // jar:jar:http://www.foo.com/bar.jar!/a.jar!/b.html @@ -274,6 +276,16 @@ nsJARURI::Equals(nsIURI *other, PRBool *result) return NS_OK; } +NS_IMETHODIMP +nsJARURI::SchemeIs(PRUint32 i_Scheme, PRBool *o_Equals) +{ + NS_ENSURE_ARG_POINTER(o_Equals); + if (i_Scheme == nsIURI::UNKNOWN) + return NS_ERROR_INVALID_ARG; + *o_Equals = (mSchemeType == i_Scheme); + return NS_OK; +} + NS_IMETHODIMP nsJARURI::Clone(nsIURI **result) { diff --git a/mozilla/modules/libjar/nsJARURI.h b/mozilla/modules/libjar/nsJARURI.h index fbbc9e96286..d45d56e51e8 100644 --- a/mozilla/modules/libjar/nsJARURI.h +++ b/mozilla/modules/libjar/nsJARURI.h @@ -50,6 +50,7 @@ public: protected: nsCOMPtr mJARFile; char *mJAREntry; + PRUint32 mSchemeType; }; #endif // nsJARURI_h__ diff --git a/mozilla/netwerk/base/public/nsIURI.idl b/mozilla/netwerk/base/public/nsIURI.idl index 284344fcb64..26cbc516be5 100644 --- a/mozilla/netwerk/base/public/nsIURI.idl +++ b/mozilla/netwerk/base/public/nsIURI.idl @@ -17,6 +17,8 @@ * Copyright (C) 1998 Netscape Communications Corporation. All * Rights Reserved. * + * Original Author: Gagan Saksena + * * Contributor(s): */ @@ -60,6 +62,25 @@ [scriptable, uuid(07a22cc0-0ce5-11d3-9331-00104ba0fd40)] interface nsIURI : nsISupports { + /** + * List of standard/known URL scheme types for quicker lookups and + * comparisons. The UNKNOWN type applies for all other cases. + */ + const PRUint32 UNKNOWN = 0; + const PRUint32 ABOUT = 1; + const PRUint32 CHROME = 2; + const PRUint32 FILE = 3; + const PRUint32 FTP = 4; + const PRUint32 HTTP = 5; + const PRUint32 HTTPS = 6; + const PRUint32 IMAP = 7; + const PRUint32 JAR = 8; + const PRUint32 JAVASCRIPT = 9; + const PRUint32 MAILBOX = 10; + const PRUint32 MAILTO = 11; + const PRUint32 NEWS = 12; + const PRUint32 RESOURCE = 13; + /** * Returns a string representation of the URI. Setting the spec * causes the new spec to be parsed, initializing the URI. Setting @@ -128,6 +149,15 @@ interface nsIURI : nsISupports */ boolean equals(in nsIURI other); + /** + * An optimization to do scheme checks without requiring the users of nsIURI + * to GetScheme thereby saving extra allocating and freeing. Returns true if + * the schemes match (case ignored) to one of the standard known types + * mentioned above. Note that for unknown cases this will always return + * false. + */ + boolean schemeIs(in PRUint32 scheme); + /** * Clones the current URI. The newly created URI will be in a closed * state even if the underlying channel of the cloned URI is open. diff --git a/mozilla/netwerk/base/public/nsIURL.idl b/mozilla/netwerk/base/public/nsIURL.idl index 502800e8eb3..cfe3e2077a0 100644 --- a/mozilla/netwerk/base/public/nsIURL.idl +++ b/mozilla/netwerk/base/public/nsIURL.idl @@ -17,6 +17,8 @@ * Copyright (C) 1998 Netscape Communications Corporation. All * Rights Reserved. * + * Original Author: Gagan Saksena + * * Contributor(s): */ diff --git a/mozilla/netwerk/base/src/nsSimpleURI.cpp b/mozilla/netwerk/base/src/nsSimpleURI.cpp index 5e79551bb14..3bed4028fc1 100644 --- a/mozilla/netwerk/base/src/nsSimpleURI.cpp +++ b/mozilla/netwerk/base/src/nsSimpleURI.cpp @@ -19,6 +19,7 @@ * * Contributor(s): * Pierre Phaneuf + * Gagan Saksena */ #include "nsSimpleURI.h" @@ -40,7 +41,8 @@ static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); nsSimpleURI::nsSimpleURI(nsISupports* outer) : mScheme(nsnull), - mPath(nsnull) + mPath(nsnull), + mSchemeType(nsIURI::UNKNOWN) { NS_INIT_AGGREGATED(outer); } @@ -246,6 +248,16 @@ nsSimpleURI::Equals(nsIURI* other, PRBool *result) return NS_OK; } +NS_IMETHODIMP +nsSimpleURI::SchemeIs(PRUint32 i_Scheme, PRBool *o_Equals) +{ + NS_ENSURE_ARG_POINTER(o_Equals); + if (i_Scheme == nsIURI::UNKNOWN) + return NS_ERROR_INVALID_ARG; + *o_Equals = (mSchemeType == i_Scheme); + return NS_OK; +} + NS_IMETHODIMP nsSimpleURI::Clone(nsIURI* *result) { diff --git a/mozilla/netwerk/base/src/nsSimpleURI.h b/mozilla/netwerk/base/src/nsSimpleURI.h index b68a2470b19..1f22d33abda 100644 --- a/mozilla/netwerk/base/src/nsSimpleURI.h +++ b/mozilla/netwerk/base/src/nsSimpleURI.h @@ -51,6 +51,7 @@ public: protected: char* mScheme; char* mPath; + PRUint32 mSchemeType; }; #endif // nsSimpleURI_h__ diff --git a/mozilla/netwerk/base/src/nsStdURL.cpp b/mozilla/netwerk/base/src/nsStdURL.cpp index 2977a0481b3..ce842465202 100644 --- a/mozilla/netwerk/base/src/nsStdURL.cpp +++ b/mozilla/netwerk/base/src/nsStdURL.cpp @@ -17,6 +17,8 @@ * Copyright (C) 1998 Netscape Communications Corporation. All * Rights Reserved. * + * Original Author: Gagan Saksena + * * Contributor(s): */ @@ -115,7 +117,8 @@ nsStdURL::nsStdURL(nsISupports* outer) mParam(nsnull), mQuery(nsnull), mRef(nsnull), - mDefaultPort(-1) + mDefaultPort(-1), + mSchemeType(nsIURI::UNKNOWN) { NS_INIT_AGGREGATED(outer); InitGlobalObjects(); @@ -172,6 +175,7 @@ nsStdURL::nsStdURL(const nsStdURL& otherURL) mQuery = otherURL.mQuery ? nsCRT::strdup(otherURL.mQuery) : nsnull; mRef= otherURL.mRef ? nsCRT::strdup(otherURL.mRef) : nsnull; mURLParser = otherURL.mURLParser; + mSchemeType = otherURL.mSchemeType; NS_INIT_AGGREGATED(nsnull); // Todo! How? } @@ -190,6 +194,7 @@ nsStdURL::operator=(const nsStdURL& otherURL) mQuery = otherURL.mQuery ? nsCRT::strdup(otherURL.mQuery) : nsnull; mRef= otherURL.mRef ? nsCRT::strdup(otherURL.mRef) : nsnull; mURLParser = otherURL.mURLParser; + mSchemeType = otherURL.mSchemeType; NS_INIT_AGGREGATED(nsnull); // Todo! How? return *this; @@ -299,6 +304,16 @@ nsStdURL::Equals(nsIURI *i_OtherURI, PRBool *o_Equals) return NS_OK; } +NS_IMETHODIMP +nsStdURL::SchemeIs(PRUint32 i_Scheme, PRBool *o_Equals) +{ + NS_ENSURE_ARG_POINTER(o_Equals); + if (i_Scheme == nsIURI::UNKNOWN) + return NS_ERROR_INVALID_ARG; + *o_Equals = (mSchemeType == i_Scheme); + return NS_OK; +} + NS_IMETHODIMP nsStdURL::Clone(nsIURI **o_URI) { @@ -328,6 +343,36 @@ nsStdURL::Parse(const char* i_Spec) nsresult rv = mURLParser->ParseAtScheme(i_Spec, &mScheme, &mUsername, &mPassword, &mHost, &mPort, &ePath); + + if (0 == PL_strcasecmp("about", mScheme)) + mSchemeType = nsIURI::ABOUT; + else if (0 == PL_strcasecmp("chrome", mScheme)) + mSchemeType = nsIURI::CHROME; + else if (0 == PL_strcasecmp("file", mScheme)) + mSchemeType = nsIURI::FILE; + else if (0 == PL_strcasecmp("ftp", mScheme)) + mSchemeType = nsIURI::FTP; + else if (0 == PL_strcasecmp("http", mScheme)) + mSchemeType = nsIURI::HTTP; + else if (0 == PL_strcasecmp("https", mScheme)) + mSchemeType = nsIURI::HTTPS; + else if (0 == PL_strcasecmp("imap", mScheme)) + mSchemeType = nsIURI::IMAP; + else if (0 == PL_strcasecmp("jar", mScheme)) + mSchemeType = nsIURI::JAR; + else if (0 == PL_strcasecmp("javascript", mScheme)) + mSchemeType = nsIURI::JAVASCRIPT; + else if (0 == PL_strcasecmp("mailbox", mScheme)) + mSchemeType = nsIURI::MAILBOX; + else if (0 == PL_strcasecmp("mailto", mScheme)) + mSchemeType = nsIURI::MAILTO; + else if (0 == PL_strcasecmp("news", mScheme)) + mSchemeType = nsIURI::NEWS; + else if (0 == PL_strcasecmp("resource", mScheme)) + mSchemeType = nsIURI::RESOURCE; + else + mSchemeType = nsIURI::UNKNOWN; + if (NS_SUCCEEDED(rv)) { // Now parse the path rv = mURLParser->ParseAtDirectory(ePath, &mDirectory, &mFileBaseName, diff --git a/mozilla/netwerk/base/src/nsStdURL.h b/mozilla/netwerk/base/src/nsStdURL.h index ad0dd74a42b..4aab0b1e2cf 100644 --- a/mozilla/netwerk/base/src/nsStdURL.h +++ b/mozilla/netwerk/base/src/nsStdURL.h @@ -96,7 +96,10 @@ protected: char* mRef; nsCOMPtr mURLParser; - PRInt32 mDefaultPort; // port for protocol (used for canonicalizing, and printing) + PRInt32 mDefaultPort; // port for protocol (used for canonicalizing, + // and printing) + PRUint32 mSchemeType; + // Global objects. Dont use comptr as its destructor will cause // a coredump if we leak it. diff --git a/mozilla/netwerk/protocol/http/Makefile.in b/mozilla/netwerk/protocol/http/Makefile.in index 8e79579887a..16e3d52fc8f 100644 --- a/mozilla/netwerk/protocol/http/Makefile.in +++ b/mozilla/netwerk/protocol/http/Makefile.in @@ -16,6 +16,8 @@ # Copyright (C) 1998 Netscape Communications Corporation. All # Rights Reserved. # +# Original Author: Gagan Saksena +# # Contributor(s): # diff --git a/mozilla/netwerk/protocol/http/makefile.win b/mozilla/netwerk/protocol/http/makefile.win index 6087cbfe1af..cde535ff512 100644 --- a/mozilla/netwerk/protocol/http/makefile.win +++ b/mozilla/netwerk/protocol/http/makefile.win @@ -17,6 +17,8 @@ # Copyright (C) 1998 Netscape Communications Corporation. All # Rights Reserved. # +# Original Author: Gagan Saksena +# # Contributor(s): #------------------------------------------------------------------------ diff --git a/mozilla/netwerk/protocol/http/public/nsHTTPEnums.h b/mozilla/netwerk/protocol/http/public/nsHTTPEnums.h index d6457aebadd..77381242a41 100644 --- a/mozilla/netwerk/protocol/http/public/nsHTTPEnums.h +++ b/mozilla/netwerk/protocol/http/public/nsHTTPEnums.h @@ -18,6 +18,8 @@ * Rights Reserved. * * Contributor(s): + * Gagan Saksena + * */ #ifndef _nsHTTPEnums_h_ diff --git a/mozilla/netwerk/protocol/http/public/nsIHTTPChannel.idl b/mozilla/netwerk/protocol/http/public/nsIHTTPChannel.idl index 770f78d7b24..99cedbf944d 100644 --- a/mozilla/netwerk/protocol/http/public/nsIHTTPChannel.idl +++ b/mozilla/netwerk/protocol/http/public/nsIHTTPChannel.idl @@ -17,6 +17,8 @@ * Copyright (C) 1998 Netscape Communications Corporation. All * Rights Reserved. * + * Original Author: Gagan Saksena + * * Contributor(s): */ diff --git a/mozilla/netwerk/protocol/http/public/nsIHTTPEventSink.idl b/mozilla/netwerk/protocol/http/public/nsIHTTPEventSink.idl index 566bc0094ef..e9bffd39de2 100644 --- a/mozilla/netwerk/protocol/http/public/nsIHTTPEventSink.idl +++ b/mozilla/netwerk/protocol/http/public/nsIHTTPEventSink.idl @@ -17,6 +17,8 @@ * Copyright (C) 1998 Netscape Communications Corporation. All * Rights Reserved. * + * Original Author: Gagan Saksena + * * Contributor(s): */ diff --git a/mozilla/netwerk/protocol/http/public/nsIHTTPHeader.idl b/mozilla/netwerk/protocol/http/public/nsIHTTPHeader.idl index db831f4fd1f..dfa72d80e8e 100644 --- a/mozilla/netwerk/protocol/http/public/nsIHTTPHeader.idl +++ b/mozilla/netwerk/protocol/http/public/nsIHTTPHeader.idl @@ -17,6 +17,8 @@ * Copyright (C) 1998 Netscape Communications Corporation. All * Rights Reserved. * + * Original Author: Gagan Saksena + * * Contributor(s): */ diff --git a/mozilla/netwerk/protocol/http/public/nsIHTTPProtocolHandler.idl b/mozilla/netwerk/protocol/http/public/nsIHTTPProtocolHandler.idl index 00620b9b4da..f7fe8cdeb86 100644 --- a/mozilla/netwerk/protocol/http/public/nsIHTTPProtocolHandler.idl +++ b/mozilla/netwerk/protocol/http/public/nsIHTTPProtocolHandler.idl @@ -17,6 +17,8 @@ * Copyright (C) 1998 Netscape Communications Corporation. All * Rights Reserved. * + * Original Author: Gagan Saksena + * * Contributor(s): */ diff --git a/mozilla/netwerk/protocol/http/public/nsIHttpNotify.idl b/mozilla/netwerk/protocol/http/public/nsIHttpNotify.idl index 7ad8ec30729..564e1bda048 100644 --- a/mozilla/netwerk/protocol/http/public/nsIHttpNotify.idl +++ b/mozilla/netwerk/protocol/http/public/nsIHttpNotify.idl @@ -18,6 +18,8 @@ * Rights Reserved. * * Contributor(s): + * Gagan Saksena + * */ /* The internal networking library http interface. External modules diff --git a/mozilla/netwerk/protocol/http/src/nsAuth.cpp b/mozilla/netwerk/protocol/http/src/nsAuth.cpp index 8f567afd531..d50508e15f8 100644 --- a/mozilla/netwerk/protocol/http/src/nsAuth.cpp +++ b/mozilla/netwerk/protocol/http/src/nsAuth.cpp @@ -17,6 +17,8 @@ * Copyright (C) 1998 Netscape Communications Corporation. All * Rights Reserved. * + * Original Author: Gagan Saksena + * * Contributor(s): */ diff --git a/mozilla/netwerk/protocol/http/src/nsAuth.h b/mozilla/netwerk/protocol/http/src/nsAuth.h index 1d7e1622537..dff3939c79d 100644 --- a/mozilla/netwerk/protocol/http/src/nsAuth.h +++ b/mozilla/netwerk/protocol/http/src/nsAuth.h @@ -17,6 +17,8 @@ * Copyright (C) 1998 Netscape Communications Corporation. All * Rights Reserved. * + * Original Author: Gagan Saksena + * * Contributor(s): */ diff --git a/mozilla/netwerk/protocol/http/src/nsAuthEngine.cpp b/mozilla/netwerk/protocol/http/src/nsAuthEngine.cpp index fbe15e6bf28..ff76695a5a3 100644 --- a/mozilla/netwerk/protocol/http/src/nsAuthEngine.cpp +++ b/mozilla/netwerk/protocol/http/src/nsAuthEngine.cpp @@ -17,6 +17,8 @@ * Copyright (C) 1998 Netscape Communications Corporation. All * Rights Reserved. * + * Original Author: Gagan Saksena + * * Contributor(s): */ diff --git a/mozilla/netwerk/protocol/http/src/nsAuthEngine.h b/mozilla/netwerk/protocol/http/src/nsAuthEngine.h index 564f5c87710..47a749a49c5 100644 --- a/mozilla/netwerk/protocol/http/src/nsAuthEngine.h +++ b/mozilla/netwerk/protocol/http/src/nsAuthEngine.h @@ -17,6 +17,8 @@ * Copyright (C) 1998 Netscape Communications Corporation. All * Rights Reserved. * + * Original Author: Gagan Saksena + * * Contributor(s): */ diff --git a/mozilla/netwerk/protocol/http/src/nsBasicAuth.cpp b/mozilla/netwerk/protocol/http/src/nsBasicAuth.cpp index 1eb028a2d45..cd21e260af1 100644 --- a/mozilla/netwerk/protocol/http/src/nsBasicAuth.cpp +++ b/mozilla/netwerk/protocol/http/src/nsBasicAuth.cpp @@ -17,6 +17,8 @@ * Copyright (C) 1998 Netscape Communications Corporation. All * Rights Reserved. * + * Original Author: Gagan Saksena + * * Contributor(s): * Mike Shaver * Christopher Blizzard diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPAtomList.h b/mozilla/netwerk/protocol/http/src/nsHTTPAtomList.h index bcb01981b1e..7a082aca7e7 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPAtomList.h +++ b/mozilla/netwerk/protocol/http/src/nsHTTPAtomList.h @@ -18,6 +18,7 @@ * Rights Reserved. * * Contributor(s): + * Gagan Saksena */ /****** diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPAtoms.cpp b/mozilla/netwerk/protocol/http/src/nsHTTPAtoms.cpp index f217efa4987..539a0a3671b 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPAtoms.cpp +++ b/mozilla/netwerk/protocol/http/src/nsHTTPAtoms.cpp @@ -18,6 +18,7 @@ * Rights Reserved. * * Contributor(s): + * Gagan Saksena */ #include "nsHTTPAtoms.h" diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPAtoms.h b/mozilla/netwerk/protocol/http/src/nsHTTPAtoms.h index 695c7f0b651..01964577864 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPAtoms.h +++ b/mozilla/netwerk/protocol/http/src/nsHTTPAtoms.h @@ -18,6 +18,7 @@ * Rights Reserved. * * Contributor(s): + * Gagan Saksena */ #ifndef nsHTTPAtoms_h___ #define nsHTTPAtoms_h___ diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPChannel.cpp b/mozilla/netwerk/protocol/http/src/nsHTTPChannel.cpp index 74694a5183f..62f55a09a87 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPChannel.cpp +++ b/mozilla/netwerk/protocol/http/src/nsHTTPChannel.cpp @@ -17,6 +17,8 @@ * Copyright (C) 1998 Netscape Communications Corporation. All * Rights Reserved. * + * Original Author: Gagan Saksena + * * Contributor(s): * Pierre Phaneuf * Mike Shaver @@ -116,9 +118,8 @@ nsHTTPChannel::nsHTTPChannel(nsIURI* i_URL, nsHTTPHandler* i_Handler): ("Creating nsHTTPChannel [this=%x] for URI: %s.\n", this, (const char *)urlCString)); #endif - nsXPIDLCString scheme; - mURI->GetScheme(getter_Copies(scheme)); - if ( 0 == PL_strncasecmp((const char*)scheme, "https", 5) ) + PRBool isHTTPS=PR_FALSE; + if (NS_SUCCEEDED(mURI->SchemeIs(nsIURI::HTTPS, &isHTTPS)) && isHTTPS) mLoadAttributes |= nsIChannel::INHIBIT_PERSISTENT_CACHING; } diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPChannel.h b/mozilla/netwerk/protocol/http/src/nsHTTPChannel.h index 6acb820d80a..f68b7c5ccec 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPChannel.h +++ b/mozilla/netwerk/protocol/http/src/nsHTTPChannel.h @@ -17,6 +17,8 @@ * Copyright (C) 1998 Netscape Communications Corporation. All * Rights Reserved. * + * Original Author: Gagan Saksena + * * Contributor(s): */ diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPHandler.cpp b/mozilla/netwerk/protocol/http/src/nsHTTPHandler.cpp index b764a59ea80..34b26675e02 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPHandler.cpp +++ b/mozilla/netwerk/protocol/http/src/nsHTTPHandler.cpp @@ -17,6 +17,8 @@ * Copyright (C) 1998 Netscape Communications Corporation. All * Rights Reserved. * + * Original Author: Gagan Saksena + * * Contributor(s): * Pierre Phaneuf * Christopher Blizzard @@ -196,19 +198,14 @@ nsHTTPHandler::NewChannel(nsIURI* i_URL, nsIChannel **o_Instance) { nsresult rv; nsHTTPChannel* pChannel = nsnull; - nsXPIDLCString scheme; - nsXPIDLCString handlerScheme; // Initial checks... if (!i_URL || !o_Instance) { return NS_ERROR_NULL_POINTER; } - i_URL->GetScheme(getter_Copies(scheme)); - GetScheme(getter_Copies(handlerScheme)); - - if (scheme != nsnull && handlerScheme != nsnull && - 0 == PL_strcasecmp(scheme, handlerScheme)) + PRBool isHTTP = PR_FALSE; + if (NS_SUCCEEDED(i_URL->SchemeIs(nsIURI::HTTP, &isHTTP)) && isHTTP) { // Check for filtering nsCOMPtr filters = diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPHandler.h b/mozilla/netwerk/protocol/http/src/nsHTTPHandler.h index 081b354fbbb..773e5e5ac4d 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPHandler.h +++ b/mozilla/netwerk/protocol/http/src/nsHTTPHandler.h @@ -17,6 +17,8 @@ * Copyright (C) 1998 Netscape Communications Corporation. All * Rights Reserved. * + * Original Author: Gagan Saksena + * * Contributor(s): */ diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPHandlerModule.cpp b/mozilla/netwerk/protocol/http/src/nsHTTPHandlerModule.cpp index 032b0d57432..aaf03704fc2 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPHandlerModule.cpp +++ b/mozilla/netwerk/protocol/http/src/nsHTTPHandlerModule.cpp @@ -18,6 +18,7 @@ * Rights Reserved. * * Contributor(s): + * Gagan Saksena */ #include "nsIGenericFactory.h" #include "nsIServiceManager.h" diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPHeaderArray.cpp b/mozilla/netwerk/protocol/http/src/nsHTTPHeaderArray.cpp index a4079dc4bc2..c26ddd4764b 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPHeaderArray.cpp +++ b/mozilla/netwerk/protocol/http/src/nsHTTPHeaderArray.cpp @@ -18,6 +18,8 @@ * Rights Reserved. * * Contributor(s): + * Gagan Saksena + * */ diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPHeaderArray.h b/mozilla/netwerk/protocol/http/src/nsHTTPHeaderArray.h index 2eb9fef8b10..8e82221dab1 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPHeaderArray.h +++ b/mozilla/netwerk/protocol/http/src/nsHTTPHeaderArray.h @@ -17,6 +17,8 @@ * Copyright (C) 1998 Netscape Communications Corporation. All * Rights Reserved. * + * Original Author: Gagan Saksena + * * Contributor(s): */ diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPRequest.cpp b/mozilla/netwerk/protocol/http/src/nsHTTPRequest.cpp index f1bfe18e837..fd2ee5015a7 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPRequest.cpp +++ b/mozilla/netwerk/protocol/http/src/nsHTTPRequest.cpp @@ -17,6 +17,8 @@ * Copyright (C) 1998 Netscape Communications Corporation. All * Rights Reserved. * + * Original Author: Gagan Saksena + * * Contributor(s): */ diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPRequest.h b/mozilla/netwerk/protocol/http/src/nsHTTPRequest.h index 9ed66e7101b..9540e0c295f 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPRequest.h +++ b/mozilla/netwerk/protocol/http/src/nsHTTPRequest.h @@ -17,6 +17,8 @@ * Copyright (C) 1998 Netscape Communications Corporation. All * Rights Reserved. * + * Original Author: Gagan Saksena + * * Contributor(s): */ diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPResponse.cpp b/mozilla/netwerk/protocol/http/src/nsHTTPResponse.cpp index d35e8ca0837..9a3b8062ed9 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPResponse.cpp +++ b/mozilla/netwerk/protocol/http/src/nsHTTPResponse.cpp @@ -17,6 +17,8 @@ * Copyright (C) 1998 Netscape Communications Corporation. All * Rights Reserved. * + * Original Author: Gagan Saksena + * * Contributor(s): */ diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPResponse.h b/mozilla/netwerk/protocol/http/src/nsHTTPResponse.h index 9b1e18eb612..80fd996555c 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPResponse.h +++ b/mozilla/netwerk/protocol/http/src/nsHTTPResponse.h @@ -17,6 +17,8 @@ * Copyright (C) 1998 Netscape Communications Corporation. All * Rights Reserved. * + * Original Author: Gagan Saksena + * * Contributor(s): */ diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPResponseListener.cpp b/mozilla/netwerk/protocol/http/src/nsHTTPResponseListener.cpp index 9970b1fe959..0a478c2af4d 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPResponseListener.cpp +++ b/mozilla/netwerk/protocol/http/src/nsHTTPResponseListener.cpp @@ -17,6 +17,8 @@ * Copyright (C) 1998 Netscape Communications Corporation. All * Rights Reserved. * + * Original Author: Gagan Saksena + * * Contributor(s): */ diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPResponseListener.h b/mozilla/netwerk/protocol/http/src/nsHTTPResponseListener.h index 81468ab1f03..88ea87defc4 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPResponseListener.h +++ b/mozilla/netwerk/protocol/http/src/nsHTTPResponseListener.h @@ -17,6 +17,8 @@ * Copyright (C) 1998 Netscape Communications Corporation. All * Rights Reserved. * + * Original Author: Gagan Saksena + * * Contributor(s): */ diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPSHandler.cpp b/mozilla/netwerk/protocol/http/src/nsHTTPSHandler.cpp index 0a8f531763b..06e10c95173 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPSHandler.cpp +++ b/mozilla/netwerk/protocol/http/src/nsHTTPSHandler.cpp @@ -18,6 +18,7 @@ * Rights Reserved. * * Contributor(s): + * Gagan Saksena */ #include "nspr.h" diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPSHandler.h b/mozilla/netwerk/protocol/http/src/nsHTTPSHandler.h index 3394e36bb5e..9b4ec14c3d3 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPSHandler.h +++ b/mozilla/netwerk/protocol/http/src/nsHTTPSHandler.h @@ -18,6 +18,7 @@ * Rights Reserved. * * Contributor(s): + * Gagan Saksena */ #ifndef _nsHTTPSHandler_h_ diff --git a/mozilla/netwerk/protocol/jar/src/nsJARURI.cpp b/mozilla/netwerk/protocol/jar/src/nsJARURI.cpp index ea640fa7da2..447ffc4f530 100644 --- a/mozilla/netwerk/protocol/jar/src/nsJARURI.cpp +++ b/mozilla/netwerk/protocol/jar/src/nsJARURI.cpp @@ -30,7 +30,8 @@ static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); //////////////////////////////////////////////////////////////////////////////// nsJARURI::nsJARURI() - : mJAREntry(nsnull) + : mJAREntry(nsnull), + mSchemeType(nsIURI::JAR) { NS_INIT_REFCNT(); } @@ -115,6 +116,7 @@ nsJARURI::SetSpec(const char * aSpec) if (nsCRT::strncmp("jar", &aSpec[startPos], endPos - startPos - 1) != 0) return NS_ERROR_MALFORMED_URI; + mSchemeType = nsIURI::JAR; // Search backward from the end for the "!/" delimiter. Remember, jar URLs // can nest, e.g.: // jar:jar:http://www.foo.com/bar.jar!/a.jar!/b.html @@ -274,6 +276,16 @@ nsJARURI::Equals(nsIURI *other, PRBool *result) return NS_OK; } +NS_IMETHODIMP +nsJARURI::SchemeIs(PRUint32 i_Scheme, PRBool *o_Equals) +{ + NS_ENSURE_ARG_POINTER(o_Equals); + if (i_Scheme == nsIURI::UNKNOWN) + return NS_ERROR_INVALID_ARG; + *o_Equals = (mSchemeType == i_Scheme); + return NS_OK; +} + NS_IMETHODIMP nsJARURI::Clone(nsIURI **result) { diff --git a/mozilla/netwerk/protocol/jar/src/nsJARURI.h b/mozilla/netwerk/protocol/jar/src/nsJARURI.h index fbbc9e96286..d45d56e51e8 100644 --- a/mozilla/netwerk/protocol/jar/src/nsJARURI.h +++ b/mozilla/netwerk/protocol/jar/src/nsJARURI.h @@ -50,6 +50,7 @@ public: protected: nsCOMPtr mJARFile; char *mJAREntry; + PRUint32 mSchemeType; }; #endif // nsJARURI_h__ diff --git a/mozilla/netwerk/streamconv/converters/nsUnknownDecoder.cpp b/mozilla/netwerk/streamconv/converters/nsUnknownDecoder.cpp index 0d354f1a5fe..a9b1f39b4d2 100644 --- a/mozilla/netwerk/streamconv/converters/nsUnknownDecoder.cpp +++ b/mozilla/netwerk/streamconv/converters/nsUnknownDecoder.cpp @@ -278,16 +278,8 @@ void nsUnknownDecoder::DetermineContentType(nsIChannel *aChannel) PRBool isLocalFile = PR_FALSE; if (aChannel) { nsCOMPtr pURL; - nsresult rv = aChannel->GetURI(getter_AddRefs(pURL)); - if (NS_SUCCEEDED(rv)) { - nsXPIDLCString protocol; - rv = pURL->GetScheme(getter_Copies(protocol)); - if (NS_SUCCEEDED(rv)) { - if (!PL_strcasecmp(protocol, "file")) { - isLocalFile = PR_TRUE; - } - } - } + if (NS_SUCCEEDED(aChannel->GetURI(getter_AddRefs(pURL)))) + pURL->SchemeIs(nsIURI::FILE, &isLocalFile); } if (!mRequireHTMLsuffix || !isLocalFile) { diff --git a/mozilla/parser/htmlparser/src/nsExpatTokenizer.cpp b/mozilla/parser/htmlparser/src/nsExpatTokenizer.cpp index 8dad05d59c0..fcbdb3438cd 100644 --- a/mozilla/parser/htmlparser/src/nsExpatTokenizer.cpp +++ b/mozilla/parser/htmlparser/src/nsExpatTokenizer.cpp @@ -63,7 +63,6 @@ typedef struct _XMLParserState { static NS_DEFINE_IID(kHTMLTokenizerIID, NS_HTMLTOKENIZER_IID); static NS_DEFINE_IID(kClassIID, NS_EXPATTOKENIZER_IID); -static const char* kChromeProtocol = "chrome"; static const char* kDTDDirectory = "dtd/"; static const char kHTMLNameSpaceURI[] = "http://www.w3.org/1999/xhtml"; @@ -718,7 +717,6 @@ void nsExpatTokenizer::HandleUnparsedEntityDecl(void *userData, static PRBool IsLoadableDTD(nsCOMPtr* aDTD) { - char* scheme = nsnull; PRBool isLoadable = PR_FALSE; nsresult res = NS_OK; @@ -728,12 +726,7 @@ IsLoadableDTD(nsCOMPtr* aDTD) } // Return true if the url is a chrome url - res = (*aDTD)->GetScheme(&scheme); - if (NS_SUCCEEDED(res) && nsnull != scheme) { - if (PL_strcmp(scheme, kChromeProtocol) == 0) - isLoadable = PR_TRUE; - nsCRT::free(scheme); - } + res = (*aDTD)->SchemeIs(nsIURI::CHROME, &isLoadable); // If the url is not a chrome url, check to see if a DTD file of the same name // exists in the special DTD directory diff --git a/mozilla/rdf/chrome/src/nsChromeRegistry.cpp b/mozilla/rdf/chrome/src/nsChromeRegistry.cpp index 2d80b9ca2a1..b00d5e22619 100644 --- a/mozilla/rdf/chrome/src/nsChromeRegistry.cpp +++ b/mozilla/rdf/chrome/src/nsChromeRegistry.cpp @@ -20,6 +20,7 @@ * Original Author: David W. Hyatt (hyatt@netscape.com) * * Contributor(s): + * Gagan Saksena */ #include @@ -1079,16 +1080,10 @@ NS_IMETHODIMP nsChromeRegistry::RefreshSkins() static PRBool IsChromeURI(nsIURI* aURI) { - nsresult rv; - nsXPIDLCString protocol; - rv = aURI->GetScheme(getter_Copies(protocol)); - if (NS_SUCCEEDED(rv)) { - if (PL_strcmp(protocol, "chrome") == 0) { + PRBool isChrome=PR_FALSE; + if (NS_SUCCEEDED(aURI->SchemeIs(nsIURI::CHROME, &isChrome)) && isChrome) return PR_TRUE; - } - } - - return PR_FALSE; + return PR_FALSE; } NS_IMETHODIMP nsChromeRegistry::RefreshWindow(nsIDOMWindowInternal* aWindow) diff --git a/mozilla/rdf/content/src/nsXULDocument.cpp b/mozilla/rdf/content/src/nsXULDocument.cpp index 83c5616582c..98ba666eae5 100644 --- a/mozilla/rdf/content/src/nsXULDocument.cpp +++ b/mozilla/rdf/content/src/nsXULDocument.cpp @@ -165,6 +165,15 @@ static NS_DEFINE_CID(kRangeCID, NS_RANGE_CID); static NS_DEFINE_IID(kIParserIID, NS_IPARSER_IID); +static PRBool IsChromeURI(nsIURI* aURI) +{ + // why is this check a member function of nsXULDocument? -gagan + PRBool isChrome=PR_FALSE; + if (NS_SUCCEEDED(aURI->SchemeIs(nsIURI::CHROME, &isChrome)) && isChrome) + return PR_TRUE; + return PR_FALSE; +} + //---------------------------------------------------------------------- // // Miscellaneous Constants @@ -6378,20 +6387,6 @@ nsXULDocument::RemoveElement(nsIContent* aParent, nsIContent* aChild) -PRBool -nsXULDocument::IsChromeURI(nsIURI* aURI) -{ - nsresult rv; - nsXPIDLCString protocol; - rv = aURI->GetScheme(getter_Copies(protocol)); - if (NS_SUCCEEDED(rv)) { - if (PL_strcmp(protocol, "chrome") == 0) { - return PR_TRUE; - } - } - - return PR_FALSE; -} void nsXULDocument::GetElementFactory(PRInt32 aNameSpaceID, nsIElementFactory** aResult) diff --git a/mozilla/rdf/content/src/nsXULDocument.h b/mozilla/rdf/content/src/nsXULDocument.h index 61ecfe3e6ca..3a83bb3cfad 100644 --- a/mozilla/rdf/content/src/nsXULDocument.h +++ b/mozilla/rdf/content/src/nsXULDocument.h @@ -725,10 +725,6 @@ protected: nsresult RemoveElement(nsIContent* aParent, nsIContent* aChild); - static - PRBool - IsChromeURI(nsIURI* aURI); - /** * The current prototype that we are walking to construct the * content model.