зеркало из https://github.com/mozilla/pjs.git
make registry work without needing an rdf datasource r=pavlov
This commit is contained in:
Родитель
16aaa7ce49
Коммит
3b9d1d73f8
|
@ -265,7 +265,6 @@ nsChromeRegistry::QueryInterface(REFNSIID aIID, void** aResult)
|
|||
*/
|
||||
NS_IMETHODIMP
|
||||
nsChromeRegistry::ConvertChromeURL(nsIURI* aChromeURL)
|
||||
#ifdef NECKO
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
NS_ASSERTION(aChromeURL, "null url!");
|
||||
|
@ -329,8 +328,8 @@ nsChromeRegistry::ConvertChromeURL(nsIURI* aChromeURL)
|
|||
// Get the chromeResource from this lookup string
|
||||
nsCOMPtr<nsIRDFResource> chromeResource;
|
||||
if (NS_FAILED(rv = GetPackageTypeResource(lookup, getter_AddRefs(chromeResource)))) {
|
||||
NS_ERROR("Unable to retrieve the resource corresponding to the chrome skin or content.");
|
||||
return rv;
|
||||
// NS_ERROR("Unable to retrieve the resource corresponding to the chrome skin or content.");
|
||||
//return rv;
|
||||
}
|
||||
|
||||
// Using this chrome resource get the three basic things of a chrome entry-
|
||||
|
@ -340,7 +339,10 @@ nsChromeRegistry::ConvertChromeURL(nsIURI* aChromeURL)
|
|||
|
||||
rv = GetChromeResource(name, chromeResource, kCHROME_name);
|
||||
if (NS_FAILED (rv)) {
|
||||
// No name entry was found. No problem.
|
||||
if (PL_strcmp(provider,"/locale") == 0)
|
||||
name = "en-US";
|
||||
else
|
||||
name = "default";
|
||||
}
|
||||
|
||||
rv = GetChromeResource(base, chromeResource, kCHROME_base);
|
||||
|
@ -373,8 +375,15 @@ nsChromeRegistry::ConvertChromeURL(nsIURI* aChromeURL)
|
|||
if (NS_FAILED(rv))
|
||||
{
|
||||
//we'd definitely need main for an empty remaining
|
||||
NS_ERROR("Unable to retrieve the main file registry entry for a chrome URL.");
|
||||
return rv;
|
||||
//NS_ERROR("Unable to retrieve the main file registry entry for a chrome URL.");
|
||||
//return rv;
|
||||
main = package;
|
||||
if (PL_strcmp(provider, "/skin") == 0)
|
||||
main += ".css";
|
||||
else if (PL_strcmp(provider, "/content") == 0)
|
||||
main += ".xul";
|
||||
else if (PL_strcmp(provider, "/locale") == 0)
|
||||
main += ".dtd";
|
||||
}
|
||||
finalString += main;
|
||||
}
|
||||
|
@ -383,143 +392,11 @@ nsChromeRegistry::ConvertChromeURL(nsIURI* aChromeURL)
|
|||
|
||||
char* finalURI = finalString.ToNewCString();
|
||||
aChromeURL->SetSpec(finalURI);
|
||||
/*
|
||||
#ifndef NECKO
|
||||
// Clean out possible // in the path
|
||||
char* path;
|
||||
rv = aChromeURL->GetPath(&path);
|
||||
char* cleanPath = path;
|
||||
for (; '\0' != *path; ++path)
|
||||
{
|
||||
if (*path == '/' && *(path+1) == '/')
|
||||
++path;
|
||||
*cleanPath++ = *path;
|
||||
}
|
||||
aChrome->SetRelativePath(path);
|
||||
nsCRT::free(path);
|
||||
#endif
|
||||
*/
|
||||
|
||||
nsCRT::free(finalURI);
|
||||
return NS_OK;
|
||||
}
|
||||
#else
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// 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);
|
||||
const char* file;
|
||||
|
||||
// Construct a chrome URL and use it to look up a resource.
|
||||
nsAutoString windowType = nsAutoString("chrome://") + hostStr + "/";
|
||||
|
||||
// Stash any search part of the URL for later
|
||||
aChromeURL->GetSearch(&file);
|
||||
nsAutoString searchStr(file);
|
||||
|
||||
// Find out the package type of the URL
|
||||
aChromeURL->GetFile(&file);
|
||||
|
||||
nsAutoString restOfURL(file);
|
||||
|
||||
// Find the second slash.
|
||||
nsAutoString packageType("content");
|
||||
nsAutoString path("");
|
||||
PRInt32 slashIndex = -1;
|
||||
if (restOfURL.Length() > 1)
|
||||
{
|
||||
// There is something to the right of that slash. A provider type must have
|
||||
// been specified.
|
||||
slashIndex = restOfURL.FindChar('/', PR_FALSE,1);
|
||||
if (slashIndex == -1)
|
||||
slashIndex = restOfURL.Length();
|
||||
|
||||
restOfURL.Mid(packageType, 1, slashIndex - 1);
|
||||
|
||||
if (slashIndex < restOfURL.Length()-1)
|
||||
{
|
||||
// There are some extra subdirectories to remember.
|
||||
restOfURL.Right(path, restOfURL.Length()-slashIndex-1);
|
||||
}
|
||||
}
|
||||
|
||||
windowType += packageType + "/";
|
||||
|
||||
// We have the resource URI that we wish to retrieve. Fetch it.
|
||||
nsCOMPtr<nsIRDFResource> chromeResource;
|
||||
if (NS_FAILED(rv = GetPackageTypeResource(windowType, getter_AddRefs(chromeResource)))) {
|
||||
NS_ERROR("Unable to retrieve the resource corresponding to the chrome skin or content.");
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsAutoString chromeName;
|
||||
if (NS_FAILED(rv = GetChromeResource(chromeName, chromeResource, kCHROME_name))) {
|
||||
// No name entry was found. Don't use one.
|
||||
chromeName = "";
|
||||
}
|
||||
|
||||
nsAutoString chromeBase;
|
||||
if (NS_FAILED(rv = GetChromeResource(chromeBase, chromeResource, kCHROME_base))) {
|
||||
// No base entry was found. Default to our cache.
|
||||
chromeBase = "resource:/chrome/";
|
||||
chromeBase += hostStr;
|
||||
chromeBase += "/";
|
||||
chromeBase += packageType + "/";
|
||||
if (chromeName != "")
|
||||
chromeBase += chromeName + "/";
|
||||
}
|
||||
|
||||
// Make sure base ends in a slash
|
||||
PRInt32 length = chromeBase.Length();
|
||||
if (length > 0)
|
||||
{
|
||||
PRUnichar c = chromeBase.CharAt(length-1);
|
||||
if (c != '/')
|
||||
chromeBase += "/"; // Ensure that a slash is present.
|
||||
}
|
||||
|
||||
// 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 (path.IsEmpty())
|
||||
{
|
||||
PRInt32 length = restOfURL.Length();
|
||||
if (length > 0)
|
||||
{
|
||||
PRUnichar c = restOfURL.CharAt(length-1);
|
||||
if (c != '/')
|
||||
restOfURL += "/"; // Ensure that a slash is present.
|
||||
}
|
||||
|
||||
// Append the "main" entry.
|
||||
nsAutoString mainFile;
|
||||
if (NS_FAILED(rv = GetChromeResource(mainFile, chromeResource, kCHROME_main))) {
|
||||
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 to base to get the actual URL to look up.
|
||||
chromeBase += path;
|
||||
}
|
||||
|
||||
char* finalDecision = chromeBase.ToNewCString();
|
||||
char* search = searchStr.ToNewCString();
|
||||
aChromeURL->SetSpec(finalDecision);
|
||||
if (search && *search) {
|
||||
aChromeURL->SetSearch(search);
|
||||
nsCRT::free(search);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsChromeRegistry::InitRegistry()
|
||||
|
@ -570,6 +447,8 @@ nsChromeRegistry::InitRegistry()
|
|||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get resource");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
|
||||
/*
|
||||
rv = nsComponentManager::CreateInstance(kRDFXMLDataSourceCID,
|
||||
nsnull,
|
||||
nsIRDFDataSource::GetIID(),
|
||||
|
@ -590,8 +469,9 @@ nsChromeRegistry::InitRegistry()
|
|||
|
||||
rv = remote->Init(innerURI);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
nsCOMPtr<nsIRDFRemoteDataSource> remote = do_QueryInterface(mInner);
|
||||
if (! remote)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
@ -599,7 +479,8 @@ nsChromeRegistry::InitRegistry()
|
|||
// We need to read this synchronously.
|
||||
nsresult rv = remote->Refresh(PR_TRUE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
*/
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,383 +0,0 @@
|
|||
<?xml version="1.0"?> <!-- -*- Mode: SGML; tab-width: 4; indent-tabs-mode: nil -*- -->
|
||||
|
||||
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns="http://chrome.mozilla.org/rdf#">
|
||||
|
||||
<chrome about="chrome://global/">
|
||||
|
||||
<skin>
|
||||
<RDF:Description about="chrome://global/skin/">
|
||||
<main>skin.css</main>
|
||||
<base>resource:/chrome/global/skin/default/</base>
|
||||
</RDF:Description>
|
||||
</skin>
|
||||
|
||||
<content>
|
||||
<RDF:Description about="chrome://global/content/">
|
||||
<base>resource:/chrome/global/content/default/</base>
|
||||
<main>globalOverlay.xul</main>
|
||||
</RDF:Description>
|
||||
</content>
|
||||
|
||||
<locale>
|
||||
<RDF:Description about="chrome://global/locale/">
|
||||
<name>en-US</name>
|
||||
</RDF:Description>
|
||||
</locale>
|
||||
|
||||
</chrome>
|
||||
|
||||
|
||||
<chrome about="chrome://navigator/">
|
||||
|
||||
<skin>
|
||||
<RDF:Description about="chrome://navigator/skin/">
|
||||
<base>resource:/chrome/navigator/skin/default/</base>
|
||||
<main>navigator.css</main>
|
||||
</RDF:Description>
|
||||
</skin>
|
||||
|
||||
<content>
|
||||
<RDF:Description about="chrome://navigator/content/">
|
||||
<base>resource:/chrome/navigator/content/default/</base>
|
||||
<main>navigator.xul</main>
|
||||
</RDF:Description>
|
||||
</content>
|
||||
|
||||
<locale>
|
||||
<RDF:Description about="chrome://navigator/locale/">
|
||||
<name>en-US</name>
|
||||
</RDF:Description>
|
||||
</locale>
|
||||
|
||||
</chrome>
|
||||
|
||||
<chrome about="chrome://sidebar/">
|
||||
|
||||
<content>
|
||||
<RDF:Description about="chrome://sidebar/content/">
|
||||
<base>resource:/chrome/sidebar/content/default/</base>
|
||||
</RDF:Description>
|
||||
</content>
|
||||
|
||||
<skin>
|
||||
<RDF:Description about="chrome://sidebar/skin/">
|
||||
<base>resource:/chrome/sidebar/skin/default/</base>
|
||||
<main>sidebar.css</main>
|
||||
</RDF:Description>
|
||||
</skin>
|
||||
|
||||
<locale>
|
||||
<RDF:Description about="chrome://sidebar/locale/">
|
||||
<name>en-US</name>
|
||||
</RDF:Description>
|
||||
</locale>
|
||||
|
||||
</chrome>
|
||||
|
||||
<chrome about="chrome://messenger/">
|
||||
|
||||
<skin>
|
||||
<RDF:Description about="chrome://messenger/skin/">
|
||||
<base>resource:/chrome/messenger/skin/default/</base>
|
||||
<main>messenger.css</main>
|
||||
</RDF:Description>
|
||||
</skin>
|
||||
|
||||
<content>
|
||||
<RDF:Description about="chrome://messenger/content/">
|
||||
<base>resource:/chrome/messenger/content/default/</base>
|
||||
<main>messenger.xul</main>
|
||||
</RDF:Description>
|
||||
</content>
|
||||
|
||||
<locale>
|
||||
<RDF:Description about="chrome://messenger/locale/">
|
||||
<name>en-US</name>
|
||||
</RDF:Description>
|
||||
</locale>
|
||||
|
||||
</chrome>
|
||||
|
||||
<chrome about="chrome://messengercompose/">
|
||||
|
||||
<skin>
|
||||
<RDF:Description about="chrome://messengercompose/skin/">
|
||||
<base>resource:/chrome/messengercompose/skin/default/</base>
|
||||
<main>messengercompose.css</main>
|
||||
</RDF:Description>
|
||||
</skin>
|
||||
|
||||
<content>
|
||||
<RDF:Description about="chrome://messengercompose/content/">
|
||||
<base>resource:/chrome/messengercompose/content/default/</base>
|
||||
<main>messengercompose.xul</main>
|
||||
</RDF:Description>
|
||||
</content>
|
||||
|
||||
<locale>
|
||||
<RDF:Description about="chrome://messengercompose/locale/">
|
||||
<name>en-US</name>
|
||||
</RDF:Description>
|
||||
</locale>
|
||||
|
||||
</chrome>
|
||||
|
||||
<chrome about="chrome://editor/">
|
||||
|
||||
<content>
|
||||
<RDF:Description about="chrome://editor/content/">
|
||||
<base>resource:/chrome/editor/content/default/</base>
|
||||
<main>EditorAppShell.xul</main>
|
||||
</RDF:Description>
|
||||
</content>
|
||||
|
||||
<skin>
|
||||
<RDF:Description about="chrome://editor/skin/">
|
||||
<base>resource:/chrome/editor/skin/default/</base>
|
||||
<main>Editor.css</main>
|
||||
</RDF:Description>
|
||||
</skin>
|
||||
|
||||
<locale>
|
||||
<RDF:Description about="chrome://editor/locale/">
|
||||
<name>en-US</name>
|
||||
</RDF:Description>
|
||||
</locale>
|
||||
|
||||
</chrome>
|
||||
|
||||
<chrome about="chrome://addressbook/">
|
||||
|
||||
<skin>
|
||||
<RDF:Description about="chrome://addressbook/skin/">
|
||||
<base>resource:/chrome/addressbook/skin/default/</base>
|
||||
<main>addressbook.css</main>
|
||||
</RDF:Description>
|
||||
</skin>
|
||||
|
||||
<content>
|
||||
<RDF:Description about="chrome://addressbook/content/">
|
||||
<base>resource:/chrome/addressbook/content/default/</base>
|
||||
<main>addressbook.xul</main>
|
||||
</RDF:Description>
|
||||
</content>
|
||||
|
||||
<locale>
|
||||
<RDF:Description about="chrome://addressbook/locale/">
|
||||
<name>en-US</name>
|
||||
</RDF:Description>
|
||||
</locale>
|
||||
|
||||
</chrome>
|
||||
|
||||
<chrome about="chrome://pref/">
|
||||
|
||||
<skin>
|
||||
<RDF:Description about="chrome://pref/skin/">
|
||||
<base>resource:/chrome/pref/skin/default/</base>
|
||||
<main>pref.css</main>
|
||||
</RDF:Description>
|
||||
</skin>
|
||||
|
||||
<content>
|
||||
<RDF:Description about="chrome://pref/content/">
|
||||
<base>resource:/chrome/pref/content/default/</base>
|
||||
<main>PrefsWindow.xul</main>
|
||||
</RDF:Description>
|
||||
</content>
|
||||
|
||||
<locale>
|
||||
<RDF:Description about="chrome://pref/locale/">
|
||||
<name>en-US</name>
|
||||
</RDF:Description>
|
||||
</locale>
|
||||
|
||||
</chrome>
|
||||
|
||||
<chrome about="chrome://profile/">
|
||||
|
||||
<content>
|
||||
<RDF:Description about="chrome://profile/content/">
|
||||
<base>resource:/chrome/profile/content/default/</base>
|
||||
</RDF:Description>
|
||||
</content>
|
||||
|
||||
<skin>
|
||||
<RDF:Description about="chrome://profile/skin/">
|
||||
<base>resource:/chrome/profile/skin/default/</base>
|
||||
</RDF:Description>
|
||||
</skin>
|
||||
|
||||
<locale>
|
||||
<RDF:Description about="chrome://profile/locale/">
|
||||
<name>en-US</name>
|
||||
</RDF:Description>
|
||||
</locale>
|
||||
|
||||
</chrome>
|
||||
|
||||
<chrome about="chrome://wallet/">
|
||||
|
||||
<skin>
|
||||
<RDF:Description about="chrome://wallet/skin/">
|
||||
<base>resource:/chrome/wallet/skin/default/</base>
|
||||
<main>wallet.css</main>
|
||||
</RDF:Description>
|
||||
</skin>
|
||||
|
||||
<content>
|
||||
<RDF:Description about="chrome://wallet/content/">
|
||||
<base>resource:/chrome/wallet/content/default/</base>
|
||||
<main>CookieViewer.xul</main>
|
||||
</RDF:Description>
|
||||
</content>
|
||||
|
||||
<locale>
|
||||
<RDF:Description about="chrome://wallet/locale/">
|
||||
<name>en-US</name>
|
||||
</RDF:Description>
|
||||
</locale>
|
||||
|
||||
</chrome>
|
||||
|
||||
<chrome about="chrome://bookmarks/">
|
||||
|
||||
<content>
|
||||
<RDF:Description about="chrome://bookmarks/content/">
|
||||
<base>resource:/chrome/bookmarks/content/default/</base>
|
||||
<main>bookmarks.xul</main>
|
||||
</RDF:Description>
|
||||
</content>
|
||||
|
||||
<skin>
|
||||
<RDF:Description about="chrome://bookmarks/skin/">
|
||||
<base>resource:/chrome/bookmarks/skin/default/</base>
|
||||
<main>bookmarks.css</main>
|
||||
</RDF:Description>
|
||||
</skin>
|
||||
|
||||
<locale>
|
||||
<RDF:Description about="chrome://bookmarks/locale/">
|
||||
<name>en-US</name>
|
||||
</RDF:Description>
|
||||
</locale>
|
||||
|
||||
</chrome>
|
||||
|
||||
<chrome about="chrome://directory/">
|
||||
<content>
|
||||
<RDF:Description about="chrome://directory/content/">
|
||||
<base>resource:/chrome/directory/content/default/</base>
|
||||
<main>directory.xul</main>
|
||||
</RDF:Description>
|
||||
</content>
|
||||
|
||||
<skin>
|
||||
<RDF:Description about="chrome://directory/skin/">
|
||||
<base>resource:/chrome/directory/skin/default/</base>
|
||||
<main>directory.css</main>
|
||||
</RDF:Description>
|
||||
</skin>
|
||||
|
||||
<locale>
|
||||
<RDF:Description about="chrome://directory/locale/">
|
||||
<name>en-US</name>
|
||||
</RDF:Description>
|
||||
</locale>
|
||||
</chrome>
|
||||
|
||||
<chrome about="chrome://regviewer/">
|
||||
<content>
|
||||
<RDF:Description about="chrome://regviewer/content/">
|
||||
<base>resource:/chrome/regviewer/content/default/</base>
|
||||
<main>regviewer.xul</main>
|
||||
</RDF:Description>
|
||||
</content>
|
||||
|
||||
<skin>
|
||||
<RDF:Description about="chrome://regviewer/skin/">
|
||||
<base>resource:/chrome/regviewer/skin/default/</base>
|
||||
<main>regviewer.css</main>
|
||||
</RDF:Description>
|
||||
</skin>
|
||||
|
||||
<locale>
|
||||
<RDF:Description about="chrome://regviewer/locale/">
|
||||
<name>en-US</name>
|
||||
</RDF:Description>
|
||||
</locale>
|
||||
</chrome>
|
||||
|
||||
<chrome about="chrome://history/">
|
||||
|
||||
<content>
|
||||
<RDF:Description about="chrome://history/content/">
|
||||
<base>resource:/chrome/history/content/default/</base>
|
||||
<main>history.xul</main>
|
||||
</RDF:Description>
|
||||
</content>
|
||||
|
||||
<skin>
|
||||
<RDF:Description about="chrome://history/skin/">
|
||||
<base>resource:/chrome/history/skin/default/</base>
|
||||
<main>history.css</main>
|
||||
</RDF:Description>
|
||||
</skin>
|
||||
|
||||
<locale>
|
||||
<RDF:Description about="chrome://history/locale/">
|
||||
<name>en-US</name>
|
||||
</RDF:Description>
|
||||
</locale>
|
||||
|
||||
</chrome>
|
||||
|
||||
<chrome about="chrome://related/">
|
||||
|
||||
<content>
|
||||
<RDF:Description about="chrome://related/content/">
|
||||
<base>resource:/chrome/related/content/default/</base>
|
||||
</RDF:Description>
|
||||
</content>
|
||||
|
||||
<skin>
|
||||
<RDF:Description about="chrome://related/skin/">
|
||||
<base>resource:/chrome/related/skin/default/</base>
|
||||
</RDF:Description>
|
||||
</skin>
|
||||
|
||||
<locale>
|
||||
<RDF:Description about="chrome://related/locale/">
|
||||
<name>en-US</name>
|
||||
</RDF:Description>
|
||||
</locale>
|
||||
|
||||
</chrome>
|
||||
|
||||
<chrome about="chrome://xpinstall/">
|
||||
|
||||
<content>
|
||||
<RDF:Description about="chrome://xpinstall/content/">
|
||||
<base>resource:/chrome/xpinstall/content/default/</base>
|
||||
</RDF:Description>
|
||||
</content>
|
||||
|
||||
<locale>
|
||||
<RDF:Description about="chrome://xpinstall/locale/">
|
||||
<name>en-US</name>
|
||||
</RDF:Description>
|
||||
</locale>
|
||||
|
||||
</chrome>
|
||||
|
||||
<chrome about="chrome://netwerk/">
|
||||
<content>
|
||||
<RDF:Description about="chrome://netwerk/content/">
|
||||
<base>resource:/chrome/netwerk/content/default/</base>
|
||||
</RDF:Description>
|
||||
</content>
|
||||
</chrome>
|
||||
|
||||
</RDF:RDF>
|
||||
|
|
@ -265,7 +265,6 @@ nsChromeRegistry::QueryInterface(REFNSIID aIID, void** aResult)
|
|||
*/
|
||||
NS_IMETHODIMP
|
||||
nsChromeRegistry::ConvertChromeURL(nsIURI* aChromeURL)
|
||||
#ifdef NECKO
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
NS_ASSERTION(aChromeURL, "null url!");
|
||||
|
@ -329,8 +328,8 @@ nsChromeRegistry::ConvertChromeURL(nsIURI* aChromeURL)
|
|||
// Get the chromeResource from this lookup string
|
||||
nsCOMPtr<nsIRDFResource> chromeResource;
|
||||
if (NS_FAILED(rv = GetPackageTypeResource(lookup, getter_AddRefs(chromeResource)))) {
|
||||
NS_ERROR("Unable to retrieve the resource corresponding to the chrome skin or content.");
|
||||
return rv;
|
||||
// NS_ERROR("Unable to retrieve the resource corresponding to the chrome skin or content.");
|
||||
//return rv;
|
||||
}
|
||||
|
||||
// Using this chrome resource get the three basic things of a chrome entry-
|
||||
|
@ -340,7 +339,10 @@ nsChromeRegistry::ConvertChromeURL(nsIURI* aChromeURL)
|
|||
|
||||
rv = GetChromeResource(name, chromeResource, kCHROME_name);
|
||||
if (NS_FAILED (rv)) {
|
||||
// No name entry was found. No problem.
|
||||
if (PL_strcmp(provider,"/locale") == 0)
|
||||
name = "en-US";
|
||||
else
|
||||
name = "default";
|
||||
}
|
||||
|
||||
rv = GetChromeResource(base, chromeResource, kCHROME_base);
|
||||
|
@ -373,8 +375,15 @@ nsChromeRegistry::ConvertChromeURL(nsIURI* aChromeURL)
|
|||
if (NS_FAILED(rv))
|
||||
{
|
||||
//we'd definitely need main for an empty remaining
|
||||
NS_ERROR("Unable to retrieve the main file registry entry for a chrome URL.");
|
||||
return rv;
|
||||
//NS_ERROR("Unable to retrieve the main file registry entry for a chrome URL.");
|
||||
//return rv;
|
||||
main = package;
|
||||
if (PL_strcmp(provider, "/skin") == 0)
|
||||
main += ".css";
|
||||
else if (PL_strcmp(provider, "/content") == 0)
|
||||
main += ".xul";
|
||||
else if (PL_strcmp(provider, "/locale") == 0)
|
||||
main += ".dtd";
|
||||
}
|
||||
finalString += main;
|
||||
}
|
||||
|
@ -383,143 +392,11 @@ nsChromeRegistry::ConvertChromeURL(nsIURI* aChromeURL)
|
|||
|
||||
char* finalURI = finalString.ToNewCString();
|
||||
aChromeURL->SetSpec(finalURI);
|
||||
/*
|
||||
#ifndef NECKO
|
||||
// Clean out possible // in the path
|
||||
char* path;
|
||||
rv = aChromeURL->GetPath(&path);
|
||||
char* cleanPath = path;
|
||||
for (; '\0' != *path; ++path)
|
||||
{
|
||||
if (*path == '/' && *(path+1) == '/')
|
||||
++path;
|
||||
*cleanPath++ = *path;
|
||||
}
|
||||
aChrome->SetRelativePath(path);
|
||||
nsCRT::free(path);
|
||||
#endif
|
||||
*/
|
||||
|
||||
nsCRT::free(finalURI);
|
||||
return NS_OK;
|
||||
}
|
||||
#else
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// 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);
|
||||
const char* file;
|
||||
|
||||
// Construct a chrome URL and use it to look up a resource.
|
||||
nsAutoString windowType = nsAutoString("chrome://") + hostStr + "/";
|
||||
|
||||
// Stash any search part of the URL for later
|
||||
aChromeURL->GetSearch(&file);
|
||||
nsAutoString searchStr(file);
|
||||
|
||||
// Find out the package type of the URL
|
||||
aChromeURL->GetFile(&file);
|
||||
|
||||
nsAutoString restOfURL(file);
|
||||
|
||||
// Find the second slash.
|
||||
nsAutoString packageType("content");
|
||||
nsAutoString path("");
|
||||
PRInt32 slashIndex = -1;
|
||||
if (restOfURL.Length() > 1)
|
||||
{
|
||||
// There is something to the right of that slash. A provider type must have
|
||||
// been specified.
|
||||
slashIndex = restOfURL.FindChar('/', PR_FALSE,1);
|
||||
if (slashIndex == -1)
|
||||
slashIndex = restOfURL.Length();
|
||||
|
||||
restOfURL.Mid(packageType, 1, slashIndex - 1);
|
||||
|
||||
if (slashIndex < restOfURL.Length()-1)
|
||||
{
|
||||
// There are some extra subdirectories to remember.
|
||||
restOfURL.Right(path, restOfURL.Length()-slashIndex-1);
|
||||
}
|
||||
}
|
||||
|
||||
windowType += packageType + "/";
|
||||
|
||||
// We have the resource URI that we wish to retrieve. Fetch it.
|
||||
nsCOMPtr<nsIRDFResource> chromeResource;
|
||||
if (NS_FAILED(rv = GetPackageTypeResource(windowType, getter_AddRefs(chromeResource)))) {
|
||||
NS_ERROR("Unable to retrieve the resource corresponding to the chrome skin or content.");
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsAutoString chromeName;
|
||||
if (NS_FAILED(rv = GetChromeResource(chromeName, chromeResource, kCHROME_name))) {
|
||||
// No name entry was found. Don't use one.
|
||||
chromeName = "";
|
||||
}
|
||||
|
||||
nsAutoString chromeBase;
|
||||
if (NS_FAILED(rv = GetChromeResource(chromeBase, chromeResource, kCHROME_base))) {
|
||||
// No base entry was found. Default to our cache.
|
||||
chromeBase = "resource:/chrome/";
|
||||
chromeBase += hostStr;
|
||||
chromeBase += "/";
|
||||
chromeBase += packageType + "/";
|
||||
if (chromeName != "")
|
||||
chromeBase += chromeName + "/";
|
||||
}
|
||||
|
||||
// Make sure base ends in a slash
|
||||
PRInt32 length = chromeBase.Length();
|
||||
if (length > 0)
|
||||
{
|
||||
PRUnichar c = chromeBase.CharAt(length-1);
|
||||
if (c != '/')
|
||||
chromeBase += "/"; // Ensure that a slash is present.
|
||||
}
|
||||
|
||||
// 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 (path.IsEmpty())
|
||||
{
|
||||
PRInt32 length = restOfURL.Length();
|
||||
if (length > 0)
|
||||
{
|
||||
PRUnichar c = restOfURL.CharAt(length-1);
|
||||
if (c != '/')
|
||||
restOfURL += "/"; // Ensure that a slash is present.
|
||||
}
|
||||
|
||||
// Append the "main" entry.
|
||||
nsAutoString mainFile;
|
||||
if (NS_FAILED(rv = GetChromeResource(mainFile, chromeResource, kCHROME_main))) {
|
||||
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 to base to get the actual URL to look up.
|
||||
chromeBase += path;
|
||||
}
|
||||
|
||||
char* finalDecision = chromeBase.ToNewCString();
|
||||
char* search = searchStr.ToNewCString();
|
||||
aChromeURL->SetSpec(finalDecision);
|
||||
if (search && *search) {
|
||||
aChromeURL->SetSearch(search);
|
||||
nsCRT::free(search);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsChromeRegistry::InitRegistry()
|
||||
|
@ -570,6 +447,8 @@ nsChromeRegistry::InitRegistry()
|
|||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get resource");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
|
||||
/*
|
||||
rv = nsComponentManager::CreateInstance(kRDFXMLDataSourceCID,
|
||||
nsnull,
|
||||
nsIRDFDataSource::GetIID(),
|
||||
|
@ -590,8 +469,9 @@ nsChromeRegistry::InitRegistry()
|
|||
|
||||
rv = remote->Init(innerURI);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
nsCOMPtr<nsIRDFRemoteDataSource> remote = do_QueryInterface(mInner);
|
||||
if (! remote)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
@ -599,7 +479,8 @@ nsChromeRegistry::InitRegistry()
|
|||
// We need to read this synchronously.
|
||||
nsresult rv = remote->Refresh(PR_TRUE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
*/
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче