зеркало из https://github.com/mozilla/gecko-dev.git
Bug 229285 - separate nsIXULOverlayProvider from nsIXULChromeRegistry
r=bryner sr=hyatt
This commit is contained in:
Родитель
f7a95e4596
Коммит
386f40c13a
|
@ -43,6 +43,7 @@
|
|||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include "nsArrayEnumerator.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIChromeRegistry.h"
|
||||
#include "nsChromeRegistry.h"
|
||||
|
@ -146,107 +147,6 @@ DEFINE_RDF_VOCAB(CHROME_URI, CHROME, localeVersion);
|
|||
DEFINE_RDF_VOCAB(CHROME_URI, CHROME, packageVersion);
|
||||
DEFINE_RDF_VOCAB(CHROME_URI, CHROME, disabled);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class nsOverlayEnumerator : public nsISimpleEnumerator
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSISIMPLEENUMERATOR
|
||||
|
||||
nsOverlayEnumerator(nsISimpleEnumerator *aInstallArcs,
|
||||
nsISimpleEnumerator *aProfileArcs);
|
||||
virtual ~nsOverlayEnumerator();
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsISimpleEnumerator> mInstallArcs;
|
||||
nsCOMPtr<nsISimpleEnumerator> mProfileArcs;
|
||||
nsCOMPtr<nsISimpleEnumerator> mCurrentArcs;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsOverlayEnumerator, nsISimpleEnumerator)
|
||||
|
||||
nsOverlayEnumerator::nsOverlayEnumerator(nsISimpleEnumerator *aInstallArcs,
|
||||
nsISimpleEnumerator *aProfileArcs)
|
||||
: mInstallArcs(aInstallArcs),
|
||||
mProfileArcs(aProfileArcs)
|
||||
{
|
||||
}
|
||||
|
||||
nsOverlayEnumerator::~nsOverlayEnumerator()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsOverlayEnumerator::HasMoreElements(PRBool *aIsTrue)
|
||||
{
|
||||
*aIsTrue = PR_FALSE;
|
||||
if (!mProfileArcs) {
|
||||
if (!mInstallArcs)
|
||||
return NS_OK; // No arcs period. We default to false,
|
||||
return mInstallArcs->HasMoreElements(aIsTrue); // no profile arcs. use install arcs,
|
||||
}
|
||||
|
||||
nsresult rv = mProfileArcs->HasMoreElements(aIsTrue);
|
||||
if (*aIsTrue || !mInstallArcs)
|
||||
return rv;
|
||||
|
||||
return mInstallArcs->HasMoreElements(aIsTrue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsOverlayEnumerator::GetNext(nsISupports **aResult)
|
||||
{
|
||||
nsresult rv;
|
||||
*aResult = nsnull;
|
||||
|
||||
if (!mCurrentArcs) {
|
||||
// Start with the profile arcs.
|
||||
mCurrentArcs = mProfileArcs;
|
||||
if (!mCurrentArcs) {
|
||||
// No profile arcs, try the install arcs.
|
||||
mCurrentArcs = mInstallArcs;
|
||||
if (!mCurrentArcs)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
else if (mCurrentArcs == mProfileArcs) {
|
||||
// Check if we have more profile arcs.
|
||||
PRBool hasMore;
|
||||
rv = mCurrentArcs->HasMoreElements(&hasMore);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
if (!hasMore) {
|
||||
// No more profile arcs, try the install arcs.
|
||||
if (!mInstallArcs)
|
||||
return NS_ERROR_FAILURE;
|
||||
mCurrentArcs = mInstallArcs;
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISupports> supports;
|
||||
rv = mCurrentArcs->GetNext(getter_AddRefs(supports));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIRDFLiteral> value = do_QueryInterface(supports, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return NS_OK;
|
||||
|
||||
const PRUnichar* valueStr;
|
||||
rv = value->GetValueConst(&valueStr);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIURI> url;
|
||||
rv = NS_NewURI(getter_AddRefs(url), NS_ConvertUCS2toUTF8(valueStr));
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return NS_OK;
|
||||
|
||||
return CallQueryInterface(url, aResult);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsChromeRegistry::nsChromeRegistry() : mRDFService(nsnull),
|
||||
|
@ -310,7 +210,12 @@ nsChromeRegistry::~nsChromeRegistry()
|
|||
|
||||
}
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS4(nsChromeRegistry, nsIChromeRegistry, nsIXULChromeRegistry, nsIObserver, nsISupportsWeakReference)
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS5(nsChromeRegistry,
|
||||
nsIChromeRegistry,
|
||||
nsIXULChromeRegistry,
|
||||
nsIXULOverlayProvider,
|
||||
nsIObserver,
|
||||
nsISupportsWeakReference)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIChromeRegistry methods:
|
||||
|
@ -1094,7 +999,7 @@ nsChromeRegistry::GetDynamicDataSource(nsIURI *aChromeURL,
|
|||
nsCAutoString package, provider, remaining;
|
||||
|
||||
rv = SplitURL(aChromeURL, package, provider, remaining);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (!aCreateDS) {
|
||||
// We are not supposed to create the data source, which means
|
||||
|
@ -1104,7 +1009,7 @@ nsChromeRegistry::GetDynamicDataSource(nsIURI *aChromeURL,
|
|||
nsDependentCString dataSourceStr(kChromeFileName);
|
||||
nsCOMPtr<nsIRDFDataSource> mainDataSource;
|
||||
rv = LoadDataSource(dataSourceStr, getter_AddRefs(mainDataSource), aUseProfile, nsnull);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Now that we have the appropriate chrome.rdf file, we
|
||||
// must check the package resource for stylesheets or overlays.
|
||||
|
@ -1178,11 +1083,64 @@ nsChromeRegistry::GetStyleSheets(nsIURI *aChromeURL,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsChromeRegistry::GetOverlays(nsIURI *aChromeURL, nsISimpleEnumerator **aResult)
|
||||
NS_IMETHODIMP nsChromeRegistry::GetOverlaysForURI(nsIURI *aChromeURL, nsISimpleEnumerator **aResult)
|
||||
{
|
||||
return GetDynamicInfo(aChromeURL, PR_TRUE, aResult);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsChromeRegistry::GetURIList(nsIRDFDataSource *aSource,
|
||||
nsIRDFResource *aResource,
|
||||
nsCOMArray<nsIURI>& aArray)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsISimpleEnumerator> arcs;
|
||||
nsCOMPtr<nsIRDFContainer> container =
|
||||
do_CreateInstance("@mozilla.org/rdf/container;1", &rv);
|
||||
if (NS_FAILED(rv)) goto end_GetURIList;
|
||||
|
||||
rv = container->Init(aSource, aResource);
|
||||
if (NS_FAILED(rv)) {
|
||||
rv = NS_OK;
|
||||
goto end_GetURIList;
|
||||
}
|
||||
|
||||
rv = container->GetElements(getter_AddRefs(arcs));
|
||||
if (NS_FAILED(rv)) goto end_GetURIList;
|
||||
|
||||
{
|
||||
nsCOMPtr<nsISupports> supports;
|
||||
nsCOMPtr<nsIRDFLiteral> value;
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
PRBool hasMore;
|
||||
|
||||
while (NS_SUCCEEDED(rv = arcs->HasMoreElements(&hasMore)) && hasMore) {
|
||||
rv = arcs->GetNext(getter_AddRefs(supports));
|
||||
if (NS_FAILED(rv)) break;
|
||||
|
||||
value = do_QueryInterface(supports, &rv);
|
||||
if (NS_FAILED(rv)) continue;
|
||||
|
||||
const PRUnichar* valueStr;
|
||||
rv = value->GetValueConst(&valueStr);
|
||||
if (NS_FAILED(rv)) continue;
|
||||
|
||||
rv = NS_NewURI(getter_AddRefs(uri), NS_ConvertUTF16toUTF8(valueStr));
|
||||
if (NS_FAILED(rv)) continue;
|
||||
|
||||
if (IsOverlayAllowed(uri)) {
|
||||
if (!aArray.AppendObject(uri)) {
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
end_GetURIList:
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsChromeRegistry::GetDynamicInfo(nsIURI *aChromeURL, PRBool aIsOverlay,
|
||||
nsISimpleEnumerator **aResult)
|
||||
|
@ -1195,17 +1153,20 @@ nsChromeRegistry::GetDynamicInfo(nsIURI *aChromeURL, PRBool aIsOverlay,
|
|||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIRDFDataSource> installSource;
|
||||
rv = GetDynamicDataSource(aChromeURL, aIsOverlay, PR_FALSE, PR_FALSE, getter_AddRefs(installSource));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = GetDynamicDataSource(aChromeURL, aIsOverlay, PR_FALSE, PR_FALSE,
|
||||
getter_AddRefs(installSource));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIRDFDataSource> profileSource;
|
||||
if (mProfileInitialized) {
|
||||
rv = GetDynamicDataSource(aChromeURL, aIsOverlay, PR_TRUE, PR_FALSE, getter_AddRefs(profileSource));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = GetDynamicDataSource(aChromeURL, aIsOverlay, PR_TRUE, PR_FALSE,
|
||||
getter_AddRefs(profileSource));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
nsCAutoString lookup;
|
||||
rv = aChromeURL->GetSpec(lookup);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Get the chromeResource from this lookup string
|
||||
nsCOMPtr<nsIRDFResource> chromeResource;
|
||||
|
@ -1215,38 +1176,16 @@ nsChromeRegistry::GetDynamicInfo(nsIURI *aChromeURL, PRBool aIsOverlay,
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> installArcs;
|
||||
nsCOMPtr<nsISimpleEnumerator> profileArcs;
|
||||
nsCOMArray<nsIURI> overlayURIs;
|
||||
|
||||
if (installSource)
|
||||
{
|
||||
nsCOMPtr<nsIRDFContainer> container;
|
||||
rv = nsComponentManager::CreateInstance("@mozilla.org/rdf/container;1",
|
||||
nsnull,
|
||||
NS_GET_IID(nsIRDFContainer),
|
||||
getter_AddRefs(container));
|
||||
if (NS_SUCCEEDED(rv) && NS_SUCCEEDED(container->Init(installSource, chromeResource)))
|
||||
rv = container->GetElements(getter_AddRefs(installArcs));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (installSource) {
|
||||
GetURIList(installSource, chromeResource, overlayURIs);
|
||||
}
|
||||
if (profileSource) {
|
||||
GetURIList(profileSource, chromeResource, overlayURIs);
|
||||
}
|
||||
|
||||
if (profileSource)
|
||||
{
|
||||
nsCOMPtr<nsIRDFContainer> container;
|
||||
rv = nsComponentManager::CreateInstance("@mozilla.org/rdf/container;1",
|
||||
nsnull,
|
||||
NS_GET_IID(nsIRDFContainer),
|
||||
getter_AddRefs(container));
|
||||
if (NS_SUCCEEDED(rv) && NS_SUCCEEDED(container->Init(profileSource, chromeResource)))
|
||||
rv = container->GetElements(getter_AddRefs(profileArcs));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
|
||||
*aResult = new nsOverlayEnumerator(installArcs, profileArcs);
|
||||
NS_ADDREF(*aResult);
|
||||
|
||||
return NS_OK;
|
||||
return NS_NewArrayEnumerator(aResult, overlayURIs);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -2739,38 +2678,28 @@ NS_IMETHODIMP nsChromeRegistry::SetAllowOverlaysForPackage(const PRUnichar *aPac
|
|||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsChromeRegistry::OverlaysAllowedForPackage(const PRUnichar *aPackageName, PRBool *aRetval)
|
||||
PRBool nsChromeRegistry::IsOverlayAllowed(nsIURI *aChromeURL)
|
||||
{
|
||||
nsCAutoString package, provider, file;
|
||||
nsresult rv = SplitURL(aChromeURL, package, provider, file);
|
||||
if (NS_FAILED(rv)) return PR_FALSE;
|
||||
|
||||
// Get the chrome resource for the package.
|
||||
nsCAutoString package( "urn:mozilla:package:" );
|
||||
package.AppendWithConversion(aPackageName);
|
||||
nsCAutoString rdfpackage( "urn:mozilla:package:" );
|
||||
rdfpackage.Append(package);
|
||||
|
||||
// Obtain the package resource.
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIRDFResource> packageResource;
|
||||
rv = GetResource(package, getter_AddRefs(packageResource));
|
||||
if (NS_FAILED(rv)) {
|
||||
rv = GetResource(rdfpackage, getter_AddRefs(packageResource));
|
||||
if (NS_FAILED(rv) || !packageResource) {
|
||||
NS_ERROR("Unable to obtain the package resource.");
|
||||
return rv;
|
||||
return PR_FALSE;
|
||||
}
|
||||
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);
|
||||
return disabled.IsEmpty();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsChromeRegistry::InstallSkin(const char* aBaseURL, PRBool aUseProfile, PRBool aAllowScripts)
|
||||
|
|
|
@ -48,6 +48,8 @@ class nsIRDFContainerUtils;
|
|||
class nsIDOMWindowInternal;
|
||||
class nsIDocument;
|
||||
|
||||
#include "nsIChromeRegistry.h"
|
||||
#include "nsIXULOverlayProvider.h"
|
||||
#include "nsIRDFCompositeDataSource.h"
|
||||
#include "nsICSSStyleSheet.h"
|
||||
#include "nsIObserver.h"
|
||||
|
@ -55,13 +57,15 @@ class nsIDocument;
|
|||
#include "nsString.h"
|
||||
#include "nsIZipReader.h"
|
||||
#include "nsICSSLoader.h"
|
||||
#include "nsCOMArray.h"
|
||||
|
||||
// for component registration
|
||||
// {D8C7D8A2-E84C-11d2-BF87-00105A1B0627}
|
||||
// {47049e42-1d87-482a-984d-56ae185e367a}
|
||||
#define NS_CHROMEREGISTRY_CID \
|
||||
{ 0xd8c7d8a2, 0xe84c, 0x11d2, { 0xbf, 0x87, 0x0, 0x10, 0x5a, 0x1b, 0x6, 0x27 } }
|
||||
{ 0x47049e42, 0x1d87, 0x482a, { 0x98, 0x4d, 0x56, 0xae, 0x18, 0x5e, 0x36, 0x7a } }
|
||||
|
||||
class nsChromeRegistry : public nsIXULChromeRegistry,
|
||||
public nsIXULOverlayProvider,
|
||||
public nsIObserver,
|
||||
public nsSupportsWeakReference
|
||||
{
|
||||
|
@ -71,6 +75,7 @@ public:
|
|||
// nsIChromeRegistry methods:
|
||||
NS_DECL_NSICHROMEREGISTRY
|
||||
NS_DECL_NSIXULCHROMEREGISTRY
|
||||
NS_DECL_NSIXULOVERLAYPROVIDER
|
||||
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
|
@ -91,8 +96,11 @@ public:
|
|||
|
||||
protected:
|
||||
nsresult GetDynamicDataSource(nsIURI *aChromeURL, PRBool aIsOverlay, PRBool aUseProfile, PRBool aCreateDS, nsIRDFDataSource **aResult);
|
||||
nsresult GetURIList(nsIRDFDataSource *aDS, nsIRDFResource *aResource, nsCOMArray<nsIURI>& aArray);
|
||||
nsresult GetDynamicInfo(nsIURI *aChromeURL, PRBool aIsOverlay, nsISimpleEnumerator **aResult);
|
||||
|
||||
PRBool IsOverlayAllowed(nsIURI *aChromeURI);
|
||||
|
||||
nsresult GetResource(const nsACString& aChromeType, nsIRDFResource** aResult);
|
||||
|
||||
nsresult UpdateDynamicDataSource(nsIRDFDataSource *aDataSource,
|
||||
|
|
|
@ -136,8 +136,6 @@ interface nsIXULChromeRegistry : nsIChromeRegistry {
|
|||
ACString getSelectedLocale(in ACString packageName);
|
||||
ACString getSelectedSkin(in ACString packageName);
|
||||
|
||||
nsISimpleEnumerator getOverlays(in nsIURI aChromeURL);
|
||||
|
||||
/* Should be called when skins change. Reloads only stylesheets. */
|
||||
void refreshSkins();
|
||||
|
||||
|
@ -147,8 +145,6 @@ interface nsIXULChromeRegistry : nsIChromeRegistry {
|
|||
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,
|
||||
|
|
|
@ -35,6 +35,10 @@ XPIDLSRCS = \
|
|||
$(NULL)
|
||||
|
||||
ifdef MOZ_XUL
|
||||
XPIDLSRCS += \
|
||||
nsIXULOverlayProvider.idl \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
nsIXULContentSink.h \
|
||||
nsIXULDocument.h \
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Gecko XUL engine code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Benjamin Smedberg <bsmedberg@covad.net>
|
||||
* Portions created by the Initial Developer are Copyright (C) 2003
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsISimpleEnumerator;
|
||||
interface nsIURI;
|
||||
|
||||
/**
|
||||
* The chrome registry implements this interface to give overlays
|
||||
* to the gecko XUL engine.
|
||||
*
|
||||
* @status UNDER_REVIEW
|
||||
*/
|
||||
|
||||
[scriptable, uuid(3b1b0a68-261c-44e1-abfe-fc7637b6977a)]
|
||||
interface nsIXULOverlayProvider : nsISupports
|
||||
{
|
||||
/**
|
||||
* Method will be called by the gecko XUL engine when loading a chrome
|
||||
* XUL page.
|
||||
*
|
||||
* @param aURI The URI being loaded
|
||||
* @return An enumerator of nsIURI for the overlays of this URI
|
||||
*/
|
||||
nsISimpleEnumerator /*nsIURI*/ getOverlaysForURI(in nsIURI aURI);
|
||||
};
|
|
@ -68,13 +68,13 @@
|
|||
#include "nsDOMError.h"
|
||||
#include "nsIBoxObject.h"
|
||||
#include "nsIChromeRegistry.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsIContentSink.h" // for NS_CONTENT_ID_COUNTER_BASE
|
||||
#include "nsIScrollableView.h"
|
||||
#include "nsIContentViewer.h"
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsIDOMXULElement.h"
|
||||
#include "nsIElementFactory.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsIPrivateDOMEvent.h"
|
||||
#include "nsIRDFNode.h"
|
||||
#include "nsIRDFRemoteDataSource.h"
|
||||
|
@ -87,6 +87,7 @@
|
|||
#include "nsIXULContent.h"
|
||||
#include "nsIXULContentSink.h"
|
||||
#include "nsXULContentUtils.h"
|
||||
#include "nsIXULOverlayProvider.h"
|
||||
#include "nsIXULPrototypeCache.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsParserCIID.h"
|
||||
|
@ -697,6 +698,8 @@ nsXULDocument::EndLoad()
|
|||
rv = mCurrentPrototype->GetURI(getter_AddRefs(uri));
|
||||
if (NS_FAILED(rv)) return;
|
||||
|
||||
PRBool isChrome = IsChromeURI(uri);
|
||||
|
||||
// Remember if the XUL cache is on
|
||||
PRBool useXULCache;
|
||||
gXULCache->GetEnabled(&useXULCache);
|
||||
|
@ -706,49 +709,51 @@ nsXULDocument::EndLoad()
|
|||
// loading it, and write the prototype.
|
||||
if (useXULCache && mIsWritingFastLoad &&
|
||||
mMasterPrototype != mCurrentPrototype &&
|
||||
IsChromeURI(uri))
|
||||
isChrome)
|
||||
gXULCache->WritePrototype(mCurrentPrototype);
|
||||
|
||||
nsCOMPtr<nsIXULChromeRegistry> reg =
|
||||
do_GetService(NS_CHROMEREGISTRY_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) return;
|
||||
if (isChrome) {
|
||||
nsCOMPtr<nsIXULChromeRegistry> reg =
|
||||
do_GetService(NS_CHROMEREGISTRY_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) return;
|
||||
|
||||
nsCOMPtr<nsISupportsArray> sheets;
|
||||
reg->GetStyleSheets(uri, getter_AddRefs(sheets));
|
||||
nsCOMPtr<nsISupportsArray> sheets;
|
||||
reg->GetStyleSheets(uri, getter_AddRefs(sheets));
|
||||
|
||||
// Walk the sheets and add them to the prototype. Also put them
|
||||
// into the document.
|
||||
if (sheets) {
|
||||
nsCOMPtr<nsICSSStyleSheet> sheet;
|
||||
PRUint32 count;
|
||||
sheets->Count(&count);
|
||||
for (PRUint32 i = 0; i < count; ++i) {
|
||||
sheet = do_QueryElementAt(sheets, i);
|
||||
if (sheet) {
|
||||
nsCOMPtr<nsIURI> sheetURL;
|
||||
sheet->GetURL(*getter_AddRefs(sheetURL));
|
||||
// Walk the sheets and add them to the prototype. Also put them
|
||||
// into the document.
|
||||
if (sheets) {
|
||||
nsCOMPtr<nsICSSStyleSheet> sheet;
|
||||
PRUint32 count;
|
||||
sheets->Count(&count);
|
||||
for (PRUint32 i = 0; i < count; ++i) {
|
||||
sheet = do_QueryElementAt(sheets, i);
|
||||
if (sheet) {
|
||||
nsCOMPtr<nsIURI> sheetURL;
|
||||
sheet->GetURL(*getter_AddRefs(sheetURL));
|
||||
|
||||
if (useXULCache && IsChromeURI(sheetURL)) {
|
||||
mCurrentPrototype->AddStyleSheetReference(sheetURL);
|
||||
if (useXULCache && IsChromeURI(sheetURL)) {
|
||||
mCurrentPrototype->AddStyleSheetReference(sheetURL);
|
||||
}
|
||||
AddStyleSheet(sheet, 0);
|
||||
}
|
||||
AddStyleSheet(sheet, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (useXULCache && IsChromeURI(uri)) {
|
||||
// If it's a 'chrome:' prototype document, then notify any
|
||||
// documents that raced to load the prototype, and awaited
|
||||
// its load completion via proto->AwaitLoadDone().
|
||||
rv = mCurrentPrototype->NotifyLoadDone();
|
||||
if (useXULCache) {
|
||||
// If it's a 'chrome:' prototype document, then notify any
|
||||
// documents that raced to load the prototype, and awaited
|
||||
// its load completion via proto->AwaitLoadDone().
|
||||
rv = mCurrentPrototype->NotifyLoadDone();
|
||||
if (NS_FAILED(rv)) return;
|
||||
}
|
||||
|
||||
// Now walk the prototype to build content.
|
||||
rv = PrepareToWalk();
|
||||
if (NS_FAILED(rv)) return;
|
||||
|
||||
ResumeWalk();
|
||||
}
|
||||
|
||||
// Now walk the prototype to build content.
|
||||
rv = PrepareToWalk();
|
||||
if (NS_FAILED(rv)) return;
|
||||
|
||||
ResumeWalk();
|
||||
}
|
||||
|
||||
// Called back from nsXULPrototypeDocument::NotifyLoadDone for each XUL
|
||||
|
@ -2780,47 +2785,40 @@ nsresult
|
|||
nsXULDocument::AddChromeOverlays()
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIXULChromeRegistry> reg(do_GetService(NS_CHROMEREGISTRY_CONTRACTID, &rv));
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsIURI> docUri;
|
||||
rv = mCurrentPrototype->GetURI(getter_AddRefs(docUri));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> oe;
|
||||
/* overlays only apply to chrome, skip all content URIs */
|
||||
if (!IsChromeURI(docUri)) return NS_OK;
|
||||
|
||||
{
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
rv = mCurrentPrototype->GetURI(getter_AddRefs(uri));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsCOMPtr<nsIXULOverlayProvider> chromeReg(do_GetService(NS_CHROMEREGISTRY_CONTRACTID));
|
||||
// In embedding situations, the chrome registry may not provide overlays,
|
||||
// or even exist at all; that's OK.
|
||||
NS_ENSURE_TRUE(chromeReg, NS_OK);
|
||||
|
||||
reg->GetOverlays(uri, getter_AddRefs(oe));
|
||||
}
|
||||
nsCOMPtr<nsISimpleEnumerator> overlays;
|
||||
rv = chromeReg->GetOverlaysForURI(docUri, getter_AddRefs(overlays));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (!oe)
|
||||
return NS_OK;
|
||||
PRBool moreOverlays;
|
||||
nsCOMPtr<nsISupports> next;
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
|
||||
PRBool moreElements;
|
||||
oe->HasMoreElements(&moreElements);
|
||||
while (NS_SUCCEEDED(rv = overlays->HasMoreElements(&moreOverlays)) &&
|
||||
moreOverlays) {
|
||||
rv = overlays->GetNext(getter_AddRefs(next));
|
||||
if (NS_FAILED(rv) || !next) continue;
|
||||
|
||||
while (moreElements) {
|
||||
nsCOMPtr<nsISupports> next;
|
||||
oe->GetNext(getter_AddRefs(next));
|
||||
if (!next)
|
||||
return NS_OK;
|
||||
uri = do_QueryInterface(next);
|
||||
if (!uri) {
|
||||
NS_ERROR("Chrome registry handed me a non-nsIURI object!");
|
||||
continue;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> uri = do_QueryInterface(next);
|
||||
if (!uri)
|
||||
return NS_OK;
|
||||
|
||||
// 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);
|
||||
}
|
||||
mUnloadedOverlays->AppendElement(uri);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ REQUIRES = xpcom \
|
|||
necko \
|
||||
layout \
|
||||
content \
|
||||
xuldoc \
|
||||
jar \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include "nsArrayEnumerator.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIChromeRegistry.h"
|
||||
#include "nsChromeRegistry.h"
|
||||
|
@ -146,107 +147,6 @@ DEFINE_RDF_VOCAB(CHROME_URI, CHROME, localeVersion);
|
|||
DEFINE_RDF_VOCAB(CHROME_URI, CHROME, packageVersion);
|
||||
DEFINE_RDF_VOCAB(CHROME_URI, CHROME, disabled);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class nsOverlayEnumerator : public nsISimpleEnumerator
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSISIMPLEENUMERATOR
|
||||
|
||||
nsOverlayEnumerator(nsISimpleEnumerator *aInstallArcs,
|
||||
nsISimpleEnumerator *aProfileArcs);
|
||||
virtual ~nsOverlayEnumerator();
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsISimpleEnumerator> mInstallArcs;
|
||||
nsCOMPtr<nsISimpleEnumerator> mProfileArcs;
|
||||
nsCOMPtr<nsISimpleEnumerator> mCurrentArcs;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsOverlayEnumerator, nsISimpleEnumerator)
|
||||
|
||||
nsOverlayEnumerator::nsOverlayEnumerator(nsISimpleEnumerator *aInstallArcs,
|
||||
nsISimpleEnumerator *aProfileArcs)
|
||||
: mInstallArcs(aInstallArcs),
|
||||
mProfileArcs(aProfileArcs)
|
||||
{
|
||||
}
|
||||
|
||||
nsOverlayEnumerator::~nsOverlayEnumerator()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsOverlayEnumerator::HasMoreElements(PRBool *aIsTrue)
|
||||
{
|
||||
*aIsTrue = PR_FALSE;
|
||||
if (!mProfileArcs) {
|
||||
if (!mInstallArcs)
|
||||
return NS_OK; // No arcs period. We default to false,
|
||||
return mInstallArcs->HasMoreElements(aIsTrue); // no profile arcs. use install arcs,
|
||||
}
|
||||
|
||||
nsresult rv = mProfileArcs->HasMoreElements(aIsTrue);
|
||||
if (*aIsTrue || !mInstallArcs)
|
||||
return rv;
|
||||
|
||||
return mInstallArcs->HasMoreElements(aIsTrue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsOverlayEnumerator::GetNext(nsISupports **aResult)
|
||||
{
|
||||
nsresult rv;
|
||||
*aResult = nsnull;
|
||||
|
||||
if (!mCurrentArcs) {
|
||||
// Start with the profile arcs.
|
||||
mCurrentArcs = mProfileArcs;
|
||||
if (!mCurrentArcs) {
|
||||
// No profile arcs, try the install arcs.
|
||||
mCurrentArcs = mInstallArcs;
|
||||
if (!mCurrentArcs)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
else if (mCurrentArcs == mProfileArcs) {
|
||||
// Check if we have more profile arcs.
|
||||
PRBool hasMore;
|
||||
rv = mCurrentArcs->HasMoreElements(&hasMore);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
if (!hasMore) {
|
||||
// No more profile arcs, try the install arcs.
|
||||
if (!mInstallArcs)
|
||||
return NS_ERROR_FAILURE;
|
||||
mCurrentArcs = mInstallArcs;
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISupports> supports;
|
||||
rv = mCurrentArcs->GetNext(getter_AddRefs(supports));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIRDFLiteral> value = do_QueryInterface(supports, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return NS_OK;
|
||||
|
||||
const PRUnichar* valueStr;
|
||||
rv = value->GetValueConst(&valueStr);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIURI> url;
|
||||
rv = NS_NewURI(getter_AddRefs(url), NS_ConvertUCS2toUTF8(valueStr));
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return NS_OK;
|
||||
|
||||
return CallQueryInterface(url, aResult);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsChromeRegistry::nsChromeRegistry() : mRDFService(nsnull),
|
||||
|
@ -310,7 +210,12 @@ nsChromeRegistry::~nsChromeRegistry()
|
|||
|
||||
}
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS4(nsChromeRegistry, nsIChromeRegistry, nsIXULChromeRegistry, nsIObserver, nsISupportsWeakReference)
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS5(nsChromeRegistry,
|
||||
nsIChromeRegistry,
|
||||
nsIXULChromeRegistry,
|
||||
nsIXULOverlayProvider,
|
||||
nsIObserver,
|
||||
nsISupportsWeakReference)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIChromeRegistry methods:
|
||||
|
@ -1094,7 +999,7 @@ nsChromeRegistry::GetDynamicDataSource(nsIURI *aChromeURL,
|
|||
nsCAutoString package, provider, remaining;
|
||||
|
||||
rv = SplitURL(aChromeURL, package, provider, remaining);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (!aCreateDS) {
|
||||
// We are not supposed to create the data source, which means
|
||||
|
@ -1104,7 +1009,7 @@ nsChromeRegistry::GetDynamicDataSource(nsIURI *aChromeURL,
|
|||
nsDependentCString dataSourceStr(kChromeFileName);
|
||||
nsCOMPtr<nsIRDFDataSource> mainDataSource;
|
||||
rv = LoadDataSource(dataSourceStr, getter_AddRefs(mainDataSource), aUseProfile, nsnull);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Now that we have the appropriate chrome.rdf file, we
|
||||
// must check the package resource for stylesheets or overlays.
|
||||
|
@ -1178,11 +1083,64 @@ nsChromeRegistry::GetStyleSheets(nsIURI *aChromeURL,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsChromeRegistry::GetOverlays(nsIURI *aChromeURL, nsISimpleEnumerator **aResult)
|
||||
NS_IMETHODIMP nsChromeRegistry::GetOverlaysForURI(nsIURI *aChromeURL, nsISimpleEnumerator **aResult)
|
||||
{
|
||||
return GetDynamicInfo(aChromeURL, PR_TRUE, aResult);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsChromeRegistry::GetURIList(nsIRDFDataSource *aSource,
|
||||
nsIRDFResource *aResource,
|
||||
nsCOMArray<nsIURI>& aArray)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsISimpleEnumerator> arcs;
|
||||
nsCOMPtr<nsIRDFContainer> container =
|
||||
do_CreateInstance("@mozilla.org/rdf/container;1", &rv);
|
||||
if (NS_FAILED(rv)) goto end_GetURIList;
|
||||
|
||||
rv = container->Init(aSource, aResource);
|
||||
if (NS_FAILED(rv)) {
|
||||
rv = NS_OK;
|
||||
goto end_GetURIList;
|
||||
}
|
||||
|
||||
rv = container->GetElements(getter_AddRefs(arcs));
|
||||
if (NS_FAILED(rv)) goto end_GetURIList;
|
||||
|
||||
{
|
||||
nsCOMPtr<nsISupports> supports;
|
||||
nsCOMPtr<nsIRDFLiteral> value;
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
PRBool hasMore;
|
||||
|
||||
while (NS_SUCCEEDED(rv = arcs->HasMoreElements(&hasMore)) && hasMore) {
|
||||
rv = arcs->GetNext(getter_AddRefs(supports));
|
||||
if (NS_FAILED(rv)) break;
|
||||
|
||||
value = do_QueryInterface(supports, &rv);
|
||||
if (NS_FAILED(rv)) continue;
|
||||
|
||||
const PRUnichar* valueStr;
|
||||
rv = value->GetValueConst(&valueStr);
|
||||
if (NS_FAILED(rv)) continue;
|
||||
|
||||
rv = NS_NewURI(getter_AddRefs(uri), NS_ConvertUTF16toUTF8(valueStr));
|
||||
if (NS_FAILED(rv)) continue;
|
||||
|
||||
if (IsOverlayAllowed(uri)) {
|
||||
if (!aArray.AppendObject(uri)) {
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
end_GetURIList:
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsChromeRegistry::GetDynamicInfo(nsIURI *aChromeURL, PRBool aIsOverlay,
|
||||
nsISimpleEnumerator **aResult)
|
||||
|
@ -1195,17 +1153,20 @@ nsChromeRegistry::GetDynamicInfo(nsIURI *aChromeURL, PRBool aIsOverlay,
|
|||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIRDFDataSource> installSource;
|
||||
rv = GetDynamicDataSource(aChromeURL, aIsOverlay, PR_FALSE, PR_FALSE, getter_AddRefs(installSource));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = GetDynamicDataSource(aChromeURL, aIsOverlay, PR_FALSE, PR_FALSE,
|
||||
getter_AddRefs(installSource));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIRDFDataSource> profileSource;
|
||||
if (mProfileInitialized) {
|
||||
rv = GetDynamicDataSource(aChromeURL, aIsOverlay, PR_TRUE, PR_FALSE, getter_AddRefs(profileSource));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = GetDynamicDataSource(aChromeURL, aIsOverlay, PR_TRUE, PR_FALSE,
|
||||
getter_AddRefs(profileSource));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
nsCAutoString lookup;
|
||||
rv = aChromeURL->GetSpec(lookup);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Get the chromeResource from this lookup string
|
||||
nsCOMPtr<nsIRDFResource> chromeResource;
|
||||
|
@ -1215,38 +1176,16 @@ nsChromeRegistry::GetDynamicInfo(nsIURI *aChromeURL, PRBool aIsOverlay,
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> installArcs;
|
||||
nsCOMPtr<nsISimpleEnumerator> profileArcs;
|
||||
nsCOMArray<nsIURI> overlayURIs;
|
||||
|
||||
if (installSource)
|
||||
{
|
||||
nsCOMPtr<nsIRDFContainer> container;
|
||||
rv = nsComponentManager::CreateInstance("@mozilla.org/rdf/container;1",
|
||||
nsnull,
|
||||
NS_GET_IID(nsIRDFContainer),
|
||||
getter_AddRefs(container));
|
||||
if (NS_SUCCEEDED(rv) && NS_SUCCEEDED(container->Init(installSource, chromeResource)))
|
||||
rv = container->GetElements(getter_AddRefs(installArcs));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (installSource) {
|
||||
GetURIList(installSource, chromeResource, overlayURIs);
|
||||
}
|
||||
if (profileSource) {
|
||||
GetURIList(profileSource, chromeResource, overlayURIs);
|
||||
}
|
||||
|
||||
if (profileSource)
|
||||
{
|
||||
nsCOMPtr<nsIRDFContainer> container;
|
||||
rv = nsComponentManager::CreateInstance("@mozilla.org/rdf/container;1",
|
||||
nsnull,
|
||||
NS_GET_IID(nsIRDFContainer),
|
||||
getter_AddRefs(container));
|
||||
if (NS_SUCCEEDED(rv) && NS_SUCCEEDED(container->Init(profileSource, chromeResource)))
|
||||
rv = container->GetElements(getter_AddRefs(profileArcs));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
|
||||
*aResult = new nsOverlayEnumerator(installArcs, profileArcs);
|
||||
NS_ADDREF(*aResult);
|
||||
|
||||
return NS_OK;
|
||||
return NS_NewArrayEnumerator(aResult, overlayURIs);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -2739,38 +2678,28 @@ NS_IMETHODIMP nsChromeRegistry::SetAllowOverlaysForPackage(const PRUnichar *aPac
|
|||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsChromeRegistry::OverlaysAllowedForPackage(const PRUnichar *aPackageName, PRBool *aRetval)
|
||||
PRBool nsChromeRegistry::IsOverlayAllowed(nsIURI *aChromeURL)
|
||||
{
|
||||
nsCAutoString package, provider, file;
|
||||
nsresult rv = SplitURL(aChromeURL, package, provider, file);
|
||||
if (NS_FAILED(rv)) return PR_FALSE;
|
||||
|
||||
// Get the chrome resource for the package.
|
||||
nsCAutoString package( "urn:mozilla:package:" );
|
||||
package.AppendWithConversion(aPackageName);
|
||||
nsCAutoString rdfpackage( "urn:mozilla:package:" );
|
||||
rdfpackage.Append(package);
|
||||
|
||||
// Obtain the package resource.
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIRDFResource> packageResource;
|
||||
rv = GetResource(package, getter_AddRefs(packageResource));
|
||||
if (NS_FAILED(rv)) {
|
||||
rv = GetResource(rdfpackage, getter_AddRefs(packageResource));
|
||||
if (NS_FAILED(rv) || !packageResource) {
|
||||
NS_ERROR("Unable to obtain the package resource.");
|
||||
return rv;
|
||||
return PR_FALSE;
|
||||
}
|
||||
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);
|
||||
return disabled.IsEmpty();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsChromeRegistry::InstallSkin(const char* aBaseURL, PRBool aUseProfile, PRBool aAllowScripts)
|
||||
|
|
|
@ -48,6 +48,8 @@ class nsIRDFContainerUtils;
|
|||
class nsIDOMWindowInternal;
|
||||
class nsIDocument;
|
||||
|
||||
#include "nsIChromeRegistry.h"
|
||||
#include "nsIXULOverlayProvider.h"
|
||||
#include "nsIRDFCompositeDataSource.h"
|
||||
#include "nsICSSStyleSheet.h"
|
||||
#include "nsIObserver.h"
|
||||
|
@ -55,6 +57,7 @@ class nsIDocument;
|
|||
#include "nsString.h"
|
||||
#include "nsIZipReader.h"
|
||||
#include "nsICSSLoader.h"
|
||||
#include "nsCOMArray.h"
|
||||
|
||||
// for component registration
|
||||
// {D8C7D8A2-E84C-11d2-BF87-00105A1B0627}
|
||||
|
@ -62,6 +65,7 @@ class nsIDocument;
|
|||
{ 0xd8c7d8a2, 0xe84c, 0x11d2, { 0xbf, 0x87, 0x0, 0x10, 0x5a, 0x1b, 0x6, 0x27 } }
|
||||
|
||||
class nsChromeRegistry : public nsIXULChromeRegistry,
|
||||
public nsIXULOverlayProvider,
|
||||
public nsIObserver,
|
||||
public nsSupportsWeakReference
|
||||
{
|
||||
|
@ -71,6 +75,7 @@ public:
|
|||
// nsIChromeRegistry methods:
|
||||
NS_DECL_NSICHROMEREGISTRY
|
||||
NS_DECL_NSIXULCHROMEREGISTRY
|
||||
NS_DECL_NSIXULOVERLAYPROVIDER
|
||||
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
|
@ -91,8 +96,11 @@ public:
|
|||
|
||||
protected:
|
||||
nsresult GetDynamicDataSource(nsIURI *aChromeURL, PRBool aIsOverlay, PRBool aUseProfile, PRBool aCreateDS, nsIRDFDataSource **aResult);
|
||||
nsresult GetURIList(nsIRDFDataSource *aDS, nsIRDFResource *aResource, nsCOMArray<nsIURI>& aArray);
|
||||
nsresult GetDynamicInfo(nsIURI *aChromeURL, PRBool aIsOverlay, nsISimpleEnumerator **aResult);
|
||||
|
||||
PRBool IsOverlayAllowed(nsIURI *aChromeURI);
|
||||
|
||||
nsresult GetResource(const nsACString& aChromeType, nsIRDFResource** aResult);
|
||||
|
||||
nsresult UpdateDynamicDataSource(nsIRDFDataSource *aDataSource,
|
||||
|
|
Загрузка…
Ссылка в новой задаче