Optimization for scheme comparison of URIs. See bug 66577 for details. r=darin, sr=brendan@mozilla.org

git-svn-id: svn://10.0.0.236/trunk@85797 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
gagan%netscape.com 2001-01-31 01:33:03 +00:00
parent 960e43639c
commit f3f5b36700
73 changed files with 356 additions and 237 deletions

View File

@ -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;

View File

@ -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)))

View File

@ -20,6 +20,7 @@
* Original Author: David W. Hyatt (hyatt@netscape.com)
*
* Contributor(s):
* Gagan Saksena <gagan@netscape.com>
*/
#include <string.h>
@ -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)

View File

@ -804,10 +804,13 @@ nsDocument::Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup)
nsCOMPtr<nsIURI> 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<nsIDOMNode> 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);

View File

@ -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<nsIDocument> document;
mHandlerElement->GetDocument(*getter_AddRefs(document));
nsCOMPtr<nsIURI> 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.

View File

@ -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;
}

View File

@ -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)

View File

@ -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.

View File

@ -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<nsIDocShellTreeItem> targetDocShell;
@ -3328,9 +3328,7 @@ NS_IMETHODIMP nsDocShell::DoURILoad(nsIURI* aURI, nsIURI* aReferrerURI,
nsCOMPtr<nsIStreamIOChannel> 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;
}

View File

@ -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<nsIFileURL> 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<nsIFile> pageFile;
pageFileURL->GetFile(getter_AddRefs(pageFile));

View File

@ -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<nsIFileURL> 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<nsIFile> pageFile;
pageFileURL->GetFile(getter_AddRefs(pageFile));

View File

@ -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;

View File

@ -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<nsIURI>* aDTD)
{
char* scheme = nsnull;
PRBool isLoadable = PR_FALSE;
nsresult res = NS_OK;
@ -728,12 +726,7 @@ IsLoadableDTD(nsCOMPtr<nsIURI>* 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

View File

@ -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) {

View File

@ -804,10 +804,13 @@ nsDocument::Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup)
nsCOMPtr<nsIURI> 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<nsIDOMNode> 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);

View File

@ -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) {

View File

@ -423,12 +423,12 @@ nsIsIndexFrame::OnSubmit(nsIPresContext* aPresContext)
// Get the scheme of the URI.
nsCOMPtr<nsIURI> 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

View File

@ -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;
}

View File

@ -423,12 +423,12 @@ nsIsIndexFrame::OnSubmit(nsIPresContext* aPresContext)
// Get the scheme of the URI.
nsCOMPtr<nsIURI> 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

View File

@ -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<nsIDocument> document;
mHandlerElement->GetDocument(*getter_AddRefs(document));
nsCOMPtr<nsIURI> 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.

View File

@ -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;
}

View File

@ -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);

View File

@ -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)
{

View File

@ -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;

View File

@ -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;
}

View File

@ -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);

View File

@ -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;

View File

@ -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)
{

View File

@ -50,6 +50,7 @@ public:
protected:
nsCOMPtr<nsIURI> mJARFile;
char *mJAREntry;
PRUint32 mSchemeType;
};
#endif // nsJARURI_h__

View File

@ -17,6 +17,8 @@
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Original Author: Gagan Saksena <gagan@netscape.com>
*
* 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.

View File

@ -17,6 +17,8 @@
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Original Author: Gagan Saksena <gagan@netscape.com>
*
* Contributor(s):
*/

View File

@ -19,6 +19,7 @@
*
* Contributor(s):
* Pierre Phaneuf <pp@ludusdesign.com>
* Gagan Saksena <gagan@netscape.com>
*/
#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)
{

View File

@ -51,6 +51,7 @@ public:
protected:
char* mScheme;
char* mPath;
PRUint32 mSchemeType;
};
#endif // nsSimpleURI_h__

View File

@ -17,6 +17,8 @@
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Original Author: Gagan Saksena <gagan@netscape.com>
*
* 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,

View File

@ -96,7 +96,10 @@ protected:
char* mRef;
nsCOMPtr<nsIURLParser> 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.

View File

@ -16,6 +16,8 @@
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Original Author: Gagan Saksena <gagan@netscape.com>
#
# Contributor(s):
#

View File

@ -17,6 +17,8 @@
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Original Author: Gagan Saksena <gagan@netscape.com>
#
# Contributor(s):
#------------------------------------------------------------------------

View File

@ -18,6 +18,8 @@
* Rights Reserved.
*
* Contributor(s):
* Gagan Saksena <gagan@netscape.com>
*
*/
#ifndef _nsHTTPEnums_h_

View File

@ -17,6 +17,8 @@
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Original Author: Gagan Saksena <gagan@netscape.com>
*
* Contributor(s):
*/

View File

@ -17,6 +17,8 @@
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Original Author: Gagan Saksena <gagan@netscape.com>
*
* Contributor(s):
*/

View File

@ -17,6 +17,8 @@
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Original Author: Gagan Saksena <gagan@netscape.com>
*
* Contributor(s):
*/

View File

@ -17,6 +17,8 @@
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Original Author: Gagan Saksena <gagan@netscape.com>
*
* Contributor(s):
*/

View File

