Bug 278534, try #2 - Make tooklit chrome registry use plaintext manifests instead of an RDF cache (get rid of contents.rdf!) r=darin/dveditz/ben

This commit is contained in:
bsmedberg%covad.net 2005-02-22 21:49:45 +00:00
Родитель 610d170988
Коммит aab6284169
31 изменённых файлов: 2250 добавлений и 3268 удалений

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

@ -919,6 +919,7 @@ xulrunner/app/profile/extensions/Makefile
MAKEFILES_xulapp="
chrome/Makefile
chrome/public/Makefile
chrome/src/Makefile
chrome/tools/Makefile
chrome/tools/chromereg/Makefile

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

@ -61,6 +61,7 @@ bin/components/bookmarks.xpt
bin/components/browsercompsbase.xpt
bin/components/caps.xpt
bin/components/chardet.xpt
bin/components/chrome.xpt
bin/components/commandhandler.xpt
bin/components/commandlines.xpt
bin/components/composer.xpt
@ -134,7 +135,6 @@ bin/components/passwordmgr.xpt
bin/components/plugin.xpt
bin/components/prefetch.xpt
bin/components/pref.xpt
bin/components/profile.xpt
bin/components/progressDlg.xpt
bin/components/proxyObjInst.xpt
bin/components/rdf.xpt

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

@ -42,7 +42,7 @@ VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS = src tools
DIRS = public src tools
include $(topsrcdir)/config/rules.mk

48
chrome/public/Makefile.in Normal file
Просмотреть файл

@ -0,0 +1,48 @@
# ***** 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 mozilla.org code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1998
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either of 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 *****
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = chrome
XPIDLSRCS = nsIToolkitChromeRegistry.idl
include $(topsrcdir)/config/rules.mk

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

@ -0,0 +1,82 @@
/* -*- Mode: C++; tab-width; 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** 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 the XUL toolkit.
*
* The Initial Developer of the Original Code is
* Benjamin Smedberg <benjamin@smedbergs.us>
*
* Portions created by the Initial Developer are Copyright (C) 2005
* 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 "nsIChromeRegistry.idl"
interface nsIURI;
[scriptable, uuid(b1fe3107-fac6-432a-be34-fdfc26b0736c)]
interface nsIToolkitChromeRegistry : nsIXULChromeRegistry
{
/**
* The "canonical" manifest is a plaintext file which sits outside of a
* JAR file. To provide backwards-compatibility with contents.rdf, we provide
* this function which reads a contents.rdf manifest and writes it to a file.
*
* @param aOldManifestURI The URI of an old manifest to read, without
* the trailing "contents.rdf", e.g.
* "jar:resource:///chrome/foo.jar!/content/foo/"
* @param aFile The URI of a manifest file to write. It's a good
* idea to use a resource: URI if possible.
* @param aAppend Whether we should append to an existing manifest
* or truncate and start empty.
* @param aSkinOnly Only allow skin packages.
*/
void processContentsManifest(in nsIURI aOldManifestURI, in nsIURI aFile,
in boolean aAppend, in boolean aSkinOnly);
/**
* If the OS has a "high-visibility" or "disabled-friendly" theme set,
* we want to force mozilla into the classic theme, which (for the most part
* obeys the system color/font settings. We cannot do this at initialization,
* because it depends on the toolkit (GTK2) being initialized, which is
* not the case in some embedding situations. Embedders have to manually
* call this method during the startup process.
*/
void checkForOSAccessibility();
};
/**
* The chrome registry will ask the directory service for this file list and
* process each file as a manifest. Skin manifests may contain only skin
* and style overlays.
*/
%{ C++
#define NS_CHROME_MANIFESTS_FILE_LIST "ChromeML"
#define NS_SKIN_MANIFESTS_FILE_LIST "SkinML"
%}

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

@ -75,7 +75,6 @@ REQUIRES = xpcom \
CPPSRCS = \
nsChromeFactory.cpp \
nsChromeRegistry.cpp \
nsChromeUIDataSource.cpp \
nsChromeProtocolHandler.cpp \
$(NULL)

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

