зеркало из https://github.com/mozilla/gecko-dev.git
fix bug 160000 - custom.jar support for chrome
look for custom.jar in the chrome directory - if found, always check it first for files before using the rest of the chrome registry. This allows embeddors to override specific chrome URLs with their own files. sr=hyatt, r=chak
This commit is contained in:
Родитель
98438361a1
Коммит
4e0b59f695
|
@ -105,8 +105,8 @@ interface nsIXULChromeRegistry : nsIChromeRegistry {
|
||||||
/* runtimeProvider == true: don't assert the runtime change */
|
/* runtimeProvider == true: don't assert the runtime change */
|
||||||
void setRuntimeProvider(in boolean runtimeProvider);
|
void setRuntimeProvider(in boolean runtimeProvider);
|
||||||
|
|
||||||
boolean checkThemeVersion(in wstring skinName);
|
boolean checkThemeVersion(in ACString skinName);
|
||||||
boolean checkLocaleVersion(in wstring localeName);
|
boolean checkLocaleVersion(in ACString localeName);
|
||||||
|
|
||||||
/* Apply skin/locale to a specific package */
|
/* Apply skin/locale to a specific package */
|
||||||
void selectSkinForPackage(in ACString skinName,
|
void selectSkinForPackage(in ACString skinName,
|
||||||
|
|
|
@ -539,6 +539,11 @@ nsChromeRegistry::ConvertChromeURL(nsIURI* aChromeURL, nsACString& aResult)
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCAutoString finalURL;
|
nsCAutoString finalURL;
|
||||||
|
|
||||||
|
rv = GetOverrideURL(package, provider, remaining, finalURL);
|
||||||
|
if (NS_SUCCEEDED(rv))
|
||||||
|
return NS_OK;
|
||||||
|
|
||||||
rv = GetBaseURL(package, provider, finalURL);
|
rv = GetBaseURL(package, provider, finalURL);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
|
@ -658,10 +663,122 @@ nsChromeRegistry::GetBaseURL(const nsACString& aPackage,
|
||||||
}
|
}
|
||||||
|
|
||||||
// From this resource, follow the "baseURL" arc.
|
// From this resource, follow the "baseURL" arc.
|
||||||
return nsChromeRegistry::FollowArc(mChromeDataSource,
|
return FollowArc(mChromeDataSource, aBaseURL, resource, mBaseURL);
|
||||||
aBaseURL,
|
}
|
||||||
resource,
|
|
||||||
mBaseURL);
|
nsresult
|
||||||
|
nsChromeRegistry::GetOverrideURL(const nsACString& aPackage,
|
||||||
|
const nsACString& aProvider,
|
||||||
|
const nsACString& aPath,
|
||||||
|
nsACString& aResult)
|
||||||
|
{
|
||||||
|
nsresult rv = InitOverrideJAR();
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
|
// ok, if we get here, we have an override JAR
|
||||||
|
|
||||||
|
aResult.SetCapacity(mOverrideJARURL.Length() +
|
||||||
|
aPackage.Length() +
|
||||||
|
aProvider.Length() +
|
||||||
|
aPath.Length() + 2);
|
||||||
|
|
||||||
|
aResult = mOverrideJARURL;
|
||||||
|
aResult += aPackage;
|
||||||
|
aResult += '/';
|
||||||
|
aResult += aProvider;
|
||||||
|
aResult += '/';
|
||||||
|
|
||||||
|
// skins and locales get their name tacked on, like
|
||||||
|
// skin/modern/foo.css or
|
||||||
|
// locale/en-US/navigator.properties
|
||||||
|
if (aProvider.Equals(NS_LITERAL_CSTRING("skin")) ||
|
||||||
|
aProvider.Equals(NS_LITERAL_CSTRING("locale"))) {
|
||||||
|
|
||||||
|
// little hack here to get the right arc
|
||||||
|
nsIRDFResource* providerArc;
|
||||||
|
if (aProvider.Equals("skin"))
|
||||||
|
providerArc = mSelectedSkin;
|
||||||
|
else
|
||||||
|
providerArc = mSelectedLocale;
|
||||||
|
|
||||||
|
nsCAutoString selectedProvider;
|
||||||
|
rv = GetSelectedProvider(aPackage, aProvider, providerArc, selectedProvider);
|
||||||
|
|
||||||
|
if (NS_SUCCEEDED(rv)) {
|
||||||
|
aResult += selectedProvider;
|
||||||
|
aResult += '/';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
aResult += aPath;
|
||||||
|
|
||||||
|
nsCOMPtr<nsIZipEntry> zipEntry;
|
||||||
|
rv = mOverrideJAR->GetEntry(PromiseFlatCString(aResult).get(),
|
||||||
|
getter_AddRefs(zipEntry));
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
aResult.Truncate();
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
nsChromeRegistry::InitOverrideJAR()
|
||||||
|
{
|
||||||
|
// generic failure if we know there's no override
|
||||||
|
if (mSearchedForOverride && !mOverrideJAR)
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
|
mSearchedForOverride = PR_TRUE;
|
||||||
|
|
||||||
|
nsresult rv;
|
||||||
|
//
|
||||||
|
// look for custom.jar
|
||||||
|
//
|
||||||
|
nsCOMPtr<nsIFile> overrideFile;
|
||||||
|
rv = GetInstallRoot(getter_AddRefs(overrideFile));
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
|
rv = overrideFile->AppendNative(NS_LITERAL_CSTRING("custom.jar"));
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
|
PRBool exists;
|
||||||
|
rv = overrideFile->Exists(&exists);
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
|
// ok, if the file doesn't exist, its just a generic failure
|
||||||
|
if (!exists)
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
|
//
|
||||||
|
// cache the url so we can later append
|
||||||
|
//
|
||||||
|
mOverrideJARURL.Assign("jar:");
|
||||||
|
nsCAutoString jarURL;
|
||||||
|
rv = NS_GetURLSpecFromFile(overrideFile, jarURL);
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
|
mOverrideJARURL.Append(jarURL);
|
||||||
|
mOverrideJARURL.Append("!/");
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
|
//
|
||||||
|
// also cache the zip file itself
|
||||||
|
//
|
||||||
|
nsCOMPtr<nsIZipReaderCache> readerCache =
|
||||||
|
do_CreateInstance("@mozilla.org/libjar/zip-reader-cache;1", &rv);
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
|
rv = readerCache->Init(32);
|
||||||
|
|
||||||
|
rv = readerCache->GetZip(overrideFile, getter_AddRefs(mOverrideJAR));
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
mOverrideJARURL.Truncate();
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// locate
|
// locate
|
||||||
|
@ -746,7 +863,7 @@ nsresult
|
||||||
nsChromeRegistry::SelectPackageInProvider(nsIRDFResource *aPackageList,
|
nsChromeRegistry::SelectPackageInProvider(nsIRDFResource *aPackageList,
|
||||||
const nsACString& aPackage,
|
const nsACString& aPackage,
|
||||||
const nsACString& aProvider,
|
const nsACString& aProvider,
|
||||||
const nsCString& aProviderName,
|
const nsACString& aProviderName,
|
||||||
nsIRDFResource *aArc,
|
nsIRDFResource *aArc,
|
||||||
nsIRDFNode **aSelectedProvider)
|
nsIRDFNode **aSelectedProvider)
|
||||||
{
|
{
|
||||||
|
@ -2217,10 +2334,9 @@ nsChromeRegistry::InstallProvider(const nsACString& aProviderType,
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
// Get the literal for our script access.
|
// Get the literal for our script access.
|
||||||
nsAutoString scriptstr;
|
|
||||||
scriptstr.Assign(NS_LITERAL_STRING("false"));
|
|
||||||
nsCOMPtr<nsIRDFLiteral> scriptLiteral;
|
nsCOMPtr<nsIRDFLiteral> scriptLiteral;
|
||||||
rv = mRDFService->GetLiteral(scriptstr.get(), getter_AddRefs(scriptLiteral));
|
rv = mRDFService->GetLiteral(NS_LITERAL_STRING("false").get(),
|
||||||
|
getter_AddRefs(scriptLiteral));
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
// Build the prefix string. Only resources with this prefix string will have their
|
// Build the prefix string. Only resources with this prefix string will have their
|
||||||
|
@ -2639,8 +2755,8 @@ nsChromeRegistry::GetProfileRoot(nsACString& aFileURL)
|
||||||
|
|
||||||
// copy along
|
// copy along
|
||||||
// It aint an error if these files dont exist
|
// It aint an error if these files dont exist
|
||||||
(void) defaultUserContentFile->CopyToNative(userChromeDir, nsCString());
|
(void) defaultUserContentFile->CopyToNative(userChromeDir, NS_LITERAL_CSTRING(""));
|
||||||
(void) defaultUserChromeFile->CopyToNative(userChromeDir, nsCString());
|
(void) defaultUserChromeFile->CopyToNative(userChromeDir, NS_LITERAL_CSTRING(""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (NS_FAILED(rv))
|
if (NS_FAILED(rv))
|
||||||
|
@ -2713,7 +2829,7 @@ nsChromeRegistry::ReloadChrome()
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsChromeRegistry::GetArcs(nsIRDFDataSource* aDataSource,
|
nsChromeRegistry::GetArcs(nsIRDFDataSource* aDataSource,
|
||||||
const nsCString& aType,
|
const nsACString& aType,
|
||||||
nsISimpleEnumerator** aResult)
|
nsISimpleEnumerator** aResult)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIRDFContainer> container;
|
nsCOMPtr<nsIRDFContainer> container;
|
||||||
|
@ -2803,7 +2919,7 @@ nsChromeRegistry::GetAgentSheets(nsIDocShell* aDocShell, nsISupportsArray **aRes
|
||||||
elt->GetAttribute(NS_LITERAL_STRING("usechromesheets"), sheets);
|
elt->GetAttribute(NS_LITERAL_STRING("usechromesheets"), sheets);
|
||||||
if (!sheets.IsEmpty()) {
|
if (!sheets.IsEmpty()) {
|
||||||
// Construct the URIs and try to load each sheet.
|
// Construct the URIs and try to load each sheet.
|
||||||
nsCAutoString sheetsStr; sheetsStr.AssignWithConversion(sheets);
|
|
||||||
char* str = ToNewCString(sheets);
|
char* str = ToNewCString(sheets);
|
||||||
char* newStr;
|
char* newStr;
|
||||||
char* token = nsCRT::strtok( str, ", ", &newStr );
|
char* token = nsCRT::strtok( str, ", ", &newStr );
|
||||||
|
@ -2919,7 +3035,7 @@ nsresult nsChromeRegistry::GetUserSheetURL(PRBool aIsChrome, nsACString & aURL)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult nsChromeRegistry::GetFormSheetURL(nsCString& aURL)
|
nsresult nsChromeRegistry::GetFormSheetURL(nsACString& aURL)
|
||||||
{
|
{
|
||||||
aURL = mUseXBLForms ? "chrome://forms/skin/forms.css" : "resource:/res/forms.css";
|
aURL = mUseXBLForms ? "chrome://forms/skin/forms.css" : "resource:/res/forms.css";
|
||||||
|
|
||||||
|
@ -3310,14 +3426,14 @@ NS_IMETHODIMP nsChromeRegistry::Observe(nsISupports *aSubject, const char *aTopi
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsChromeRegistry::CheckThemeVersion(const PRUnichar *aSkin,
|
NS_IMETHODIMP nsChromeRegistry::CheckThemeVersion(const nsACString& aSkin,
|
||||||
PRBool* aResult)
|
PRBool* aResult)
|
||||||
{
|
{
|
||||||
return CheckProviderVersion(NS_LITERAL_CSTRING("skin"), aSkin, mSkinVersion, aResult);
|
return CheckProviderVersion(NS_LITERAL_CSTRING("skin"), aSkin, mSkinVersion, aResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NS_IMETHODIMP nsChromeRegistry::CheckLocaleVersion(const PRUnichar *aLocale,
|
NS_IMETHODIMP nsChromeRegistry::CheckLocaleVersion(const nsACString& aLocale,
|
||||||
PRBool* aResult)
|
PRBool* aResult)
|
||||||
{
|
{
|
||||||
nsCAutoString provider("locale");
|
nsCAutoString provider("locale");
|
||||||
|
@ -3327,7 +3443,7 @@ NS_IMETHODIMP nsChromeRegistry::CheckLocaleVersion(const PRUnichar *aLocale,
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsChromeRegistry::CheckProviderVersion (const nsACString& aProviderType,
|
nsChromeRegistry::CheckProviderVersion (const nsACString& aProviderType,
|
||||||
const PRUnichar* aProviderName,
|
const nsACString& aProviderName,
|
||||||
nsIRDFResource* aSelectionArc,
|
nsIRDFResource* aSelectionArc,
|
||||||
PRBool *aCompatible)
|
PRBool *aCompatible)
|
||||||
{
|
{
|
||||||
|
@ -3338,7 +3454,7 @@ nsChromeRegistry::CheckProviderVersion (const nsACString& aProviderType,
|
||||||
nsCAutoString resourceStr( "urn:mozilla:" );
|
nsCAutoString resourceStr( "urn:mozilla:" );
|
||||||
resourceStr += aProviderType;
|
resourceStr += aProviderType;
|
||||||
resourceStr += ":";
|
resourceStr += ":";
|
||||||
resourceStr.AppendWithConversion(aProviderName);
|
resourceStr += aProviderName;
|
||||||
|
|
||||||
// Obtain the provider resource.
|
// Obtain the provider resource.
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
|
|
|
@ -53,7 +53,7 @@ class nsIDocument;
|
||||||
#include "nsIObserver.h"
|
#include "nsIObserver.h"
|
||||||
#include "nsWeakReference.h"
|
#include "nsWeakReference.h"
|
||||||
#include "nsString.h"
|
#include "nsString.h"
|
||||||
|
#include "nsIZipReader.h"
|
||||||
|
|
||||||
// for component registration
|
// for component registration
|
||||||
// {D8C7D8A2-E84C-11d2-BF87-00105A1B0627}
|
// {D8C7D8A2-E84C-11d2-BF87-00105A1B0627}
|
||||||
|
@ -111,7 +111,7 @@ protected:
|
||||||
nsresult LoadStyleSheetWithURL(nsIURI* aURL, nsICSSStyleSheet** aSheet);
|
nsresult LoadStyleSheetWithURL(nsIURI* aURL, nsICSSStyleSheet** aSheet);
|
||||||
|
|
||||||
nsresult GetUserSheetURL(PRBool aIsChrome, nsACString & aURL);
|
nsresult GetUserSheetURL(PRBool aIsChrome, nsACString & aURL);
|
||||||
nsresult GetFormSheetURL(nsCString& aURL);
|
nsresult GetFormSheetURL(nsACString& aURL);
|
||||||
|
|
||||||
nsresult LoadInstallDataSource();
|
nsresult LoadInstallDataSource();
|
||||||
nsresult LoadProfileDataSource();
|
nsresult LoadProfileDataSource();
|
||||||
|
@ -130,7 +130,7 @@ private:
|
||||||
nsresult RefreshWindow(nsIDOMWindowInternal* aWindow);
|
nsresult RefreshWindow(nsIDOMWindowInternal* aWindow);
|
||||||
|
|
||||||
nsresult GetArcs(nsIRDFDataSource* aDataSource,
|
nsresult GetArcs(nsIRDFDataSource* aDataSource,
|
||||||
const nsCString& aType,
|
const nsACString& aType,
|
||||||
nsISimpleEnumerator** aResult);
|
nsISimpleEnumerator** aResult);
|
||||||
|
|
||||||
nsresult AddToCompositeDataSource(PRBool aUseProfile);
|
nsresult AddToCompositeDataSource(PRBool aUseProfile);
|
||||||
|
@ -139,6 +139,12 @@ private:
|
||||||
const nsACString& aProvider,
|
const nsACString& aProvider,
|
||||||
nsACString& aBaseURL);
|
nsACString& aBaseURL);
|
||||||
|
|
||||||
|
nsresult InitOverrideJAR();
|
||||||
|
nsresult GetOverrideURL(const nsACString& aPackage,
|
||||||
|
const nsACString& aProvider,
|
||||||
|
const nsACString& aPath,
|
||||||
|
nsACString& aResult);
|
||||||
|
|
||||||
nsresult FindProvider(const nsACString& aPackage,
|
nsresult FindProvider(const nsACString& aPackage,
|
||||||
const nsACString& aProvider,
|
const nsACString& aProvider,
|
||||||
nsIRDFResource *aArc,
|
nsIRDFResource *aArc,
|
||||||
|
@ -147,7 +153,7 @@ private:
|
||||||
nsresult SelectPackageInProvider(nsIRDFResource *aPackageList,
|
nsresult SelectPackageInProvider(nsIRDFResource *aPackageList,
|
||||||
const nsACString& aPackage,
|
const nsACString& aPackage,
|
||||||
const nsACString& aProvider,
|
const nsACString& aProvider,
|
||||||
const nsCString& aProviderName,
|
const nsACString& aProviderName,
|
||||||
nsIRDFResource *aArc,
|
nsIRDFResource *aArc,
|
||||||
nsIRDFNode **aSelectedProvider);
|
nsIRDFNode **aSelectedProvider);
|
||||||
|
|
||||||
|
@ -177,7 +183,7 @@ private:
|
||||||
nsACString& aResult);
|
nsACString& aResult);
|
||||||
|
|
||||||
nsresult CheckProviderVersion (const nsACString& aProviderType,
|
nsresult CheckProviderVersion (const nsACString& aProviderType,
|
||||||
const PRUnichar* aProviderName,
|
const nsACString& aProviderName,
|
||||||
nsIRDFResource* aSelectionArc,
|
nsIRDFResource* aSelectionArc,
|
||||||
PRBool *aCompatible);
|
PRBool *aCompatible);
|
||||||
|
|
||||||
|
@ -239,6 +245,9 @@ protected:
|
||||||
nsCOMPtr<nsICSSStyleSheet> mUserContentSheet;
|
nsCOMPtr<nsICSSStyleSheet> mUserContentSheet;
|
||||||
nsCOMPtr<nsICSSStyleSheet> mFormSheet;
|
nsCOMPtr<nsICSSStyleSheet> mFormSheet;
|
||||||
|
|
||||||
|
nsCOMPtr<nsIZipReader> mOverrideJAR;
|
||||||
|
nsCString mOverrideJARURL;
|
||||||
|
|
||||||
PRBool mUseXBLForms;
|
PRBool mUseXBLForms;
|
||||||
|
|
||||||
PRPackedBool mInstallInitialized;
|
PRPackedBool mInstallInitialized;
|
||||||
|
|
|
@ -37,6 +37,7 @@ REQUIRES = xpcom \
|
||||||
rdf \
|
rdf \
|
||||||
necko \
|
necko \
|
||||||
content \
|
content \
|
||||||
|
jar \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
CPPSRCS = nsChromeFactory.cpp
|
CPPSRCS = nsChromeFactory.cpp
|
||||||
|
|
|
@ -105,8 +105,8 @@ interface nsIXULChromeRegistry : nsIChromeRegistry {
|
||||||
/* runtimeProvider == true: don't assert the runtime change */
|
/* runtimeProvider == true: don't assert the runtime change */
|
||||||
void setRuntimeProvider(in boolean runtimeProvider);
|
void setRuntimeProvider(in boolean runtimeProvider);
|
||||||
|
|
||||||
boolean checkThemeVersion(in wstring skinName);
|
boolean checkThemeVersion(in ACString skinName);
|
||||||
boolean checkLocaleVersion(in wstring localeName);
|
boolean checkLocaleVersion(in ACString localeName);
|
||||||
|
|
||||||
/* Apply skin/locale to a specific package */
|
/* Apply skin/locale to a specific package */
|
||||||
void selectSkinForPackage(in ACString skinName,
|
void selectSkinForPackage(in ACString skinName,
|
||||||
|
|
|
@ -46,6 +46,7 @@ REQUIRES = xpcom \
|
||||||
docshell \
|
docshell \
|
||||||
imglib2 \
|
imglib2 \
|
||||||
xpconnect \
|
xpconnect \
|
||||||
|
jar \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
CPPSRCS = \
|
CPPSRCS = \
|
||||||
|
|
|
@ -539,6 +539,11 @@ nsChromeRegistry::ConvertChromeURL(nsIURI* aChromeURL, nsACString& aResult)
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCAutoString finalURL;
|
nsCAutoString finalURL;
|
||||||
|
|
||||||
|
rv = GetOverrideURL(package, provider, remaining, finalURL);
|
||||||
|
if (NS_SUCCEEDED(rv))
|
||||||
|
return NS_OK;
|
||||||
|
|
||||||
rv = GetBaseURL(package, provider, finalURL);
|
rv = GetBaseURL(package, provider, finalURL);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
|
@ -658,10 +663,122 @@ nsChromeRegistry::GetBaseURL(const nsACString& aPackage,
|
||||||
}
|
}
|
||||||
|
|
||||||
// From this resource, follow the "baseURL" arc.
|
// From this resource, follow the "baseURL" arc.
|
||||||
return nsChromeRegistry::FollowArc(mChromeDataSource,
|
return FollowArc(mChromeDataSource, aBaseURL, resource, mBaseURL);
|
||||||
aBaseURL,
|
}
|
||||||
resource,
|
|
||||||
mBaseURL);
|
nsresult
|
||||||
|
nsChromeRegistry::GetOverrideURL(const nsACString& aPackage,
|
||||||
|
const nsACString& aProvider,
|
||||||
|
const nsACString& aPath,
|
||||||
|
nsACString& aResult)
|
||||||
|
{
|
||||||
|
nsresult rv = InitOverrideJAR();
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
|
// ok, if we get here, we have an override JAR
|
||||||
|
|
||||||
|
aResult.SetCapacity(mOverrideJARURL.Length() +
|
||||||
|
aPackage.Length() +
|
||||||
|
aProvider.Length() +
|
||||||
|
aPath.Length() + 2);
|
||||||
|
|
||||||
|
aResult = mOverrideJARURL;
|
||||||
|
aResult += aPackage;
|
||||||
|
aResult += '/';
|
||||||
|
aResult += aProvider;
|
||||||
|
aResult += '/';
|
||||||
|
|
||||||
|
// skins and locales get their name tacked on, like
|
||||||
|
// skin/modern/foo.css or
|
||||||
|
// locale/en-US/navigator.properties
|
||||||
|
if (aProvider.Equals(NS_LITERAL_CSTRING("skin")) ||
|
||||||
|
aProvider.Equals(NS_LITERAL_CSTRING("locale"))) {
|
||||||
|
|
||||||
|
// little hack here to get the right arc
|
||||||
|
nsIRDFResource* providerArc;
|
||||||
|
if (aProvider.Equals("skin"))
|
||||||
|
providerArc = mSelectedSkin;
|
||||||
|
else
|
||||||
|
providerArc = mSelectedLocale;
|
||||||
|
|
||||||
|
nsCAutoString selectedProvider;
|
||||||
|
rv = GetSelectedProvider(aPackage, aProvider, providerArc, selectedProvider);
|
||||||
|
|
||||||
|
if (NS_SUCCEEDED(rv)) {
|
||||||
|
aResult += selectedProvider;
|
||||||
|
aResult += '/';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
aResult += aPath;
|
||||||
|
|
||||||
|
nsCOMPtr<nsIZipEntry> zipEntry;
|
||||||
|
rv = mOverrideJAR->GetEntry(PromiseFlatCString(aResult).get(),
|
||||||
|
getter_AddRefs(zipEntry));
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
aResult.Truncate();
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
nsChromeRegistry::InitOverrideJAR()
|
||||||
|
{
|
||||||
|
// generic failure if we know there's no override
|
||||||
|
if (mSearchedForOverride && !mOverrideJAR)
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
|
mSearchedForOverride = PR_TRUE;
|
||||||
|
|
||||||
|
nsresult rv;
|
||||||
|
//
|
||||||
|
// look for custom.jar
|
||||||
|
//
|
||||||
|
nsCOMPtr<nsIFile> overrideFile;
|
||||||
|
rv = GetInstallRoot(getter_AddRefs(overrideFile));
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
|
rv = overrideFile->AppendNative(NS_LITERAL_CSTRING("custom.jar"));
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
|
PRBool exists;
|
||||||
|
rv = overrideFile->Exists(&exists);
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
|
// ok, if the file doesn't exist, its just a generic failure
|
||||||
|
if (!exists)
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
|
//
|
||||||
|
// cache the url so we can later append
|
||||||
|
//
|
||||||
|
mOverrideJARURL.Assign("jar:");
|
||||||
|
nsCAutoString jarURL;
|
||||||
|
rv = NS_GetURLSpecFromFile(overrideFile, jarURL);
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
|
mOverrideJARURL.Append(jarURL);
|
||||||
|
mOverrideJARURL.Append("!/");
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
|
//
|
||||||
|
// also cache the zip file itself
|
||||||
|
//
|
||||||
|
nsCOMPtr<nsIZipReaderCache> readerCache =
|
||||||
|
do_CreateInstance("@mozilla.org/libjar/zip-reader-cache;1", &rv);
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
|
rv = readerCache->Init(32);
|
||||||
|
|
||||||
|
rv = readerCache->GetZip(overrideFile, getter_AddRefs(mOverrideJAR));
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
mOverrideJARURL.Truncate();
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// locate
|
// locate
|
||||||
|
@ -746,7 +863,7 @@ nsresult
|
||||||
nsChromeRegistry::SelectPackageInProvider(nsIRDFResource *aPackageList,
|
nsChromeRegistry::SelectPackageInProvider(nsIRDFResource *aPackageList,
|
||||||
const nsACString& aPackage,
|
const nsACString& aPackage,
|
||||||
const nsACString& aProvider,
|
const nsACString& aProvider,
|
||||||
const nsCString& aProviderName,
|
const nsACString& aProviderName,
|
||||||
nsIRDFResource *aArc,
|
nsIRDFResource *aArc,
|
||||||
nsIRDFNode **aSelectedProvider)
|
nsIRDFNode **aSelectedProvider)
|
||||||
{
|
{
|
||||||
|
@ -2217,10 +2334,9 @@ nsChromeRegistry::InstallProvider(const nsACString& aProviderType,
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
// Get the literal for our script access.
|
// Get the literal for our script access.
|
||||||
nsAutoString scriptstr;
|
|
||||||
scriptstr.Assign(NS_LITERAL_STRING("false"));
|
|
||||||
nsCOMPtr<nsIRDFLiteral> scriptLiteral;
|
nsCOMPtr<nsIRDFLiteral> scriptLiteral;
|
||||||
rv = mRDFService->GetLiteral(scriptstr.get(), getter_AddRefs(scriptLiteral));
|
rv = mRDFService->GetLiteral(NS_LITERAL_STRING("false").get(),
|
||||||
|
getter_AddRefs(scriptLiteral));
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
// Build the prefix string. Only resources with this prefix string will have their
|
// Build the prefix string. Only resources with this prefix string will have their
|
||||||
|
@ -2639,8 +2755,8 @@ nsChromeRegistry::GetProfileRoot(nsACString& aFileURL)
|
||||||
|
|
||||||
// copy along
|
// copy along
|
||||||
// It aint an error if these files dont exist
|
// It aint an error if these files dont exist
|
||||||
(void) defaultUserContentFile->CopyToNative(userChromeDir, nsCString());
|
(void) defaultUserContentFile->CopyToNative(userChromeDir, NS_LITERAL_CSTRING(""));
|
||||||
(void) defaultUserChromeFile->CopyToNative(userChromeDir, nsCString());
|
(void) defaultUserChromeFile->CopyToNative(userChromeDir, NS_LITERAL_CSTRING(""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (NS_FAILED(rv))
|
if (NS_FAILED(rv))
|
||||||
|
@ -2713,7 +2829,7 @@ nsChromeRegistry::ReloadChrome()
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsChromeRegistry::GetArcs(nsIRDFDataSource* aDataSource,
|
nsChromeRegistry::GetArcs(nsIRDFDataSource* aDataSource,
|
||||||
const nsCString& aType,
|
const nsACString& aType,
|
||||||
nsISimpleEnumerator** aResult)
|
nsISimpleEnumerator** aResult)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIRDFContainer> container;
|
nsCOMPtr<nsIRDFContainer> container;
|
||||||
|
@ -2803,7 +2919,7 @@ nsChromeRegistry::GetAgentSheets(nsIDocShell* aDocShell, nsISupportsArray **aRes
|
||||||
elt->GetAttribute(NS_LITERAL_STRING("usechromesheets"), sheets);
|
elt->GetAttribute(NS_LITERAL_STRING("usechromesheets"), sheets);
|
||||||
if (!sheets.IsEmpty()) {
|
if (!sheets.IsEmpty()) {
|
||||||
// Construct the URIs and try to load each sheet.
|
// Construct the URIs and try to load each sheet.
|
||||||
nsCAutoString sheetsStr; sheetsStr.AssignWithConversion(sheets);
|
|
||||||
char* str = ToNewCString(sheets);
|
char* str = ToNewCString(sheets);
|
||||||
char* newStr;
|
char* newStr;
|
||||||
char* token = nsCRT::strtok( str, ", ", &newStr );
|
char* token = nsCRT::strtok( str, ", ", &newStr );
|
||||||
|
@ -2919,7 +3035,7 @@ nsresult nsChromeRegistry::GetUserSheetURL(PRBool aIsChrome, nsACString & aURL)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult nsChromeRegistry::GetFormSheetURL(nsCString& aURL)
|
nsresult nsChromeRegistry::GetFormSheetURL(nsACString& aURL)
|
||||||
{
|
{
|
||||||
aURL = mUseXBLForms ? "chrome://forms/skin/forms.css" : "resource:/res/forms.css";
|
aURL = mUseXBLForms ? "chrome://forms/skin/forms.css" : "resource:/res/forms.css";
|
||||||
|
|
||||||
|
@ -3310,14 +3426,14 @@ NS_IMETHODIMP nsChromeRegistry::Observe(nsISupports *aSubject, const char *aTopi
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsChromeRegistry::CheckThemeVersion(const PRUnichar *aSkin,
|
NS_IMETHODIMP nsChromeRegistry::CheckThemeVersion(const nsACString& aSkin,
|
||||||
PRBool* aResult)
|
PRBool* aResult)
|
||||||
{
|
{
|
||||||
return CheckProviderVersion(NS_LITERAL_CSTRING("skin"), aSkin, mSkinVersion, aResult);
|
return CheckProviderVersion(NS_LITERAL_CSTRING("skin"), aSkin, mSkinVersion, aResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NS_IMETHODIMP nsChromeRegistry::CheckLocaleVersion(const PRUnichar *aLocale,
|
NS_IMETHODIMP nsChromeRegistry::CheckLocaleVersion(const nsACString& aLocale,
|
||||||
PRBool* aResult)
|
PRBool* aResult)
|
||||||
{
|
{
|
||||||
nsCAutoString provider("locale");
|
nsCAutoString provider("locale");
|
||||||
|
@ -3327,7 +3443,7 @@ NS_IMETHODIMP nsChromeRegistry::CheckLocaleVersion(const PRUnichar *aLocale,
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsChromeRegistry::CheckProviderVersion (const nsACString& aProviderType,
|
nsChromeRegistry::CheckProviderVersion (const nsACString& aProviderType,
|
||||||
const PRUnichar* aProviderName,
|
const nsACString& aProviderName,
|
||||||
nsIRDFResource* aSelectionArc,
|
nsIRDFResource* aSelectionArc,
|
||||||
PRBool *aCompatible)
|
PRBool *aCompatible)
|
||||||
{
|
{
|
||||||
|
@ -3338,7 +3454,7 @@ nsChromeRegistry::CheckProviderVersion (const nsACString& aProviderType,
|
||||||
nsCAutoString resourceStr( "urn:mozilla:" );
|
nsCAutoString resourceStr( "urn:mozilla:" );
|
||||||
resourceStr += aProviderType;
|
resourceStr += aProviderType;
|
||||||
resourceStr += ":";
|
resourceStr += ":";
|
||||||
resourceStr.AppendWithConversion(aProviderName);
|
resourceStr += aProviderName;
|
||||||
|
|
||||||
// Obtain the provider resource.
|
// Obtain the provider resource.
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
|
|
|
@ -53,7 +53,7 @@ class nsIDocument;
|
||||||
#include "nsIObserver.h"
|
#include "nsIObserver.h"
|
||||||
#include "nsWeakReference.h"
|
#include "nsWeakReference.h"
|
||||||
#include "nsString.h"
|
#include "nsString.h"
|
||||||
|
#include "nsIZipReader.h"
|
||||||
|
|
||||||
// for component registration
|
// for component registration
|
||||||
// {D8C7D8A2-E84C-11d2-BF87-00105A1B0627}
|
// {D8C7D8A2-E84C-11d2-BF87-00105A1B0627}
|
||||||
|
@ -111,7 +111,7 @@ protected:
|
||||||
nsresult LoadStyleSheetWithURL(nsIURI* aURL, nsICSSStyleSheet** aSheet);
|
nsresult LoadStyleSheetWithURL(nsIURI* aURL, nsICSSStyleSheet** aSheet);
|
||||||
|
|
||||||
nsresult GetUserSheetURL(PRBool aIsChrome, nsACString & aURL);
|
nsresult GetUserSheetURL(PRBool aIsChrome, nsACString & aURL);
|
||||||
nsresult GetFormSheetURL(nsCString& aURL);
|
nsresult GetFormSheetURL(nsACString& aURL);
|
||||||
|
|
||||||
nsresult LoadInstallDataSource();
|
nsresult LoadInstallDataSource();
|
||||||
nsresult LoadProfileDataSource();
|
nsresult LoadProfileDataSource();
|
||||||
|
@ -130,7 +130,7 @@ private:
|
||||||
nsresult RefreshWindow(nsIDOMWindowInternal* aWindow);
|
nsresult RefreshWindow(nsIDOMWindowInternal* aWindow);
|
||||||
|
|
||||||
nsresult GetArcs(nsIRDFDataSource* aDataSource,
|
nsresult GetArcs(nsIRDFDataSource* aDataSource,
|
||||||
const nsCString& aType,
|
const nsACString& aType,
|
||||||
nsISimpleEnumerator** aResult);
|
nsISimpleEnumerator** aResult);
|
||||||
|
|
||||||
nsresult AddToCompositeDataSource(PRBool aUseProfile);
|
nsresult AddToCompositeDataSource(PRBool aUseProfile);
|
||||||
|
@ -139,6 +139,12 @@ private:
|
||||||
const nsACString& aProvider,
|
const nsACString& aProvider,
|
||||||
nsACString& aBaseURL);
|
nsACString& aBaseURL);
|
||||||
|
|
||||||
|
nsresult InitOverrideJAR();
|
||||||
|
nsresult GetOverrideURL(const nsACString& aPackage,
|
||||||
|
const nsACString& aProvider,
|
||||||
|
const nsACString& aPath,
|
||||||
|
nsACString& aResult);
|
||||||
|
|
||||||
nsresult FindProvider(const nsACString& aPackage,
|
nsresult FindProvider(const nsACString& aPackage,
|
||||||
const nsACString& aProvider,
|
const nsACString& aProvider,
|
||||||
nsIRDFResource *aArc,
|
nsIRDFResource *aArc,
|
||||||
|
@ -147,7 +153,7 @@ private:
|
||||||
nsresult SelectPackageInProvider(nsIRDFResource *aPackageList,
|
nsresult SelectPackageInProvider(nsIRDFResource *aPackageList,
|
||||||
const nsACString& aPackage,
|
const nsACString& aPackage,
|
||||||
const nsACString& aProvider,
|
const nsACString& aProvider,
|
||||||
const nsCString& aProviderName,
|
const nsACString& aProviderName,
|
||||||
nsIRDFResource *aArc,
|
nsIRDFResource *aArc,
|
||||||
nsIRDFNode **aSelectedProvider);
|
nsIRDFNode **aSelectedProvider);
|
||||||
|
|
||||||
|
@ -177,7 +183,7 @@ private:
|
||||||
nsACString& aResult);
|
nsACString& aResult);
|
||||||
|
|
||||||
nsresult CheckProviderVersion (const nsACString& aProviderType,
|
nsresult CheckProviderVersion (const nsACString& aProviderType,
|
||||||
const PRUnichar* aProviderName,
|
const nsACString& aProviderName,
|
||||||
nsIRDFResource* aSelectionArc,
|
nsIRDFResource* aSelectionArc,
|
||||||
PRBool *aCompatible);
|
PRBool *aCompatible);
|
||||||
|
|
||||||
|
@ -239,6 +245,9 @@ protected:
|
||||||
nsCOMPtr<nsICSSStyleSheet> mUserContentSheet;
|
nsCOMPtr<nsICSSStyleSheet> mUserContentSheet;
|
||||||
nsCOMPtr<nsICSSStyleSheet> mFormSheet;
|
nsCOMPtr<nsICSSStyleSheet> mFormSheet;
|
||||||
|
|
||||||
|
nsCOMPtr<nsIZipReader> mOverrideJAR;
|
||||||
|
nsCString mOverrideJARURL;
|
||||||
|
|
||||||
PRBool mUseXBLForms;
|
PRBool mUseXBLForms;
|
||||||
|
|
||||||
PRPackedBool mInstallInitialized;
|
PRPackedBool mInstallInitialized;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче