if (NS_FAILED(rv = GetChromeBase(chromeBase, chromeResource))) {
if (NS_FAILED(rv = GetChromeResource(chromeBase, chromeResource, kCHROME_base))) {
nsChromeRegistry::ConvertChromeURL(nsIURL* aChromeURL){    nsresult rv = NS_OK;    if (NS_FAILED(rv = EnsureRegistryDataSource())) {        NS_ERROR("Unable to ensure the existence of a chrome registry.");        return rv;    }    // Retrieve the resource for this chrome element.    const char* host;    if (NS_FAILED(rv = aChromeURL->GetHost(&host))) {        NS_ERROR("Unable to retrieve the host for a chrome URL.");        return rv;    }    nsAutoString hostStr(host);    hostStr.ToLowerCase();    // Construct a chrome URL and use it to look up a resource.    nsAutoString windowType = nsAutoString("chrome://") + hostStr + "/";    // Find out if the chrome URL referenced a skin or content.    const char* file;    aChromeURL->GetFile(&file);    nsAutoString restOfURL(file);    restOfURL.ToLowerCase();    if (restOfURL.Find("/skin") == 0)        windowType += "skin/";    else windowType += "content/";    // We have the resource URI that we wish to retrieve. Fetch it.    nsCOMPtr<nsIRDFResource> chromeResource;    if (NS_FAILED(rv = GetSkinOrContentResource(windowType, getter_AddRefs(chromeResource)))) {        NS_ERROR("Unable to retrieve the resource corresponding to the chrome skin or content.");        return rv;    }    nsString chromeBase;    if (NS_FAILED(rv = GetChromeBase(chromeBase, chromeResource))) {        NS_ERROR("Unable to retrieve codebase for chrome entry.");        return rv;    }    // Check to see if we should append the "main" entry in the registry.    // Only do this when the user doesn't have anything following "skin"    // or "content" in the specified URL.    if (restOfURL == "/skin" || restOfURL == "/skin/" ||        restOfURL == "/content" || restOfURL == "/content/")    {        // Append the "main" entry.        nsString mainFile;        if (NS_FAILED(rv = GetMainChromeFile(mainFile, chromeResource))) {            NS_ERROR("Unable to retrieve the main file registry entry for a chrome URL.");            return rv;        }        chromeBase += mainFile;    }    else    {        // XXX Just append the rest of the URL following the skin or content.    }    char* finalDecision = chromeBase.ToNewCString();    aChromeURL->SetSpec(finalDecision);    delete []finalDecision;    return NS_OK;}