@ -43,6 +43,7 @@
*/
#include "nsChromeProtocolHandler.h"
#include "nsChromeRegistry.h"
#include "nsCOMPtr.h"
#include "nsContentCID.h"
#include "nsCRT.h"
@ -65,10 +66,8 @@
#include "nsIServiceManager.h"
#include "nsIStandardURL.h"
#include "nsIStreamListener.h"
#ifdef MOZ_XUL
#include "nsIXULPrototypeCache.h"
#include "nsIXULPrototypeDocument.h"
#endif
#include "nsNetUtil.h"
#include "nsXPIDLString.h"
#include "nsString.h"
@ -76,12 +75,7 @@
//----------------------------------------------------------------------
#ifdef MOZ_XUL
static NS_DEFINE_CID(kXULPrototypeCacheCID, NS_XULPROTOTYPECACHE_CID);
#endif
// This comes from nsChromeRegistry.cpp
extern nsIChromeRegistry* gChromeRegistry;
//----------------------------------------------------------------------
//
@ -464,50 +458,32 @@ nsChromeProtocolHandler::NewURI(const nsACString &aSpec,
nsIURI *aBaseURI,
nsIURI **result)
{
NS_PRECONDITION(result, "Null out param");
nsresult rv;
*result = nsnull;
// Chrome: URLs (currently) have no additional structure beyond that provided
// by standard URLs, so there is no "outer" given to CreateInstance
nsCOMPtr<nsIStandardURL> url(do_CreateInstance(NS_STANDARDURL_CONTRACTID, &rv));
nsCOMPtr<nsIStandardURL> surl(do_CreateInstance(NS_STANDARDURL_CONTRACTID, &rv));
NS_ENSURE_SUCCESS(rv, rv);
rv = surl->Init(nsIStandardURL::URLTYPE_STANDARD, -1, aSpec, aCharset, aBaseURI);
if (NS_FAILED(rv))
return rv;
rv = url->Init(nsIStandardURL::URLTYPE_STANDARD, -1, aSpec, aCharset, aBaseURI);
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIURI> uri(do_QueryInterface(url, &rv));
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIURL> url(do_QueryInterface(surl, &rv));
NS_ENSURE_SUCCESS(rv, rv);
// Canonify the "chrome:" URL; e.g., so that we collapse
// "chrome://navigator/content/" and "chrome://navigator/content"
// and "chrome://navigator/content/navigator.xul".
// Try the global cache first.
nsCOMPtr<nsIChromeRegistry> reg = gChromeRegistry;
// If that fails, the service has not been instantiated yet; let's
// do that now.
if (!reg) {
reg = do_GetService(NS_CHROMEREGISTRY_CONTRACTID, &rv);
if (NS_FAILED(rv))
return rv;
}
NS_ASSERTION(reg, "Must have a chrome registry by now");
rv = reg->Canonify(uri);
rv = nsChromeRegistry::Canonify(url);
if (NS_FAILED(rv))
return rv;
*result = uri;
NS_ADDREF(*result);
surl->SetMutable(PR_FALSE);
NS_ADDREF(*result = url);
return NS_OK;
}
@ -521,20 +497,17 @@ nsChromeProtocolHandler::NewChannel(nsIURI* aURI,
#ifdef DEBUG
// Check that the uri we got is already canonified
nsresult debug_rv;
nsCOMPtr<nsIChromeRegistry> debugReg(do_GetService(NS_CHROMEREGISTRY_CONTRACTID, &debug_rv));
nsCOMPtr<nsIURI> debugClone;
debug_rv = aURI->Clone(getter_AddRefs(debugClone));
if (NS_SUCCEEDED(debug_rv)) {
nsCOMPtr<nsIURI> debugClone;
debug_rv = aURI->Clone(getter_AddRefs(debugClone));
nsCOMPtr<nsIURL> debugURL (do_QueryInterface(debugClone));
debug_rv = nsChromeRegistry::Canonify(debugURL);
if (NS_SUCCEEDED(debug_rv)) {
debug_rv = debugReg->Canonify(debugClone);
PRBool same;
debug_rv = aURI->Equals(debugURL, &same);
if (NS_SUCCEEDED(debug_rv)) {
PRBool same;
debug_rv = aURI->Equals(debugClone, &same);
if (NS_SUCCEEDED(debug_rv)) {
NS_ASSERTION(same, "Non-canonified chrome uri passed to nsChromeProtocolHandler::NewChannel!");
}
NS_ASSERTION(same, "Non-canonified chrome uri passed to nsChromeProtocolHandler::NewChannel!");
}
}
}
#endif
@ -542,15 +515,16 @@ nsChromeProtocolHandler::NewChannel(nsIURI* aURI,
nsresult rv;
nsCOMPtr<nsIChannel> result;
#ifdef MOZ_XUL
// Check the prototype cache to see if we've already got the
// document in the cache.
nsCOMPtr<nsIXULPrototypeCache> cache =
do_GetService(kXULPrototypeCacheCID, &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIXULPrototypeCache> cache
(do_GetService(kXULPrototypeCacheCID));
nsCOMPtr<nsIXULPrototypeDocument> proto;
cache->GetPrototype(aURI, getter_AddRefs(proto));
if (cache)
cache->GetPrototype(aURI, getter_AddRefs(proto));
else
NS_WARNING("Unable to obtain the XUL prototype cache!");
// Same comment as nsXULDocument::StartDocumentLoad and
// nsXULDocument::ResumeWalk
@ -575,39 +549,31 @@ nsChromeProtocolHandler::NewChannel(nsIURI* aURI,
if (! result)
return NS_ERROR_OUT_OF_MEMORY;
}
else
#endif
{
else {
// Miss. Resolve the chrome URL using the registry and do a
// normal necko load.
//nsXPIDLCString oldSpec;
//aURI->GetSpec(getter_Copies(oldSpec));
//printf("*************************** %s\n", (const char*)oldSpec);
nsCOMPtr<nsIChromeRegistry> reg = gChromeRegistry;
if (!reg) {
reg = do_GetService(NS_CHROMEREGISTRY_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
}
nsCOMPtr<nsIChromeRegistry> reg (do_GetService(NS_CHROMEREGISTRY_CONTRACTID));
NS_ENSURE_TRUE(reg, NS_ERROR_FAILURE);
nsCAutoString spec;
rv = reg->ConvertChromeURL(aURI, spec);
nsCOMPtr<nsIURI> resolvedURI;
rv = reg->ConvertChromeURL(aURI, getter_AddRefs(resolvedURI));
if (NS_FAILED(rv)) {
#ifdef DEBUG
nsCAutoString spec;
aURI->GetSpec(spec);
printf("Couldn't convert chrome URL: %s\n", spec.get());
#endif
return rv;
}
nsCOMPtr<nsIIOService> ioServ(do_GetIOService(&rv));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIIOService> ioServ (do_GetIOService(&rv));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIURI> chromeURI;
rv = ioServ->NewURI(spec, nsnull, nsnull, getter_AddRefs(chromeURI));
if (NS_FAILED(rv)) return rv;
rv = ioServ->NewChannelFromURI(chromeURI, getter_AddRefs(result));
rv = ioServ->NewChannelFromURI(resolvedURI, getter_AddRefs(result));
if (NS_FAILED(rv)) return rv;
// XXX Will be removed someday when we handle remote chrome.
@ -700,10 +666,8 @@ nsChromeProtocolHandler::NewChannel(nsIURI* aURI,
if (file) {
rv = fastLoadServ->AddDependency(file);
#ifdef MOZ_XUL
if (NS_FAILED(rv))
cache->AbortFastLoads();
#endif
}
}
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -21,6 +21,7 @@
*
* Contributor(s):
* Original Author: David W. Hyatt (hyatt@netscape.com)
* Benjamin Smedberg <benjamin@smedbergs.us>
*
* 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
@ -36,37 +37,36 @@
*
* ***** END LICENSE BLOCK ***** */
class nsIAtom;
class nsICSSStyleSheet;
class nsIRDFService;
class nsIRDFDataSource;
class nsIRDFResource;
class nsIRDFNode;
class nsISimpleEnumerator;
class nsSupportsHashtable;
class nsIRDFContainer;
class nsIRDFContainerUtils;
class nsIDOMWindowInternal;
class nsIDocument;
class nsILocalFile;
class nsIProperties;
#include "nsIChromeRegistry.h"
#include "nsIToolkitChromeRegistry.h"
#include "nsIXULOverlayProvider.h"
#include "nsIRDFCompositeDataSource.h"
#include "nsIObserver.h"
#include "nsWeakReference.h"
#include "nsString.h"
#include "nsIZipReader.h"
#include "pldhash.h"
#include "nsCOMArray.h"
#include "nsInterfaceHashtable.h"
#include "nsString.h"
#include "nsTHashtable.h"
#include "nsURIHashKey.h"
#include "nsVoidArray.h"
struct PRFileDesc;
class nsIAtom;
class nsICSSStyleSheet;
class nsIDOMWindowInternal;
class nsILocalFile;
class nsIRDFDataSource;
class nsIRDFResource;
class nsIRDFService;
class nsIURL;
// for component registration
// {47049e42-1d87-482a-984d-56ae185e367a}
#define NS_CHROMEREGISTRY_CID \
{ 0x47049e42, 0x1d87, 0x482a, { 0x98, 0x4d, 0x56, 0xae, 0x18, 0x5e, 0x36, 0x7a } }
class nsChromeRegistry : public nsIXULChromeRegistry,
class nsChromeRegistry : public nsIToolkitChromeRegistry,
public nsIXULOverlayProvider,
public nsIObserver,
public nsSupportsWeakReference
@ -77,48 +77,22 @@ public:
// nsIChromeRegistry methods:
NS_DECL_NSICHROMEREGISTRY
NS_DECL_NSIXULCHROMEREGISTRY
NS_DECL_NSITOOLKITCHROMEREGISTRY
NS_DECL_NSIXULOVERLAYPROVIDER
NS_DECL_NSIOBSERVER
// nsChromeRegistry methods:
nsChromeRegistry();
virtual ~nsChromeRegistry();
nsChromeRegistry() { }
~nsChromeRegistry();
nsresult Init();
public:
static nsresult FollowArc(nsIRDFDataSource *aDataSource,
nsACString& aResult,
nsIRDFResource* aChromeResource,
nsIRDFResource* aProperty);
static nsresult UpdateArc(nsIRDFDataSource *aDataSource, nsIRDFResource* aSource, nsIRDFResource* aProperty,
nsIRDFNode *aTarget, PRBool aRemove);
static nsresult Canonify(nsIURL* aChromeURL);
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,
nsIRDFResource *aResource,
PRBool aIsOverlay, PRBool
aUseProfile, PRBool aRemove);
nsresult UpdateDynamicDataSources(nsIRDFDataSource *aDataSource,
PRBool aIsOverlay,
PRBool aUseProfile, PRBool
aRemove);
nsresult WriteInfoToDataSource(const char *aDocURI,
const PRUnichar *aOverlayURI,
PRBool aIsOverlay, PRBool
aUseProfile, PRBool aRemove);
nsresult LoadStyleSheetWithURL(nsIURI* aURL, nsICSSStyleSheet** aSheet);
static nsresult LoadStyleSheetWithURL(nsIURI* aURL, nsICSSStyleSheet** aSheet);
nsresult LoadInstallDataSource();
nsresult LoadProfileDataSource();
@ -127,89 +101,130 @@ protected:
void FlushAllCaches();
private:
nsresult LoadDataSource(const nsACString &aFileName,
nsIRDFDataSource **aResult,
PRBool aUseProfileDirOnly = PR_FALSE,
const char *aProfilePath = nsnull);
static nsresult RefreshWindow(nsIDOMWindowInternal* aWindow);
static nsresult GetProviderAndPath(nsIURL* aChromeURL,
nsACString& aProvider, nsACString& aPath);
static nsresult GetProfileRoot(nsACString& aFileURL);
static nsresult GetInstallRoot(nsIFile** aFileURL);
NS_HIDDEN_(void) ProcessProvider(PRFileDesc *fd, nsIRDFService* aRDFs,
nsIRDFDataSource* ds, nsIRDFResource* aRoot,
PRBool aIsLocale, const nsACString& aBaseURL);
NS_HIDDEN_(void) ProcessOverlays(PRFileDesc *fd, nsIRDFDataSource* ds,
nsIRDFResource* aRoot,
const nsCSubstring& aType);
nsresult RefreshWindow(nsIDOMWindowInternal* aWindow);
NS_HIDDEN_(nsresult) ProcessManifest(nsILocalFile* aManifest, PRBool aSkinOnly);
NS_HIDDEN_(nsresult) ProcessManifestBuffer(char *aBuffer, PRInt32 aLength, nsILocalFile* aManifest, PRBool aSkinOnly);
NS_HIDDEN_(nsresult) ProcessNewChromeFile(nsILocalFile *aListFile, nsIURI* aManifest);
NS_HIDDEN_(nsresult) ProcessNewChromeBuffer(char *aBuffer, PRInt32 aLength, nsIURI* aManifest);
nsresult GetArcs(nsIRDFDataSource* aDataSource,
const nsACString& aType,
nsISimpleEnumerator** aResult);
public:
struct ProviderEntry
{
ProviderEntry(const nsACString& aProvider, nsIURI* aBase) :
provider(aProvider),
baseURI(aBase) { }
nsresult AddToCompositeDataSource(PRBool aUseProfile);
nsresult GetBaseURL(const nsACString& aPackage,
const nsACString& aProvider,
nsACString& aBaseURL);
nsCString provider;
nsCOMPtr<nsIURI> baseURI;
};
nsresult FindProvider(const nsACString& aPackage,
const nsACString& aProvider,
nsCOMPtr<nsIRDFResource> &aProviderResource,
nsCOMPtr<nsIRDFResource> &aPackageResource);
class nsProviderArray
{
public:
nsProviderArray() :
mArray(1) { }
~nsProviderArray()
{ Clear(); }
nsresult TrySubProvider(const nsACString& aPackage,
nsIRDFResource* aProviderResource,
nsCOMPtr<nsIRDFResource> &aSelectedProvider);
// When looking up locales and skins, the "selected" locale is not always
// available. This enum identifies what kind of match is desired/found.
enum MatchType {
EXACT = 0,
LOCALE = 1, // "en-GB" is selected, we found "en-US"
SKIN = 2
};
nsresult FindSubProvider(const nsACString& aPackage,
const nsACString& aProvider,
nsCOMPtr<nsIRDFResource> &aSelectedProvider);
ProviderEntry* GetProvider(const nsACString& aPreferred, MatchType aType);
nsIURI* GetBase(const nsACString& aPreferred, MatchType aType);
const nsACString& GetSelected(const nsACString& aPreferred, MatchType aType);
void SetBase(const nsACString& aPreferred, nsIURI* base);
void Clear();
nsresult InstallProvider(const nsACString& aProviderType,
const nsACString& aBaseURL,
PRBool aUseProfile, PRBool aAllowScripts, PRBool aRemove);
nsresult UninstallProvider(const nsACString& aProviderType, const nsACString& aProviderName, PRBool aUseProfile);
nsresult UninstallFromDynamicDataSource(const nsACString& aPackageName,
PRBool aIsOverlay, PRBool aUseProfile);
private:
nsVoidArray mArray;
};
NS_HIDDEN_(nsresult) ProcessNewChromeFile(nsILocalFile *aListFile);
NS_HIDDEN_(nsresult) ProcessNewChromeBuffer(char *aBuffer, PRInt32 aLength);
struct PackageEntry : public PLDHashEntryHdr
{
PackageEntry(const nsACString& package);
~PackageEntry() { }
PRBool GetProviderCount(const nsACString& aProviderType, nsIRDFDataSource* aDataSource);
// Available flags
enum {
// This is a "platform" package (e.g. chrome://global-platform/).
// Appends one of win/ unix/ mac/ to the base URI.
PLATFORM_PACKAGE = 1 << 0
};
protected:
nsCString mProfileRoot;
nsCString mInstallRoot;
nsCString package;
nsCOMPtr<nsIURI> baseURI;
PRUint32 flags;
nsProviderArray locales;
nsProviderArray skins;
};
nsCOMPtr<nsIRDFCompositeDataSource> mChromeDataSource;
nsCOMPtr<nsIRDFDataSource> mInstallDirChromeDataSource;
nsCOMPtr<nsIRDFDataSource> mUIDataSource;
private:
static const void* GetKey(PLDHashTable *table, PLDHashEntryHdr *entry);
static PLDHashNumber HashKey(PLDHashTable *table, const void *key);
static PRBool MatchKey(PLDHashTable *table, const PLDHashEntryHdr *entry,
const void *key);
static void ClearEntry(PLDHashTable *table, PLDHashEntryHdr *entry);
static PRBool InitEntry(PLDHashTable *table, PLDHashEntryHdr *entry,
const void *key);
nsSupportsHashtable* mDataSourceTable;
nsIRDFService* mRDFService;
nsIRDFContainerUtils* mRDFContainerUtils;
static const PLDHashTableOps kTableOps;
public:
class OverlayListEntry : public nsURIHashKey
{
public:
typedef nsURIHashKey::KeyType KeyType;
typedef nsURIHashKey::KeyTypePointer KeyTypePointer;
OverlayListEntry(KeyTypePointer aKey) : nsURIHashKey(aKey) { }
OverlayListEntry(OverlayListEntry& toCopy) : nsURIHashKey(toCopy),
mArray(toCopy.mArray) { }
~OverlayListEntry() { }
void AddURI(nsIURI* aURI);
nsCOMArray<nsIURI> mArray;
};
class OverlayListHash
{
public:
OverlayListHash() { }
~OverlayListHash() { }
PRBool Init() { return mTable.Init(); }
void Add(nsIURI* aBase, nsIURI* aOverlay);
void Clear() { mTable.Clear(); }
const nsCOMArray<nsIURI>* GetArray(nsIURI* aBase);
private:
nsTHashtable<OverlayListEntry> mTable;
};
private:
// Hash of package names ("global") to PackageEntry objects
PLDHashTable mPackagesHash;
// Hashes on the file to be overlaid (chrome://browser/content/browser.xul)
// to a list of overlays/stylesheets
OverlayListHash mOverlayHash;
OverlayListHash mStyleHash;
nsCString mSelectedLocale;
nsCString mSelectedSkin;
nsInterfaceHashtable<nsCStringHashKey, nsIRDFResource> mSelectedLocales;
nsInterfaceHashtable<nsCStringHashKey, nsIRDFResource> mSelectedSkins;
// Resources
nsCOMPtr<nsIRDFResource> mBaseURL;
nsCOMPtr<nsIRDFResource> mPackages;
nsCOMPtr<nsIRDFResource> mPackage;
nsCOMPtr<nsIRDFResource> mName;
nsCOMPtr<nsIRDFResource> mImage;
nsCOMPtr<nsIRDFResource> mLocType;
nsCOMPtr<nsIRDFResource> mAllowScripts;
nsCOMPtr<nsIRDFResource> mHasOverlays;
nsCOMPtr<nsIRDFResource> mHasStylesheets;
nsCOMPtr<nsIRDFResource> mDisabled;
nsCOMPtr<nsIRDFResource> mPlatformPackage;
// useful atoms - these are static atoms, so don't use nsCOMPtr
static nsIAtom* sCPrefix; // "c"
PRPackedBool mInstallInitialized;
PRPackedBool mProfileInitialized;
// Boolean that indicates we should batch flushes of the main
// chrome.rdf file.
PRPackedBool mBatchInstallFlushes;
};

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

@ -40,6 +40,7 @@
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
interface nsIURI;
[scriptable, uuid(68389281-f6d0-4533-841d-344a2018140c)]
@ -50,9 +51,8 @@ interface nsIChromeRegistry : nsISupports
const PRInt32 FULL = 2;
/**
* Convert a chrome URL into a canonical representation; specifically,
*
* chrome://package/provider/file
* Resolve a chrome URL to an loadable URI using the information in the
* registry. Does not modify aChromeURL.
*
* Chrome URLs are allowed to be specified in "shorthand", leaving the
* "file" portion off. In that case, the URL is expanded to:
@ -65,17 +65,9 @@ interface nsIChromeRegistry : nsISupports
* "css" for a "skin" package, and
* "dtd" for a "locale" package.
*
* @param aChromeURL the URL that is to be canonified.
*/
void canonify(in nsIURI aChromeURL);
/**
* Convert a chrome URL to a "real" using the information in the registry.
* Does not modify aChromeURL.
*
* @param aChromeURL the URL that is to be converted.
*/
AUTF8String convertChromeURL(in nsIURI aChromeURL);
nsIURI convertChromeURL(in nsIURI aChromeURL);
/**
* refresh the chrome list at runtime, looking for new packages/etc
@ -83,7 +75,7 @@ interface nsIChromeRegistry : nsISupports
void checkForNewChrome();
};
[scriptable, uuid(a1208469-47cf-4776-9062-f8b431afb6fa)]
[scriptable, uuid(3e51f40b-b4b0-4e60-ac45-6c63477ebe41)]
interface nsIXULChromeRegistry : nsIChromeRegistry
{
/* Should be called when locales change to reload all chrome (including XUL). */
@ -94,25 +86,13 @@ interface nsIXULChromeRegistry : nsIChromeRegistry
/* Should be called when skins change. Reloads only stylesheets. */
void refreshSkins();
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);
/* Installation APIs */
void installSkin(in string baseURL,
in boolean useProfile,
in boolean allowScripts);
void uninstallSkin(in ACString skinName, in boolean useProfile);
void installLocale(in string baseURL, in boolean useProfile);
void uninstallLocale(in ACString localeName, in boolean useProfile);
void installPackage(in string baseURL, in boolean useProfile);
void uninstallPackage(in ACString packageName, in boolean useProfile);
/**
* Installable skin XBL is not always granted the same privileges as other
* chrome. This asks the chrome registry whether scripts are allowed to be
* run for a particular chrome URI. Do not pass non-chrome URIs to this
* method.
*/
boolean allowScriptsForPackage(in nsIURI url);
};
%{ C++

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

@ -48,6 +48,7 @@
#include "nsISupports.h"
class nsIContent;
class nsIDocument;
class nsIXBLBinding;
class nsIXBLDocumentInfo;
class nsIAtom;

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

@ -329,13 +329,11 @@ nsXBLDocGlobalObject::GetPrincipal()
return document->GetPrincipal();
}
static PRBool IsChromeOrResourceURI(nsIURI* aURI)
static PRBool IsChromeURI(nsIURI* aURI)
{
PRBool isChrome = PR_FALSE;
PRBool isResource = PR_FALSE;
if (NS_SUCCEEDED(aURI->SchemeIs("chrome", &isChrome)) &&
NS_SUCCEEDED(aURI->SchemeIs("resource", &isResource)))
return (isChrome || isResource);
if (NS_SUCCEEDED(aURI->SchemeIs("chrome", &isChrome)))
return isChrome;
return PR_FALSE;
}
@ -348,12 +346,12 @@ nsXBLDocumentInfo::nsXBLDocumentInfo(nsIDocument* aDocument)
mBindingTable(nsnull)
{
nsIURI* uri = aDocument->GetDocumentURI();
if (IsChromeOrResourceURI(uri)) {
if (IsChromeURI(uri)) {
// Cache whether or not this chrome XBL can execute scripts.
nsCOMPtr<nsIXULChromeRegistry> reg(do_GetService(NS_CHROMEREGISTRY_CONTRACTID));
if (reg) {
PRBool allow = PR_TRUE;
reg->AllowScriptsForSkin(uri, &allow);
reg->AllowScriptsForPackage(uri, &allow);
SetScriptAccess(allow);
}
}

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

@ -57,11 +57,12 @@ REQUIRES = xpcom \
$(NULL)
CPPSRCS = \
nsEmbedChromeRegistry.cpp \
nsEmbedGlobalHistory.cpp \
nsEmbedLiteModule.cpp \
$(NULL)
# nsEmbedChromeRegistry.cpp \
# bring in the chrome protocol handler
# LOBJS = $(topsrcdir)/rdf/chrome/src/nsChromeProtocolHandler.$(OBJ_SUFFIX)

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

@ -58,9 +58,10 @@ nsSimpleChromeRegistry::Canonify(nsIURI *aChromeURL)
}
NS_IMETHODIMP
nsSimpleChromeRegistry::ConvertChromeURL(nsIURI *aChromeURL, nsACString & _retval)
nsSimpleChromeRegistry::ConvertChromeURL(nsIURI *aChromeURL, nsIURI* *aResult)
{
return aChromeURL->GetSpec(_retval);
NS_WARNING("Who is calling ConvertChromeURL?");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsSimpleChromeRegistry::CheckForNewChrome()

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

@ -215,6 +215,7 @@ bin\components\toolkitprofile.xpt
; toolkit
bin\components\appstartup.xpt
bin\components\commandlines.xpt
bin\components\chrome.xpt
; rdf
bin\components\rdf.xpt

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

@ -39,6 +39,7 @@
#include "pldhash.h"
#include "nsCOMPtr.h"
#include "nsCRT.h"
#include "nsIURI.h"
/**
* Hashtable key class to use with nsTHashtable/nsBaseHashtable

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

@ -42,7 +42,7 @@
#include "nsISupports.idl"
#include "nsIChromeRegistry.idl"
[scriptable, uuid(ed47f6b3-8b7e-4dba-8cbd-d0560274ba4a)]
[scriptable, uuid(382370d0-a7cd-47ae-aa4e-af74f5edf652)]
interface nsIChromeRegistrySea : nsIXULChromeRegistry
{
/* Applies a skin or locale to all possible packages */
@ -89,4 +89,22 @@ interface nsIChromeRegistrySea : nsIXULChromeRegistry
in boolean useProfile);
ACString getSelectedSkin(in ACString packageName);
/* Installation APIs */
void installSkin(in string baseURL,
in boolean useProfile,
in boolean allowScripts);
void uninstallSkin(in ACString skinName, in boolean useProfile);
void installLocale(in string baseURL, in boolean useProfile);
void uninstallLocale(in ACString localeName, in boolean useProfile);
void installPackage(in string baseURL, in boolean useProfile);
void uninstallPackage(in ACString packageName, in boolean useProfile);
/* 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);
};

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

@ -42,6 +42,7 @@
*/
#include "nsChromeProtocolHandler.h"
#include "nsChromeRegistry.h"
#include "nsCOMPtr.h"
#include "nsContentCID.h"
#include "nsCRT.h"
@ -68,6 +69,7 @@
#include "nsIXULPrototypeDocument.h"
#endif
#include "nsNetCID.h"
#include "nsNetUtil.h"
#include "nsXPIDLString.h"
#include "nsString.h"
#include "prlog.h"
@ -594,21 +596,7 @@ nsChromeProtocolHandler::NewURI(const nsACString &aSpec,
// Canonify the "chrome:" URL; e.g., so that we collapse
// "chrome://navigator/content/" and "chrome://navigator/content"
// and "chrome://navigator/content/navigator.xul".
// Try the global cache first.
nsCOMPtr<nsIChromeRegistry> reg = gChromeRegistry;
// If that fails, the service has not been instantiated yet; let's
// do that now.
if (!reg) {
reg = do_GetService(NS_CHROMEREGISTRY_CONTRACTID, &rv);
if (NS_FAILED(rv))
return rv;
}
NS_ASSERTION(reg, "Must have a chrome registry by now");
rv = reg->Canonify(uri);
rv = nsChromeRegistry::Canonify(uri);
if (NS_FAILED(rv))
return rv;
@ -632,7 +620,7 @@ nsChromeProtocolHandler::NewChannel(nsIURI* aURI,
nsCOMPtr<nsIURI> debugClone;
debug_rv = aURI->Clone(getter_AddRefs(debugClone));
if (NS_SUCCEEDED(debug_rv)) {
debug_rv = debugReg->Canonify(debugClone);
debug_rv = nsChromeRegistry::Canonify(debugClone);
if (NS_SUCCEEDED(debug_rv)) {
PRBool same;
debug_rv = aURI->Equals(debugClone, &same);
@ -695,17 +683,13 @@ nsChromeProtocolHandler::NewChannel(nsIURI* aURI,
if (NS_FAILED(rv)) return rv;
}
nsCAutoString spec;
rv = reg->ConvertChromeURL(aURI, spec);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIIOService> ioServ(do_GetService(kIOServiceCID, &rv));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIURI> chromeURI;
rv = ioServ->NewURI(spec, nsnull, nsnull, getter_AddRefs(chromeURI));
rv = reg->ConvertChromeURL(aURI, getter_AddRefs(chromeURI));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIIOService> ioServ (do_GetIOService());
if (!ioServ) return NS_ERROR_FAILURE;
rv = ioServ->NewChannelFromURI(chromeURI, getter_AddRefs(result));
if (NS_FAILED(rv)) return rv;

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

@ -440,7 +440,7 @@ GetBaseURLFile(const nsACString& aBaseURL, nsIFile** aFile)
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsresult
nsChromeRegistry::Canonify(nsIURI* aChromeURI)
{
// Canonicalize 'chrome:' URLs. We'll take any 'chrome:' URL
@ -471,12 +471,10 @@ nsChromeRegistry::Canonify(nsIURI* aChromeURI)
}
NS_IMETHODIMP
nsChromeRegistry::ConvertChromeURL(nsIURI* aChromeURL, nsACString& aResult)
nsChromeRegistry::ConvertChromeURL(nsIURI* aChromeURL, nsIURI* *aResult)
{
nsresult rv = NS_OK;
NS_ASSERTION(aChromeURL, "null url!");
if (!aChromeURL)
return NS_ERROR_NULL_POINTER;
NS_ENSURE_ARG_POINTER(aChromeURL);
// No need to canonify as the SplitURL() that we
// do is the equivalent of canonification without modifying
@ -541,9 +539,9 @@ nsChromeRegistry::ConvertChromeURL(nsIURI* aChromeURL, nsACString& aResult)
}
}
aResult = finalURL + remaining;
finalURL.Append(remaining);
return NS_OK;
return NS_NewURI(aResult, finalURL);
}
nsresult
@ -2959,7 +2957,8 @@ nsresult nsChromeRegistry::LoadProfileDataSource()
return NS_OK;
}
NS_IMETHODIMP nsChromeRegistry::AllowScriptsForSkin(nsIURI* aChromeURI, PRBool *aResult)
NS_IMETHODIMP
nsChromeRegistry::AllowScriptsForPackage(nsIURI* aChromeURI, PRBool *aResult)
{
*aResult = PR_TRUE;

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

@ -86,6 +86,9 @@ public:
nsresult Init();
// used by the protocol handler
static nsresult Canonify(nsIURI* aChromeURL);
public:
static nsresult FollowArc(nsIRDFDataSource *aDataSource,
nsACString& aResult,

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -50,6 +50,8 @@ REQUIRES = \
appcomps \
toolkitcomps \
appshell \
appstartup \
chrome \
content \
docshell \
dom \

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

@ -77,6 +77,7 @@
#include "nsIServiceManager.h"
#include "nsISupportsPrimitives.h"
#include "nsITimelineService.h"
#include "nsIToolkitChromeRegistry.h"
#include "nsIToolkitProfile.h"
#include "nsIToolkitProfileService.h"
#include "nsIURI.h"
@ -674,6 +675,11 @@ ScopedXPCOMStartup::SetWindowCreator(nsINativeAppSupport* native)
nativeFactory);
NS_ENSURE_SUCCESS(rv, rv);
// Inform the chrome registry about OS accessibility
nsCOMPtr<nsIToolkitChromeRegistry> cr (do_GetService(NS_CHROMEREGISTRY_CONTRACTID));
if (cr)
cr->CheckForOSAccessibility();
nsCOMPtr<nsIWindowCreator> creator (do_GetService(NS_APPSTARTUP_CONTRACTID));
if (!creator) return NS_ERROR_UNEXPECTED;

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

@ -50,6 +50,12 @@
#include "nscore.h"
// This directory service key is a lot like "ProfD", except that it will be
// available even when the profile hasn't been "started", or after is has been
// shut down. If we're in "no-profile" mode, such as showing the profile manager UI,
// this key will not be available.
#define NS_APP_PROFILE_DIR_STARTUP "ProfDS"
class nsACString;
struct nsXREAppData;

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

@ -47,6 +47,7 @@
#include "nsILocalFile.h"
#include "nsIObserverService.h"
#include "nsIProfileChangeStatus.h"
#include "nsIToolkitChromeRegistry.h"
#include "nsAppDirectoryServiceDefs.h"
#include "nsDirectoryServiceDefs.h"
@ -282,6 +283,9 @@ nsXREDirProvider::GetFile(const char* aProperty, PRBool* aPersistent,
rv = mProfileDir->Clone(getter_AddRefs(file));
rv |= file->AppendNative(NS_LITERAL_CSTRING("chrome"));
}
else if (!strcmp(aProperty, NS_APP_PROFILE_DIR_STARTUP) && mProfileDir) {
return mProfileDir->Clone(aFile);
}
else if (mProfileNotified) {
if (!strcmp(aProperty, NS_APP_USER_PROFILE_50_DIR) ||
!strcmp(aProperty, NS_APP_PREFS_50_DIR)) {
@ -356,34 +360,48 @@ nsXREDirProvider::GetFile(const char* aProperty, PRBool* aPersistent,
}
static void
LoadDirsIntoArray(nsIFile* aComponentsList, nsCOMArray<nsIFile>& aDirectories)
LoadDirsIntoArray(nsIFile* aComponentsList, const char* aSection,
const char *const* aAppendList,
nsCOMArray<nsIFile>& aDirectories)
{
nsINIParser parser;
nsCOMPtr<nsILocalFile> lf(do_QueryInterface(aComponentsList));
parser.Init(lf);
char parserBuf[MAXPATHLEN];
nsresult rv = parser.GetString("Extra Files", "Count", parserBuf, MAXPATHLEN);
nsresult rv = parser.GetString(aSection, "Count", parserBuf, MAXPATHLEN);
if (NS_SUCCEEDED(rv)) {
PRInt32 count = atoi(parserBuf);
char buf[10];
char buf[18];
nsCOMPtr<nsIFile> parent;
aComponentsList->GetParent(getter_AddRefs(parent));
for (PRInt32 i = 0; i < count; ++i) {
sprintf(buf, "File%d", i);
nsCOMPtr<nsILocalFile> lfParent (do_QueryInterface(parent));
rv = parser.GetString("Extra Files", buf, parserBuf, MAXPATHLEN);
for (PRInt32 i = 0; i < count; ++i) {
sprintf(buf, "Extension%d", i);
rv = parser.GetString(aSection, buf, parserBuf, MAXPATHLEN);
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsILocalFile> lfParent(do_QueryInterface(parent));
nsCOMPtr<nsILocalFile> dir(do_CreateInstance("@mozilla.org/file/local;1"));
dir->SetRelativeDescriptor(lfParent, nsDependentCString(parserBuf));
nsCOMPtr<nsIFile> dirAsFile(do_QueryInterface(dir));
aDirectories.AppendObject(dirAsFile);
const char* const* a = aAppendList;
while (*a) {
dir->AppendNative(nsDependentCString(*a));
++a;
}
PRBool exists;
rv = dir->Exists(&exists);
if (NS_SUCCEEDED(rv) && exists)
aDirectories.AppendObject(dir);
}
}
}
}
static const char *const kAppendChromeManifests[] =
{ "chrome.manifest", nsnull };
NS_IMETHODIMP
nsXREDirProvider::GetFiles(const char* aProperty, nsISimpleEnumerator** aResult)
{
@ -402,16 +420,21 @@ nsXREDirProvider::GetFiles(const char* aProperty, nsISimpleEnumerator** aResult)
directories.AppendObject(file);
}
static const char *const kAppendCompDir[] = { "components", nsnull };
nsCOMPtr<nsIFile> appFile;
mAppDir->Clone(getter_AddRefs(appFile));
appFile->AppendNative(NS_LITERAL_CSTRING("components.ini"));
LoadDirsIntoArray(appFile, directories);
appFile->AppendNative(NS_LITERAL_CSTRING("extensions.ini"));
LoadDirsIntoArray(appFile, "ExtensionDirs",
kAppendCompDir, directories);
nsCOMPtr<nsIFile> profileFile;
if (mProfileDir) {
nsCOMPtr<nsIFile> profileFile;
mProfileDir->Clone(getter_AddRefs(profileFile));
profileFile->AppendNative(NS_LITERAL_CSTRING("components.ini"));
LoadDirsIntoArray(profileFile, directories);
profileFile->AppendNative(NS_LITERAL_CSTRING("extensions.ini"));
LoadDirsIntoArray(profileFile, "ExtensionDirs",
kAppendCompDir, directories);
}
rv = NS_NewArrayEnumerator(aResult, directories);
@ -429,20 +452,78 @@ nsXREDirProvider::GetFiles(const char* aProperty, nsISimpleEnumerator** aResult)
directories.AppendObject(file);
}
static const char *const kAppendPrefDir[] = { "defaults", "pref", nsnull };
nsCOMPtr<nsIFile> appFile;
mAppDir->Clone(getter_AddRefs(appFile));
appFile->AppendNative(NS_LITERAL_CSTRING("defaults.ini"));
LoadDirsIntoArray(appFile, directories);
appFile->AppendNative(NS_LITERAL_CSTRING("extensions.ini"));
LoadDirsIntoArray(appFile, "ExtensionDirs",
kAppendPrefDir, directories);
nsCOMPtr<nsIFile> profileFile;
if (mProfileDir) {
mProfileDir->Clone(getter_AddRefs(profileFile));
profileFile->AppendNative(NS_LITERAL_CSTRING("defaults.ini"));
LoadDirsIntoArray(profileFile, directories);
profileFile->AppendNative(NS_LITERAL_CSTRING("extensions.ini"));
LoadDirsIntoArray(profileFile, "ExtensionDirs",
kAppendPrefDir, directories);
}
rv = NS_NewArrayEnumerator(aResult, directories);
}
else if (!strcmp(aProperty, NS_CHROME_MANIFESTS_FILE_LIST)) {
nsCOMArray<nsIFile> manifests;
nsCOMPtr<nsIFile> manifest;
mAppDir->Clone(getter_AddRefs(manifest));
manifest->AppendNative(NS_LITERAL_CSTRING("chrome"));
manifests.AppendObject(manifest);
if (mXULAppDir) {
nsCOMPtr<nsIFile> file;
mXULAppDir->Clone(getter_AddRefs(file));
file->AppendNative(NS_LITERAL_CSTRING("chrome"));
PRBool exists;
if (NS_SUCCEEDED(file->Exists(&exists)) && exists)
manifests.AppendObject(file);
}
nsCOMPtr<nsIFile> appFile;
mAppDir->Clone(getter_AddRefs(appFile));
appFile->AppendNative(NS_LITERAL_CSTRING("extensions.ini"));
LoadDirsIntoArray(appFile, "ExtensionDirs",
kAppendChromeManifests, manifests);
if (mProfileDir) {
nsCOMPtr<nsIFile> profileFile;
mProfileDir->Clone(getter_AddRefs(profileFile));
profileFile->AppendNative(NS_LITERAL_CSTRING("extensions.ini"));
LoadDirsIntoArray(profileFile, "ExtensionDirs",
kAppendChromeManifests, manifests);
}
rv = NS_NewArrayEnumerator(aResult, manifests);
}
else if (!strcmp(aProperty, NS_SKIN_MANIFESTS_FILE_LIST)) {
nsCOMArray<nsIFile> manifests;
nsCOMPtr<nsIFile> appFile;
mAppDir->Clone(getter_AddRefs(appFile));
appFile->AppendNative(NS_LITERAL_CSTRING("extensions.ini"));
LoadDirsIntoArray(appFile, "ThemeDirs",
kAppendChromeManifests, manifests);
if (mProfileDir) {
nsCOMPtr<nsIFile> profileFile;
mProfileDir->Clone(getter_AddRefs(profileFile));
profileFile->AppendNative(NS_LITERAL_CSTRING("extensions.ini"));
LoadDirsIntoArray(profileFile, "ThemeDirs",
kAppendChromeManifests, manifests);
}
rv = NS_NewArrayEnumerator(aResult, manifests);
}
else if (!strcmp(aProperty, NS_APP_CHROME_DIR_LIST)) {
nsCOMArray<nsIFile> directories;

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

@ -53,6 +53,10 @@
#include "nsIFileChannel.h"
#include "nsDirectoryService.h"
#include "nsDirectoryServiceDefs.h"
#include "nsAppDirectoryServiceDefs.h"
#include "nsDirectoryServiceUtils.h"
#include "nsNetUtil.h"
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
@ -169,9 +173,7 @@ nsInstallInfo::nsInstallInfo(PRUint32 aInstallType,
const PRUnichar* aArgs,
nsIPrincipal* aPrincipal,
PRUint32 flags,
nsIXPIListener* aListener,
nsIXULChromeRegistry* aChromeRegistry,
nsIExtensionManager* aExtensionManager)
nsIXPIListener* aListener)
: mPrincipal(aPrincipal),
mError(0),
mType(aInstallType),
@ -179,11 +181,45 @@ nsInstallInfo::nsInstallInfo(PRUint32 aInstallType,
mURL(aURL),
mArgs(aArgs),
mFile(aFile),
mListener(aListener),
mChromeRegistry(aChromeRegistry),
mExtensionManager(aExtensionManager)
mListener(aListener)
{
MOZ_COUNT_CTOR(nsInstallInfo);
nsresult rv;
// Failure is an option, and will occur in the stub installer.
NS_WITH_ALWAYS_PROXIED_SERVICE(CHROMEREG_IFACE, cr,
NS_CHROMEREGISTRY_CONTRACTID,
NS_UI_THREAD_EVENTQ, &rv);
if (NS_SUCCEEDED(rv)) {
mChromeRegistry = cr;
nsCAutoString spec;
rv = NS_GetURLSpecFromFile(aFile, spec);
if (NS_SUCCEEDED(rv)) {
spec.Insert(NS_LITERAL_CSTRING("jar:"), 0);
spec.AppendLiteral("!/");
#ifdef MOZ_XUL_APP
NS_NewURI(getter_AddRefs(mFileJARURL), spec);
#else
mFileJARSpec.Assign(spec);
#endif
}
}
#ifdef MOZ_XUL_APP
NS_WITH_ALWAYS_PROXIED_SERVICE(nsIExtensionManager, em,
"@mozilla.org/extensions/manager;1",
NS_UI_THREAD_EVENTQ, &rv);
if (NS_SUCCEEDED(rv))
mExtensionManager = em;
nsCOMPtr<nsIFile> manifest;
rv = NS_GetSpecialDirectory(NS_APP_CHROME_DIR, getter_AddRefs(manifest));
if (NS_SUCCEEDED(rv))
NS_NewFileURI(getter_AddRefs(mManifestURL), manifest);
#endif
}

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

@ -53,6 +53,7 @@
#include "nsHashtable.h"
#include "nsCOMPtr.h"
#include "nsILocalFile.h"
#include "nsIURI.h"
#include "nsSoftwareUpdate.h"
@ -70,10 +71,17 @@
#include "nsIComponentManager.h"
#include "nsIEnumerator.h"
#include "nsIZipReader.h"
#include "nsIChromeRegistry.h"
#include "nsIExtensionManager.h"
#include "nsIPrincipal.h"
#ifdef MOZ_XUL_APP
#include "nsIToolkitChromeRegistry.h"
#define CHROMEREG_IFACE nsIToolkitChromeRegistry
#else
#include "nsIChromeRegistrySea.h"
#define CHROMEREG_IFACE nsIChromeRegistrySea
#endif
#define XPINSTALL_BUNDLE_URL "chrome://global/locale/xpinstall/xpinstall.properties"
//file and directory name length maximums
@ -95,9 +103,7 @@ class nsInstallInfo
const PRUnichar* aArgs,
nsIPrincipal* mPrincipal,
PRUint32 aFlags,
nsIXPIListener* aListener,
nsIXULChromeRegistry* aChromeReg,
nsIExtensionManager* aExtensionManager);
nsIXPIListener* aListener);
virtual ~nsInstallInfo();
@ -107,8 +113,15 @@ class nsInstallInfo
PRUint32 GetFlags() { return mFlags; }
PRUint32 GetType() { return mType; }
nsIXPIListener* GetListener() { return mListener.get(); }
nsIXULChromeRegistry* GetChromeRegistry() { return mChromeRegistry.get(); }
nsIExtensionManager* GetExtensionManager(){ return mExtensionManager.get(); }
CHROMEREG_IFACE* GetChromeRegistry() { return mChromeRegistry; }
#ifdef MOZ_XUL_APP
nsIExtensionManager* GetExtensionManager() { return mExtensionManager; }
nsIURI* GetFileJARURL() { return mFileJARURL; }
nsIURI* GetManifestURL() { return mManifestURL; }
#else
const nsCString& GetFileJARSpec() { return mFileJARSpec; }
#endif
nsCOMPtr<nsIPrincipal> mPrincipal;
@ -123,8 +136,15 @@ class nsInstallInfo
nsCOMPtr<nsIFile> mFile;
nsCOMPtr<nsIXPIListener> mListener;
nsCOMPtr<nsIXULChromeRegistry> mChromeRegistry;
nsCOMPtr<CHROMEREG_IFACE> mChromeRegistry;
#ifdef MOZ_XUL_APP
nsCOMPtr<nsIURI> mFileJARURL;
nsCOMPtr<nsIURI> mManifestURL;
nsCOMPtr<nsIExtensionManager> mExtensionManager;
#else
nsCString mFileJARSpec;
#endif
};
#if defined(XP_WIN) || defined(XP_OS2)
@ -306,8 +326,8 @@ class nsInstall
PRInt32 GetInstallPlatform(nsCString& aPlatform);
nsIXULChromeRegistry* GetChromeRegistry() { return mChromeRegistry; }
void SetChromeRegistry(nsIXULChromeRegistry* reg)
CHROMEREG_IFACE* GetChromeRegistry() { return mChromeRegistry; }
void SetChromeRegistry(CHROMEREG_IFACE* reg)
{ mChromeRegistry = reg; }
PRUint32 GetFinalStatus() { return mFinalStatus; }
@ -335,7 +355,7 @@ class nsInstall
nsString mInstallURL;
PRUint32 mInstallFlags;
nsCString mInstallPlatform;
nsIXULChromeRegistry* mChromeRegistry; // we don't own it, it outlives us
CHROMEREG_IFACE* mChromeRegistry; // we don't own it, it outlives us
nsInstallFolder* mPackageFolder;
PRBool mUserCancelled;

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

@ -1881,16 +1881,13 @@ static JSFunctionSpec InstallMethods[] =
};
JSObject * InitXPInstallObjects(JSContext *jscontext,
JSObject *global,
nsIFile* jarfile,
const PRUnichar* url,
const PRUnichar* args,
PRUint32 flags,
nsIXULChromeRegistry* reg,
CHROMEREG_IFACE* reg,
nsIZipReader * theJARFile)
{
JSObject *installObject = nsnull;

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

@ -274,11 +274,38 @@ PRInt32 nsRegisterItem::Complete()
{
nsresult rv = NS_OK;
PRInt32 result = nsInstall::SUCCESS;
CHROMEREG_IFACE* reg = mInstall->GetChromeRegistry();
#ifndef MOZ_XUL_APP
PRBool isProfile = mChromeType & CHROME_PROFILE;
nsIXULChromeRegistry* reg = mInstall->GetChromeRegistry();
#endif
if ( reg && !(mChromeType & CHROME_DELAYED) )
{
#ifdef MOZ_XUL_APP
nsCOMPtr<nsIURI> baseuri;
rv = NS_NewURI(getter_AddRefs(baseuri), mURL);
if (NS_FAILED(rv)) {
LogError(NS_LITERAL_STRING("NS_NewURI failed."), rv);
}
else {
nsCOMPtr<nsIURI> manifesturi;
rv = NS_NewURI(getter_AddRefs(manifesturi),
NS_LITERAL_CSTRING("resource:///chrome/xpinstall.manifest"));
if (NS_FAILED(rv)) {
LogError(NS_LITERAL_STRING("NS_NewURI failed."), rv);
}
else {
PRBool skinOnly = (mChromeType & CHROME_ALL) == CHROME_SKIN;
rv = reg->ProcessContentsManifest(baseuri, manifesturi,
PR_TRUE,
skinOnly);
if (NS_FAILED(rv)) {
LogError(NS_LITERAL_STRING("ProcessContentsManifest failed."), rv);
}
reg->CheckForNewChrome();
}
}
#else
// We can register right away
if (mChromeType & CHROME_SKIN)
rv = reg->InstallSkin(mURL.get(), isProfile, PR_TRUE);
@ -297,6 +324,7 @@ PRInt32 nsRegisterItem::Complete()
if (NS_FAILED(rv)) {
LogError(NS_LITERAL_STRING("InstallPackage() failed."), rv);
}
#endif
}
else
{
@ -440,6 +468,13 @@ PRInt32 nsRegisterItem::Complete()
}
}
PR_Close(fd);
#ifdef MOZ_XUL_APP
// app-chrome.manifest is not regenerated if it exists
rv = startupFile->SetNativeLeafName(NS_LITERAL_CSTRING("app-chrome.manifest"));
if (NS_SUCCEEDED(rv))
startupFile->Remove(PR_FALSE);
#endif
}
else
{

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

@ -313,28 +313,9 @@ nsSoftwareUpdate::InstallJar( nsIFile* aLocalFile,
if ( !aLocalFile )
return NS_ERROR_NULL_POINTER;
// -- grab a proxied Chrome Registry now while we can
nsresult rv;
nsIXULChromeRegistry* chromeRegistry = nsnull;
NS_WITH_ALWAYS_PROXIED_SERVICE( nsIXULChromeRegistry,
tmpRegCR,
NS_CHROMEREGISTRY_CONTRACTID,
NS_UI_THREAD_EVENTQ, &rv);
if (NS_SUCCEEDED(rv))
chromeRegistry = tmpRegCR;
NS_WITH_ALWAYS_PROXIED_SERVICE( nsIExtensionManager,
extensionManager,
"@mozilla.org/extensions/manager;1",
NS_UI_THREAD_EVENTQ, &rv);
if (NS_FAILED(rv))
extensionManager = nsnull;
// we want to call this with or without a chrome registry
nsInstallInfo *info = new nsInstallInfo( 0, aLocalFile, aURL, aArguments, aPrincipal,
flags, aListener, chromeRegistry,
extensionManager);
flags, aListener);
if (!info)
return NS_ERROR_OUT_OF_MEMORY;
@ -356,33 +337,29 @@ nsSoftwareUpdate::InstallChrome( PRUint32 aType,
PRBool aSelect,
nsIXPIListener* aListener)
{
nsresult rv;
NS_WITH_ALWAYS_PROXIED_SERVICE( nsIXULChromeRegistry,
chromeRegistry,
NS_CHROMEREGISTRY_CONTRACTID,
NS_UI_THREAD_EVENTQ, &rv);
if (NS_FAILED(rv))
return rv;
NS_WITH_ALWAYS_PROXIED_SERVICE( nsIExtensionManager,
extensionManager,
"@mozilla.org/extensions/manager;1",
NS_UI_THREAD_EVENTQ, &rv);
if (NS_FAILED(rv))
return rv;
nsInstallInfo *info = new nsInstallInfo( aType,
aFile,
URL,
aName,
nsnull,
(PRUint32)aSelect,
aListener,
chromeRegistry,
extensionManager);
aListener);
if (!info)
return NS_ERROR_OUT_OF_MEMORY;
if (!info->GetChromeRegistry() ||
#ifdef MOZ_XUL_APP
!info->GetExtensionManager() ||
!info->GetFileJARURL() ||
!info->GetManifestURL()
#else
info->GetFileJARSpec().IsEmpty()
#endif
) {
delete info;
return NS_ERROR_FAILURE;
}
PR_CreateThread(PR_USER_THREAD,
RunChromeInstallOnThread,
(void*)info,

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

@ -73,17 +73,13 @@
#include "nsIExtensionManager.h"
#ifndef MOZ_XUL_APP
#include "nsIChromeRegistrySea.h"
#endif
static NS_DEFINE_CID(kSoftwareUpdateCID, NS_SoftwareUpdate_CID);
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
extern JSObject *InitXPInstallObjects(JSContext *jscontext, JSObject *global,
nsIFile* jarfile, const PRUnichar* url,
const PRUnichar* args, PRUint32 flags,
nsIXULChromeRegistry* registry,
CHROMEREG_IFACE* registry,
nsIZipReader* hZip);
extern nsresult InitInstallVersionClass(JSContext *jscontext, JSObject *global, void** prototype);
extern nsresult InitInstallTriggerGlobalClass(JSContext *jscontext, JSObject *global, void** prototype);
@ -94,7 +90,7 @@ static PRInt32 GetInstallScriptFromJarfile(nsIZipReader* hZip, char** scriptBuf
static PRInt32 OpenAndValidateArchive(nsIZipReader* hZip, nsIFile* jarFile, nsIPrincipal* aPrincipal);
static nsresult SetupInstallContext(nsIZipReader* hZip, nsIFile* jarFile, const PRUnichar* url, const PRUnichar* args,
PRUint32 flags, nsIXULChromeRegistry* reg, JSRuntime *jsRT, JSContext **jsCX, JSObject **jsGlob);
PRUint32 flags, CHROMEREG_IFACE* reg, JSRuntime *jsRT, JSContext **jsCX, JSObject **jsGlob);
extern "C" void RunInstallOnThread(void *data);
@ -245,7 +241,6 @@ XPInstallErrorReporter(JSContext *cx, const char *message, JSErrorReport *report
}
///////////////////////////////////////////////////////////////////////////////////////////////
// Function name : OpenAndValidateArchive
// Description : Opens install archive and validates contents
@ -292,7 +287,6 @@ OpenAndValidateArchive(nsIZipReader* hZip, nsIFile* jarFile, nsIPrincipal* aPrin
return nsInstall::SUCCESS;
}
///////////////////////////////////////////////////////////////////////////////////////////////
// Function name : GetInstallScriptFromJarfile
// Description : Extracts and reads in a install.js file from a passed jar file.
@ -370,7 +364,7 @@ static nsresult SetupInstallContext(nsIZipReader* hZip,
const PRUnichar* url,
const PRUnichar* args,
PRUint32 flags,
nsIXULChromeRegistry* reg,
CHROMEREG_IFACE* reg,
JSRuntime *rt,
JSContext **jsCX,
JSObject **jsGlob)
@ -498,13 +492,13 @@ extern "C" void RunInstallOnThread(void *data)
nsCOMPtr<nsIFile> jarpath = installInfo->GetFile();
PRBool installed = PR_FALSE;
finalStatus = OpenAndValidateArchive( hZip,
jarpath,
installInfo->mPrincipal);
if (finalStatus == nsInstall::SUCCESS)
{
#ifdef MOZ_XUL_APP
if (NS_SUCCEEDED(hZip->Test("install.rdf")))
{
// appears to be an Extension Manager install
@ -512,16 +506,18 @@ extern "C" void RunInstallOnThread(void *data)
if (em)
{
rv = em->InstallExtension(jarpath, nsIExtensionManager::FLAG_INSTALL_PROFILE);
if (NS_SUCCEEDED(rv))
installed = PR_TRUE;
if (NS_FAILED(rv))
finalStatus = nsInstall::EXECUTION_ERROR;
} else {
finalStatus = nsInstall::UNEXPECTED_ERROR;
}
}
if (!installed)
// If install.rdf exists, but the install failed, we don't want
// to try an install.js install.
} else
#endif
{
// Either no install.rdf, EM doesn't exist (Suite), or EM install failed:
// If we're the suite, or there is no install.rdf,
// try original XPInstall
// XXX: Shouldn't the third case be an error and skip the old-style attempt?
finalStatus = GetInstallScriptFromJarfile( hZip,
&scriptBuffer,
&scriptLength);
@ -643,107 +639,91 @@ extern "C" void RunChromeInstallOnThread(void *data)
listener->OnInstallStart(info->GetURL());
// make sure we've got a chrome registry -- can't proceed if not
nsIXULChromeRegistry* reg = info->GetChromeRegistry();
#ifndef MOZ_XUL_APP
nsCOMPtr<nsIChromeRegistrySea> cr = do_QueryInterface(reg);
#endif
CHROMEREG_IFACE* reg = info->GetChromeRegistry();
NS_ASSERTION(reg, "We shouldn't get here without a chrome registry.");
if (reg)
{
// build up jar: URL
nsCString spec;
spec.SetCapacity(200);
spec = "jar:";
#ifdef MOZ_XUL_APP
PRBool installed = PR_FALSE;
nsCAutoString localURL;
rv = NS_GetURLSpecFromFile(info->GetFile(), localURL);
if (NS_SUCCEEDED(rv)) {
spec.Append(localURL);
spec.Append("!/");
if (info->GetType() == CHROME_SKIN) {
static NS_DEFINE_CID(kZipReaderCID, NS_ZIPREADER_CID);
nsCOMPtr<nsIZipReader> hZip = do_CreateInstance(kZipReaderCID, &rv);
if (hZip)
rv = hZip->Init(info->GetFile());
if (NS_SUCCEEDED(rv))
rv = hZip->Open();
if (NS_SUCCEEDED(rv))
{
rv = hZip->Test("install.rdf");
nsIExtensionManager* em = info->GetExtensionManager();
if (NS_SUCCEEDED(rv) && em) {
rv = em->InstallTheme(info->GetFile(), nsIExtensionManager::FLAG_INSTALL_PROFILE);
if (NS_SUCCEEDED(rv)) {
installed = PR_TRUE;
info->GetFile()->Remove(PR_FALSE);
// Extension Manager copies the theme .jar file to
// a different location, so remove the temporary file.
}
}
hZip->Close();
}
}
// Now register the new chrome
if (NS_SUCCEEDED(rv))
if (!installed) {
reg->ProcessContentsManifest(info->GetFileJARURL(),
info->GetManifestURL(),
PR_TRUE,
info->GetType() == CHROME_SKIN);
reg->CheckForNewChrome();
}
#else
PRBool isSkin = (info->GetType() & CHROME_SKIN);
PRBool isLocale = (info->GetType() & CHROME_LOCALE);
PRBool isContent = (info->GetType() & CHROME_CONTENT);
PRBool selected = (info->GetFlags() != 0);
const nsCString& spec = info->GetFileJARSpec();
if ( isContent )
rv = reg->InstallPackage(spec.get(), PR_TRUE);
if ( isSkin )
{
PRBool isSkin = (info->GetType() & CHROME_SKIN);
PRBool isLocale = (info->GetType() & CHROME_LOCALE);
PRBool isContent = (info->GetType() & CHROME_CONTENT);
PRBool selected = (info->GetFlags() != 0);
if ( isContent )
{
rv = reg->InstallPackage(spec.get(), PR_TRUE);
}
if ( isSkin )
{
PRBool installed = PR_FALSE;
// Look for a theme manifest
static NS_DEFINE_IID(kIZipReaderIID, NS_IZIPREADER_IID);
static NS_DEFINE_IID(kZipReaderCID, NS_ZIPREADER_CID);
nsresult rv;
nsCOMPtr<nsIZipReader> hZip = do_CreateInstance(kZipReaderCID, &rv);
if (hZip)
rv = hZip->Init(info->GetFile());
if (NS_SUCCEEDED(rv))
{
hZip->Open();
nsIExtensionManager* em = info->GetExtensionManager();
rv = hZip->Test("install.rdf");
if (NS_SUCCEEDED(rv) && em)
{
rv = em->InstallTheme(info->GetFile(), nsIExtensionManager::FLAG_INSTALL_PROFILE);
if (NS_SUCCEEDED(rv))
installed = PR_TRUE;
}
hZip->Close();
// Extension Manager copies the theme .jar file to
// a different location, so remove the temporary file.
info->GetFile()->Remove(PR_FALSE);
}
rv = reg->InstallSkin(spec.get(), PR_TRUE, PR_FALSE);
// We either have an old-style theme with no theme.rdf
// manifest, OR we have a new style theme and InstallTheme
// returned an error (e.g. it's not implemented in Seamonkey,
// or something else went wrong)
if (!installed)
rv = reg->InstallSkin(spec.get(), PR_TRUE, PR_FALSE);
#ifndef MOZ_XUL_APP
if (NS_SUCCEEDED(rv) && selected && cr)
{
NS_ConvertUCS2toUTF8 utf8Args(info->GetArguments());
rv = cr->SelectSkin(utf8Args, PR_TRUE);
}
#endif
}
if ( isLocale )
if (NS_SUCCEEDED(rv) && selected)
{
rv = reg->InstallLocale(spec.get(), PR_TRUE);
#ifndef MOZ_XUL_APP
if (NS_SUCCEEDED(rv) && selected && cr)
{
NS_ConvertUCS2toUTF8 utf8Args(info->GetArguments());
rv = cr->SelectLocale(utf8Args, PR_TRUE);
}
#endif
NS_ConvertUCS2toUTF8 utf8Args(info->GetArguments());
rv = reg->SelectSkin(utf8Args, PR_TRUE);
}
}
// now that all types are registered try to activate
if ( isSkin && selected )
reg->RefreshSkins();
if ( isLocale )
{
rv = reg->InstallLocale(spec.get(), PR_TRUE);
if (NS_SUCCEEDED(rv) && selected)
{
NS_ConvertUCS2toUTF8 utf8Args(info->GetArguments());
rv = reg->SelectLocale(utf8Args, PR_TRUE);
}
}
// now that all types are registered try to activate
if ( isSkin && selected )
reg->RefreshSkins();
#ifdef RELOAD_CHROME_WORKS
// XXX ReloadChrome() crashes right now
if ( isContent || (isLocale && selected) )
reg->ReloadChrome();
#endif
}
#endif
}
if (listener)