@ -18,6 +18,8 @@
* Rights Reserved.
*
* Contributor(s):
* Gagan Saksena <gagan@netscape.com>
*
*/
/* The internal networking library http interface. External modules

View File

@ -17,6 +17,8 @@
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Original Author: Gagan Saksena <gagan@netscape.com>
*
* Contributor(s):
*/

View File

@ -17,6 +17,8 @@
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Original Author: Gagan Saksena <gagan@netscape.com>
*
* Contributor(s):
*/

View File

@ -17,6 +17,8 @@
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Original Author: Gagan Saksena <gagan@netscape.com>
*
* Contributor(s):
*/

View File

@ -17,6 +17,8 @@
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Original Author: Gagan Saksena <gagan@netscape.com>
*
* Contributor(s):
*/

View File

@ -17,6 +17,8 @@
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Original Author: Gagan Saksena <gagan@netscape.com>
*
* Contributor(s):
* Mike Shaver <shaver@zeroknowledge.com>
* Christopher Blizzard <blizzard@mozilla.org>

View File

@ -18,6 +18,7 @@
* Rights Reserved.
*
* Contributor(s):
* Gagan Saksena <gagan@netscape.com>
*/
/******

View File

@ -18,6 +18,7 @@
* Rights Reserved.
*
* Contributor(s):
* Gagan Saksena <gagan@netscape.com>
*/
#include "nsHTTPAtoms.h"

View File

@ -18,6 +18,7 @@
* Rights Reserved.
*
* Contributor(s):
* Gagan Saksena <gagan@netscape.com>
*/
#ifndef nsHTTPAtoms_h___
#define nsHTTPAtoms_h___

View File

@ -17,6 +17,8 @@
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Original Author: Gagan Saksena <gagan@netscape.com>
*
* Contributor(s):
* Pierre Phaneuf <pp@ludusdesign.com>
* Mike Shaver <shaver@zeroknowledge.com>
@ -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;
}

View File

@ -17,6 +17,8 @@
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Original Author: Gagan Saksena <gagan@netscape.com>
*
* Contributor(s):
*/

View File

@ -17,6 +17,8 @@
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Original Author: Gagan Saksena <gagan@netscape.com>
*
* Contributor(s):
* Pierre Phaneuf <pp@ludusdesign.com>
* Christopher Blizzard <blizzard@mozilla.org>
@ -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<nsIWebFilters> filters =

View File

@ -17,6 +17,8 @@
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Original Author: Gagan Saksena <gagan@netscape.com>
*
* Contributor(s):
*/

View File

@ -18,6 +18,7 @@
* Rights Reserved.
*
* Contributor(s):
* Gagan Saksena <gagan@netscape.com>
*/
#include "nsIGenericFactory.h"
#include "nsIServiceManager.h"

View File

@ -18,6 +18,8 @@
* Rights Reserved.
*
* Contributor(s):
* Gagan Saksena <gagan@netscape.com>
*
*/

View File

@ -17,6 +17,8 @@
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Original Author: Gagan Saksena <gagan@netscape.com>
*
* Contributor(s):
*/

View File

@ -17,6 +17,8 @@
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Original Author: Gagan Saksena <gagan@netscape.com>
*
* Contributor(s):
*/

View File

@ -17,6 +17,8 @@
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Original Author: Gagan Saksena <gagan@netscape.com>
*
* Contributor(s):
*/

View File

@ -17,6 +17,8 @@
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Original Author: Gagan Saksena <gagan@netscape.com>
*
* Contributor(s):
*/

View File

@ -17,6 +17,8 @@
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Original Author: Gagan Saksena <gagan@netscape.com>
*
* Contributor(s):
*/

View File

@ -17,6 +17,8 @@
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Original Author: Gagan Saksena <gagan@netscape.com>
*
* Contributor(s):
*/

View File

@ -17,6 +17,8 @@
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Original Author: Gagan Saksena <gagan@netscape.com>
*
* Contributor(s):
*/

View File

@ -18,6 +18,7 @@
* Rights Reserved.
*
* Contributor(s):
* Gagan Saksena <gagan@netscape.com>
*/
#include "nspr.h"

View File

@ -18,6 +18,7 @@
* Rights Reserved.
*
* Contributor(s):
* Gagan Saksena <gagan@netscape.com>
*/
#ifndef _nsHTTPSHandler_h_

View File

@ -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)
{

View File

@ -50,6 +50,7 @@ public:
protected:
nsCOMPtr<nsIURI> mJARFile;
char *mJAREntry;
PRUint32 mSchemeType;
};
#endif // nsJARURI_h__

View File

@ -278,16 +278,8 @@ void nsUnknownDecoder::DetermineContentType(nsIChannel *aChannel)
PRBool isLocalFile = PR_FALSE;
if (aChannel) {
nsCOMPtr<nsIURI> 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) {

View File

@ -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<nsIURI>* aDTD)
{
char* scheme = nsnull;
PRBool isLoadable = PR_FALSE;
nsresult res = NS_OK;
@ -728,12 +726,7 @@ IsLoadableDTD(nsCOMPtr<nsIURI>* 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

View File

@ -20,6 +20,7 @@
* Original Author: David W. Hyatt (hyatt@netscape.com)
*
* Contributor(s):
* Gagan Saksena <gagan@netscape.com>
*/
#include <string.h>
@ -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)

View File

@ -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)

View File

@ -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.