Enable add-on chrome packages to ne disabled without being uninstalled. Bug 170432, r=blake, sr=brendan

This commit is contained in:
hyatt%netscape.com 2002-09-24 02:07:20 +00:00
Родитель f8d04505a4
Коммит 667c0366cf
7 изменённых файлов: 164 добавлений и 4 удалений

Просмотреть файл

@ -143,6 +143,13 @@ interface nsIXULChromeRegistry : nsIChromeRegistry {
boolean allowScriptsForSkin(in nsIURI url);
/* Whether or not an addon package can dynamically overlay another package.
You can use these APIs to effectively disable a chrome add-on without
uninstalling it. */
void setAllowOverlaysForPackage(in wstring packageName, in boolean allowOverlays);
boolean overlaysAllowedForPackage(in wstring packageName);
boolean isOverlayAllowed(in nsIURI aChromeURL);
/* Installation APIs */
void installSkin(in string baseURL,
in boolean useProfile,

Просмотреть файл

@ -142,6 +142,7 @@ DEFINE_RDF_VOCAB(CHROME_URI, CHROME, hasStylesheets);
DEFINE_RDF_VOCAB(CHROME_URI, CHROME, skinVersion);
DEFINE_RDF_VOCAB(CHROME_URI, CHROME, localeVersion);
DEFINE_RDF_VOCAB(CHROME_URI, CHROME, packageVersion);
DEFINE_RDF_VOCAB(CHROME_URI, CHROME, disabled);
////////////////////////////////////////////////////////////////////////////////
@ -363,6 +364,9 @@ nsChromeRegistry::Init()
rv = mRDFService->GetResource(kURICHROME_packageVersion, getter_AddRefs(mPackageVersion));
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF resource");
rv = mRDFService->GetResource(kURICHROME_disabled, getter_AddRefs(mDisabled));
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF resource");
nsCOMPtr<nsIObserverService> observerService =
do_GetService("@mozilla.org/observer-service;1", &rv);
if (observerService) {
@ -1064,7 +1068,7 @@ nsChromeRegistry::GetDynamicInfo(nsIURI *aChromeURL, PRBool aIsOverlay,
nsCAutoString lookup;
rv = aChromeURL->GetSpec(lookup);
if (NS_FAILED(rv)) return rv;
// Get the chromeResource from this lookup string
nsCOMPtr<nsIRDFResource> chromeResource;
rv = GetResource(lookup, getter_AddRefs(chromeResource));
@ -2609,6 +2613,71 @@ nsChromeRegistry::InstallProvider(const nsACString& aProviderType,
return rv;
}
NS_IMETHODIMP nsChromeRegistry::SetAllowOverlaysForPackage(const PRUnichar *aPackageName, PRBool allowOverlays)
{
nsCAutoString package("urn:mozilla:package:");
package.AppendWithConversion(aPackageName);
// Obtain the package resource.
nsCOMPtr<nsIRDFResource> packageResource;
nsresult rv = GetResource(package, getter_AddRefs(packageResource));
if (NS_FAILED(rv)) {
NS_ERROR("Unable to obtain the package resource.");
return rv;
}
NS_ASSERTION(packageResource, "failed to get packageResource");
nsCOMPtr<nsIRDFDataSource> dataSource;
rv = LoadDataSource(kChromeFileName, getter_AddRefs(dataSource), PR_TRUE, nsnull);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIRDFLiteral> trueLiteral;
mRDFService->GetLiteral(NS_LITERAL_STRING("true").get(), getter_AddRefs(trueLiteral));
nsChromeRegistry::UpdateArc(dataSource, packageResource,
mDisabled,
trueLiteral, allowOverlays);
nsCOMPtr<nsIRDFRemoteDataSource> remote = do_QueryInterface(dataSource, &rv);
if (NS_FAILED(rv)) return rv;
rv = remote->Flush();
return rv;
}
NS_IMETHODIMP nsChromeRegistry::OverlaysAllowedForPackage(const PRUnichar *aPackageName, PRBool *aRetval)
{
// Get the chrome resource for the package.
nsCAutoString package( "urn:mozilla:package:" );
package.AppendWithConversion(aPackageName);
// Obtain the package resource.
nsresult rv = NS_OK;
nsCOMPtr<nsIRDFResource> packageResource;
rv = GetResource(package, getter_AddRefs(packageResource));
if (NS_FAILED(rv)) {
NS_ERROR("Unable to obtain the package resource.");
return rv;
}
NS_ASSERTION(packageResource, "failed to get packageResource");
// See if the disabled arc is set for the package.
nsCAutoString disabled;
nsChromeRegistry::FollowArc(mChromeDataSource, disabled, packageResource, mDisabled);
*aRetval = disabled.IsEmpty();
return NS_OK;
}
NS_IMETHODIMP nsChromeRegistry::IsOverlayAllowed(nsIURI *aChromeURL, PRBool *aRetval)
{
nsCAutoString package, provider, file;
nsresult rv = SplitURL(aChromeURL, package, provider, file);
if (NS_FAILED(rv)) return rv;
nsAutoString packageStr; packageStr.AssignWithConversion(package.get());
return OverlaysAllowedForPackage(packageStr.get(), aRetval);
}
NS_IMETHODIMP nsChromeRegistry::InstallSkin(const char* aBaseURL, PRBool aUseProfile, PRBool aAllowScripts)
{
return InstallProvider(NS_LITERAL_CSTRING("skin"),

Просмотреть файл

@ -238,6 +238,7 @@ protected:
nsCOMPtr<nsIRDFResource> mSkinVersion;
nsCOMPtr<nsIRDFResource> mLocaleVersion;
nsCOMPtr<nsIRDFResource> mPackageVersion;
nsCOMPtr<nsIRDFResource> mDisabled;
// Style Sheets
nsCOMPtr<nsICSSStyleSheet> mScrollbarSheet;

Просмотреть файл

@ -5446,8 +5446,14 @@ nsXULDocument::AddChromeOverlays()
if (!uri)
return NS_OK;
mUnloadedOverlays->AppendElement(uri);
// See if this package is enabled/disabled. If it
// is disabled, we shouldn't append this element to
// the unloaded overlay list.
PRBool allowed = PR_TRUE;
reg->IsOverlayAllowed(uri, &allowed);
if (allowed)
mUnloadedOverlays->AppendElement(uri);
oe->HasMoreElements(&moreElements);
}

Просмотреть файл

@ -143,6 +143,13 @@ interface nsIXULChromeRegistry : nsIChromeRegistry {
boolean allowScriptsForSkin(in nsIURI url);
/* Whether or not an addon package can dynamically overlay another package.
You can use these APIs to effectively disable a chrome add-on without
uninstalling it. */
void setAllowOverlaysForPackage(in wstring packageName, in boolean allowOverlays);
boolean overlaysAllowedForPackage(in wstring packageName);
boolean isOverlayAllowed(in nsIURI aChromeURL);
/* Installation APIs */
void installSkin(in string baseURL,
in boolean useProfile,

Просмотреть файл

@ -142,6 +142,7 @@ DEFINE_RDF_VOCAB(CHROME_URI, CHROME, hasStylesheets);
DEFINE_RDF_VOCAB(CHROME_URI, CHROME, skinVersion);
DEFINE_RDF_VOCAB(CHROME_URI, CHROME, localeVersion);
DEFINE_RDF_VOCAB(CHROME_URI, CHROME, packageVersion);
DEFINE_RDF_VOCAB(CHROME_URI, CHROME, disabled);
////////////////////////////////////////////////////////////////////////////////
@ -363,6 +364,9 @@ nsChromeRegistry::Init()
rv = mRDFService->GetResource(kURICHROME_packageVersion, getter_AddRefs(mPackageVersion));
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF resource");
rv = mRDFService->GetResource(kURICHROME_disabled, getter_AddRefs(mDisabled));
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF resource");
nsCOMPtr<nsIObserverService> observerService =
do_GetService("@mozilla.org/observer-service;1", &rv);
if (observerService) {
@ -1064,7 +1068,7 @@ nsChromeRegistry::GetDynamicInfo(nsIURI *aChromeURL, PRBool aIsOverlay,
nsCAutoString lookup;
rv = aChromeURL->GetSpec(lookup);
if (NS_FAILED(rv)) return rv;
// Get the chromeResource from this lookup string
nsCOMPtr<nsIRDFResource> chromeResource;
rv = GetResource(lookup, getter_AddRefs(chromeResource));
@ -2609,6 +2613,71 @@ nsChromeRegistry::InstallProvider(const nsACString& aProviderType,
return rv;
}
NS_IMETHODIMP nsChromeRegistry::SetAllowOverlaysForPackage(const PRUnichar *aPackageName, PRBool allowOverlays)
{
nsCAutoString package("urn:mozilla:package:");
package.AppendWithConversion(aPackageName);
// Obtain the package resource.
nsCOMPtr<nsIRDFResource> packageResource;
nsresult rv = GetResource(package, getter_AddRefs(packageResource));
if (NS_FAILED(rv)) {
NS_ERROR("Unable to obtain the package resource.");
return rv;
}
NS_ASSERTION(packageResource, "failed to get packageResource");
nsCOMPtr<nsIRDFDataSource> dataSource;
rv = LoadDataSource(kChromeFileName, getter_AddRefs(dataSource), PR_TRUE, nsnull);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIRDFLiteral> trueLiteral;
mRDFService->GetLiteral(NS_LITERAL_STRING("true").get(), getter_AddRefs(trueLiteral));
nsChromeRegistry::UpdateArc(dataSource, packageResource,
mDisabled,
trueLiteral, allowOverlays);
nsCOMPtr<nsIRDFRemoteDataSource> remote = do_QueryInterface(dataSource, &rv);
if (NS_FAILED(rv)) return rv;
rv = remote->Flush();
return rv;
}
NS_IMETHODIMP nsChromeRegistry::OverlaysAllowedForPackage(const PRUnichar *aPackageName, PRBool *aRetval)
{
// Get the chrome resource for the package.
nsCAutoString package( "urn:mozilla:package:" );
package.AppendWithConversion(aPackageName);
// Obtain the package resource.
nsresult rv = NS_OK;
nsCOMPtr<nsIRDFResource> packageResource;
rv = GetResource(package, getter_AddRefs(packageResource));
if (NS_FAILED(rv)) {
NS_ERROR("Unable to obtain the package resource.");
return rv;
}
NS_ASSERTION(packageResource, "failed to get packageResource");
// See if the disabled arc is set for the package.
nsCAutoString disabled;
nsChromeRegistry::FollowArc(mChromeDataSource, disabled, packageResource, mDisabled);
*aRetval = disabled.IsEmpty();
return NS_OK;
}
NS_IMETHODIMP nsChromeRegistry::IsOverlayAllowed(nsIURI *aChromeURL, PRBool *aRetval)
{
nsCAutoString package, provider, file;
nsresult rv = SplitURL(aChromeURL, package, provider, file);
if (NS_FAILED(rv)) return rv;
nsAutoString packageStr; packageStr.AssignWithConversion(package.get());
return OverlaysAllowedForPackage(packageStr.get(), aRetval);
}
NS_IMETHODIMP nsChromeRegistry::InstallSkin(const char* aBaseURL, PRBool aUseProfile, PRBool aAllowScripts)
{
return InstallProvider(NS_LITERAL_CSTRING("skin"),

Просмотреть файл

@ -238,6 +238,7 @@ protected:
nsCOMPtr<nsIRDFResource> mSkinVersion;
nsCOMPtr<nsIRDFResource> mLocaleVersion;
nsCOMPtr<nsIRDFResource> mPackageVersion;
nsCOMPtr<nsIRDFResource> mDisabled;
// Style Sheets
nsCOMPtr<nsICSSStyleSheet> mScrollbarSheet;