sr=rpotts, r=gagan. 70743. switching over to new extensible URI::SchemeIs() api

This commit is contained in:
valeski%netscape.com 2001-03-13 02:02:05 +00:00
parent aec997a897
commit 68017cb9e2
20 changed files with 44 additions and 39 deletions

View File

@ -96,8 +96,8 @@ nsCodebasePrincipal::CanEnableCapability(const char *capability,
PRBool isFile = PR_FALSE;
PRBool isRes = PR_FALSE;
if (NS_FAILED(mURI->SchemeIs(nsIURI::FILE, &isFile)) ||
NS_FAILED(mURI->SchemeIs(nsIURI::RESOURCE, &isRes)) ||
if (NS_FAILED(mURI->SchemeIs("file", &isFile)) ||
NS_FAILED(mURI->SchemeIs("resource", &isRes)) ||
(!isFile && !isRes))
{
*result = nsIPrincipal::ENABLE_DENIED;

View File

@ -526,8 +526,8 @@ nsScriptSecurityManager::CheckLoadURIFromScript(JSContext *cx,
// UniversalFileRead capability trump the above check.
PRBool isFile = PR_FALSE;
PRBool isRes = PR_FALSE;
if (NS_FAILED(aURI->SchemeIs(nsIURI::FILE, &isFile)) ||
NS_FAILED(aURI->SchemeIs(nsIURI::RESOURCE, &isRes)))
if (NS_FAILED(aURI->SchemeIs("file", &isFile)) ||
NS_FAILED(aURI->SchemeIs("resource", &isRes)))
return NS_ERROR_FAILURE;
if (isFile || isRes)
{

View File

@ -1090,7 +1090,7 @@ NS_IMETHODIMP nsChromeRegistry::RefreshSkins()
static PRBool IsChromeURI(nsIURI* aURI)
{
PRBool isChrome=PR_FALSE;
if (NS_SUCCEEDED(aURI->SchemeIs(nsIURI::CHROME, &isChrome)) && isChrome)
if (NS_SUCCEEDED(aURI->SchemeIs("chrome", &isChrome)) && isChrome)
return PR_TRUE;
return PR_FALSE;
}

View File

@ -763,8 +763,8 @@ nsDocument::Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup)
PRBool isChrome = PR_FALSE;
PRBool isRes = PR_FALSE;
(void)uri->SchemeIs(nsIURI::CHROME, &isChrome);
(void)uri->SchemeIs(nsIURI::RESOURCE, &isRes);
(void)uri->SchemeIs("chrome", &isChrome);
(void)uri->SchemeIs("resource", &isRes);
if (isChrome || isRes)
(void)aChannel->GetOriginalURI(&mDocumentURL);

View File

@ -204,8 +204,8 @@ nsXBLPrototypeHandler::ExecuteHandler(nsIDOMEventReceiver* aReceiver, nsIDOMEven
PRBool isChrome = PR_FALSE;
PRBool isRes = PR_FALSE;
url->SchemeIs(nsIURI::CHROME, &isChrome);
url->SchemeIs(nsIURI::RESOURCE, &isRes);
url->SchemeIs("chrome", &isChrome);
url->SchemeIs("resource", &isRes);
if (!isChrome && !isRes)
return NS_OK;

View File

@ -82,8 +82,8 @@ static PRBool IsChromeOrResourceURI(nsIURI* aURI)
{
PRBool isChrome = PR_FALSE;
PRBool isResource = PR_FALSE;
if (NS_SUCCEEDED(aURI->SchemeIs(nsIURI::CHROME, &isChrome)) &&
NS_SUCCEEDED(aURI->SchemeIs(nsIURI::RESOURCE, &isResource)))
if (NS_SUCCEEDED(aURI->SchemeIs("chrome", &isChrome)) &&
NS_SUCCEEDED(aURI->SchemeIs("resource", &isResource)))
return (isChrome || isResource);
return PR_FALSE;
}
@ -91,7 +91,7 @@ static PRBool IsChromeOrResourceURI(nsIURI* aURI)
static PRBool IsResourceURI(nsIURI* aURI)
{
PRBool isResource = PR_FALSE;
if (NS_SUCCEEDED(aURI->SchemeIs(nsIURI::RESOURCE, &isResource)) && isResource)
if (NS_SUCCEEDED(aURI->SchemeIs("resource", &isResource)) && isResource)
return PR_TRUE;
return PR_FALSE;
}

View File

@ -174,7 +174,7 @@ 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)
if (NS_SUCCEEDED(aURI->SchemeIs("chrome", &isChrome)) && isChrome)
return PR_TRUE;
return PR_FALSE;
}

View File

@ -244,11 +244,16 @@ NS_IMETHODIMP nsLDAPURL::Equals(nsIURI *other, PRBool *_retval)
return NS_ERROR_NOT_IMPLEMENTED;
}
// boolean schemeIs(in PRUint32 scheme);
// boolean schemeIs(in const char * scheme);
//
NS_IMETHODIMP nsLDAPURL::SchemeIs(PRUint32 i_Scheme, PRBool *o_Equals)
NS_IMETHODIMP nsLDAPURL::SchemeIs(const char *i_Scheme, PRBool *o_Equals)
{
*o_Equals = (i_Scheme == nsIURI::LDAP);
if (!i_Scheme) return NS_ERROR_INVALID_ARG;
id (*i_Scheme == 'l' || *i_Scheme == 'L') {
*o_Equals = PL_strcasecmp("ldap", i_Scheme) ? PR_FALSE : PR_TRUE;
} else {
*o_Equals = PR_FALSE;
}
return NS_OK;
}

View File

@ -2969,8 +2969,8 @@ NS_IMETHODIMP nsDocShell::InternalLoad(nsIURI* aURI, nsIURI* aReferrer,
{
PRBool isChrome = PR_FALSE;
PRBool isResource = PR_FALSE;
if (NS_SUCCEEDED(aURI->SchemeIs(nsIURI::CHROME, &isChrome)) &&
NS_SUCCEEDED(aURI->SchemeIs(nsIURI::RESOURCE, &isResource)) &&
if (NS_SUCCEEDED(aURI->SchemeIs("chrome", &isChrome)) &&
NS_SUCCEEDED(aURI->SchemeIs("resource", &isResource)) &&
!isChrome && !isResource)
{
static const char top[] = "_top";
@ -3182,7 +3182,7 @@ NS_IMETHODIMP nsDocShell::DoURILoad(nsIURI* aURI, nsIURI* aReferrerURI,
if (aWindowTarget && *aWindowTarget) {
PRBool isJSURL = PR_FALSE;
// do it only for javascript urls!
if (NS_SUCCEEDED(aURI->SchemeIs(nsIURI::JAVASCRIPT, &isJSURL)) && isJSURL)
if (NS_SUCCEEDED(aURI->SchemeIs("javascript", &isJSURL)) && isJSURL)
{
nsAutoString targetName; targetName.AssignWithConversion(aWindowTarget);
@ -3249,7 +3249,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
{
aURI->SchemeIs(nsIURI::JAVASCRIPT, &isJSOrData);
aURI->SchemeIs("javascript", &isJSOrData);
}
else
{ // Also set owner for data: URLs
@ -4181,8 +4181,8 @@ NS_IMETHODIMP nsDocShell::ShouldAddToGlobalHistory(nsIURI* aURI, PRBool* aShould
// to it.
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);
NS_ENSURE_SUCCESS(aURI->SchemeIs("http", &isHTTP), NS_ERROR_FAILURE);
NS_ENSURE_SUCCESS(aURI->SchemeIs("https", &isHTTPS), NS_ERROR_FAILURE);
if (isHTTP || isHTTPS)
{
@ -4195,10 +4195,10 @@ NS_IMETHODIMP nsDocShell::ShouldAddToGlobalHistory(nsIURI* aURI, PRBool* aShould
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);
NS_ENSURE_SUCCESS(aURI->SchemeIs("about", &isAbout), NS_ERROR_FAILURE);
NS_ENSURE_SUCCESS(aURI->SchemeIs("imap", &isImap), NS_ERROR_FAILURE);
NS_ENSURE_SUCCESS(aURI->SchemeIs("news", &isNews), NS_ERROR_FAILURE);
NS_ENSURE_SUCCESS(aURI->SchemeIs("mailbox", &isMailbox), NS_ERROR_FAILURE);
if (isAbout || isImap || isNews || isMailbox)
return NS_OK;

View File

@ -565,7 +565,7 @@ nsEditorShell::PrepareDocumentForEditing(nsIDOMWindow* aDOMWindow, nsIURI *aUrl)
// in the disk document, so that later saves save back to the same file.
nsCOMPtr<nsIFileURL> pageFileURL(do_QueryInterface(aUrl));
PRBool isFile=PR_FALSE;
rv = aUrl->SchemeIs(nsIURI::FILE, &isFile);
rv = aUrl->SchemeIs("file", &isFile);
if (NS_SUCCEEDED(rv) && isFile && pageFileURL)
{
nsCOMPtr<nsIFile> pageFile;

View File

@ -565,7 +565,7 @@ nsEditorShell::PrepareDocumentForEditing(nsIDOMWindow* aDOMWindow, nsIURI *aUrl)
// in the disk document, so that later saves save back to the same file.
nsCOMPtr<nsIFileURL> pageFileURL(do_QueryInterface(aUrl));
PRBool isFile=PR_FALSE;
rv = aUrl->SchemeIs(nsIURI::FILE, &isFile);
rv = aUrl->SchemeIs("file", &isFile);
if (NS_SUCCEEDED(rv) && isFile && pageFileURL)
{
nsCOMPtr<nsIFile> pageFile;

View File

@ -860,7 +860,7 @@ nsXMLHttpRequest::OpenRequest(const char *method,
// The following check takes the place of nsScriptSecurityManager::CheckLoadURI
// since loads of http URLs are always allowed.
PRBool isHTTP = PR_FALSE;
uri->SchemeIs(nsIURI::HTTP, &isHTTP);
uri->SchemeIs("http", &isHTTP);
if (!isHTTP)
return NS_ERROR_INVALID_ARG;

View File

@ -727,7 +727,7 @@ IsLoadableDTD(nsCOMPtr<nsIURI>* aDTD)
}
// Return true if the url is a chrome url
res = (*aDTD)->SchemeIs(nsIURI::CHROME, &isLoadable);
res = (*aDTD)->SchemeIs("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

@ -458,8 +458,8 @@ nsPresContext::SetShell(nsIPresShell* aShell)
if (mBaseURL) {
PRBool isChrome = PR_FALSE;
PRBool isRes = PR_FALSE;
mBaseURL->SchemeIs(nsIURI::CHROME, &isChrome);
mBaseURL->SchemeIs(nsIURI::RESOURCE, &isRes);
mBaseURL->SchemeIs("chrome", &isChrome);
mBaseURL->SchemeIs("resource", &isRes);
if (!isChrome && !isRes)
mImageAnimationMode = mImageAnimationModePref;

View File

@ -458,8 +458,8 @@ nsPresContext::SetShell(nsIPresShell* aShell)
if (mBaseURL) {
PRBool isChrome = PR_FALSE;
PRBool isRes = PR_FALSE;
mBaseURL->SchemeIs(nsIURI::CHROME, &isChrome);
mBaseURL->SchemeIs(nsIURI::RESOURCE, &isRes);
mBaseURL->SchemeIs("chrome", &isChrome);
mBaseURL->SchemeIs("resource", &isRes);
if (!isChrome && !isRes)
mImageAnimationMode = mImageAnimationModePref;

View File

@ -444,7 +444,7 @@ nsIsIndexFrame::OnSubmit(nsIPresContext* aPresContext)
nsXPIDLCString scheme;
PRBool isJSURL = PR_FALSE;
if (NS_SUCCEEDED(result = NS_NewURI(getter_AddRefs(actionURL), href, docURL))) {
result = actionURL->SchemeIs(nsIURI::JAVASCRIPT, &isJSURL);
result = actionURL->SchemeIs("javascript", &isJSURL);
}
// Append the URI encoded variable/value pairs for GET's
if (!isJSURL) { // Not for JS URIs, see bug 26917

View File

@ -806,7 +806,7 @@ nsFormFrame::OnSubmit(nsIPresContext* aPresContext, nsIFrame* aFrame)
nsXPIDLCString scheme;
PRBool isMailto = PR_FALSE;
if (actionURL && NS_FAILED(result = actionURL->SchemeIs(nsIURI::MAILTO,
if (actionURL && NS_FAILED(result = actionURL->SchemeIs("mailto",
&isMailto)))
return result;
if (isMailto) {

View File

@ -444,7 +444,7 @@ nsIsIndexFrame::OnSubmit(nsIPresContext* aPresContext)
nsXPIDLCString scheme;
PRBool isJSURL = PR_FALSE;
if (NS_SUCCEEDED(result = NS_NewURI(getter_AddRefs(actionURL), href, docURL))) {
result = actionURL->SchemeIs(nsIURI::JAVASCRIPT, &isJSURL);
result = actionURL->SchemeIs("javascript", &isJSURL);
}
// Append the URI encoded variable/value pairs for GET's
if (!isJSURL) { // Not for JS URIs, see bug 26917

View File

@ -727,7 +727,7 @@ IsLoadableDTD(nsCOMPtr<nsIURI>* aDTD)
}
// Return true if the url is a chrome url
res = (*aDTD)->SchemeIs(nsIURI::CHROME, &isLoadable);
res = (*aDTD)->SchemeIs("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

@ -1090,7 +1090,7 @@ NS_IMETHODIMP nsChromeRegistry::RefreshSkins()
static PRBool IsChromeURI(nsIURI* aURI)
{
PRBool isChrome=PR_FALSE;
if (NS_SUCCEEDED(aURI->SchemeIs(nsIURI::CHROME, &isChrome)) && isChrome)
if (NS_SUCCEEDED(aURI->SchemeIs("chrome", &isChrome)) && isChrome)
return PR_TRUE;
return PR_FALSE;
}