зеркало из https://github.com/mozilla/pjs.git
Bug 278534 - Make a plaintext chrome registration file format to replace contents.rdf r/sr=darin+dveditz+ben
This commit is contained in:
Родитель
e74f9ad2f3
Коммит
500173e4bd
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
|
@ -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,127 @@ 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);
|
||||
|
||||
nsresult GetArcs(nsIRDFDataSource* aDataSource,
|
||||
const nsACString& aType,
|
||||
nsISimpleEnumerator** aResult);
|
||||
|
||||
nsresult AddToCompositeDataSource(PRBool aUseProfile);
|
||||
|
||||
nsresult GetBaseURL(const nsACString& aPackage,
|
||||
const nsACString& aProvider,
|
||||
nsACString& aBaseURL);
|
||||
|
||||
nsresult FindProvider(const nsACString& aPackage,
|
||||
const nsACString& aProvider,
|
||||
nsCOMPtr<nsIRDFResource> &aProviderResource,
|
||||
nsCOMPtr<nsIRDFResource> &aPackageResource);
|
||||
|
||||
nsresult TrySubProvider(const nsACString& aPackage,
|
||||
nsIRDFResource* aProviderResource,
|
||||
nsCOMPtr<nsIRDFResource> &aSelectedProvider);
|
||||
|
||||
nsresult FindSubProvider(const nsACString& aPackage,
|
||||
const nsACString& aProvider,
|
||||
nsCOMPtr<nsIRDFResource> &aSelectedProvider);
|
||||
|
||||
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);
|
||||
|
||||
NS_HIDDEN_(nsresult) ProcessNewChromeFile(nsILocalFile *aListFile);
|
||||
NS_HIDDEN_(nsresult) ProcessNewChromeBuffer(char *aBuffer, PRInt32 aLength);
|
||||
|
||||
PRBool GetProviderCount(const nsACString& aProviderType, nsIRDFDataSource* aDataSource);
|
||||
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);
|
||||
|
||||
protected:
|
||||
nsCString mProfileRoot;
|
||||
nsCString mInstallRoot;
|
||||
struct ProviderEntry
|
||||
{
|
||||
ProviderEntry(const nsACString& aProvider, nsIURI* aBase) :
|
||||
provider(aProvider),
|
||||
baseURI(aBase) { }
|
||||
|
||||
nsCOMPtr<nsIRDFCompositeDataSource> mChromeDataSource;
|
||||
nsCOMPtr<nsIRDFDataSource> mInstallDirChromeDataSource;
|
||||
nsCOMPtr<nsIRDFDataSource> mUIDataSource;
|
||||
nsCString provider;
|
||||
nsCOMPtr<nsIURI> baseURI;
|
||||
};
|
||||
|
||||
nsSupportsHashtable* mDataSourceTable;
|
||||
nsIRDFService* mRDFService;
|
||||
nsIRDFContainerUtils* mRDFContainerUtils;
|
||||
class nsProviderArray
|
||||
{
|
||||
public:
|
||||
nsProviderArray() :
|
||||
mArray(1) { }
|
||||
~nsProviderArray()
|
||||
{ Clear(); }
|
||||
|
||||
// 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
|
||||
};
|
||||
|
||||
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();
|
||||
|
||||
private:
|
||||
nsVoidArray mArray;
|
||||
};
|
||||
|
||||
struct PackageEntry : public PLDHashEntryHdr
|
||||
{
|
||||
PackageEntry(const nsACString& package);
|
||||
~PackageEntry() { }
|
||||
|
||||
// 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
|
||||
};
|
||||
|
||||
nsCString package;
|
||||
nsCOMPtr<nsIURI> baseURI;
|
||||
PRUint32 flags;
|
||||
nsProviderArray locales;
|
||||
nsProviderArray skins;
|
||||
};
|
||||
|
||||
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);
|
||||
|
||||
static const PLDHashTableOps kTableOps;
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
// 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). */
|
||||
|
@ -95,24 +87,6 @@ interface nsIXULChromeRegistry : nsIChromeRegistry
|
|||
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);
|
||||
};
|
||||
|
||||
%{ C++
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -51,7 +51,8 @@ const PREF_EM_EXTENSION_FORMAT = "extensions.%UUID%.";
|
|||
const PREF_EM_ITEM_UPDATE_ENABLED = "extensions.%UUID%.update.enabled";
|
||||
const PREF_EM_ITEM_UPDATE_URL = "extensions.%UUID%.update.url";
|
||||
const PREF_EM_DSS_ENABLED = "extensions.dss.enabled";
|
||||
|
||||
const PREF_DSS_SWITCHPENDING = "extensions.dss.switchPending";
|
||||
const PREF_DSS_SKIN_TO_SELECT = "extensions.lastSelectedSkin";
|
||||
const PREF_GENERAL_SKINS_SELECTEDSKIN = "general.skins.selectedSkin";
|
||||
|
||||
const DIR_EXTENSIONS = "extensions";
|
||||
|
@ -67,11 +68,11 @@ const DIR_CR_OVERLAYINFO = "overlayinfo";
|
|||
const FILE_CR_CHROMEDS = "chrome.rdf";
|
||||
const FILE_EXTENSIONS = "Extensions.rdf";
|
||||
const FILE_UNINSTALL_LOG = "Uninstall";
|
||||
const FILE_DEFAULTS = "defaults.ini";
|
||||
const FILE_COMPONENT_MANIFEST = "components.ini";
|
||||
const FILE_EXTENSION_MANIFEST = "extensions.ini";
|
||||
const FILE_AUTOREG = ".autoreg";
|
||||
const FILE_INSTALL_MANIFEST = "install.rdf";
|
||||
const FILE_CHROME_MANIFEST = "contents.rdf";
|
||||
const FILE_CHROMEREG_MANIFEST = "chrome.manifest";
|
||||
const FILE_WASINSAFEMODE = "Safe Mode";
|
||||
const FILE_INSTALLED_EXTENSIONS = "installed-extensions.txt"
|
||||
const FILE_INSTALLED_EXTENSIONS_PROCESSED = "installed-extensions-processed.txt"
|
||||
|
@ -246,11 +247,25 @@ function stripPropertyPrefix(aProperty, aPrefix)
|
|||
function getURLSpecFromFile(aFile)
|
||||
{
|
||||
var ioServ = Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
var fph = ioServ.getProtocolHandler("file").QueryInterface(Components.interfaces.nsIFileProtocolHandler);
|
||||
return fph.getURLSpecFromFile(aFile);
|
||||
}
|
||||
|
||||
function newURI(aSpec)
|
||||
{
|
||||
var ioServ = Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
return ioServ.newURI(aSpec, null, null);
|
||||
}
|
||||
|
||||
function getURLFromFile(aFile)
|
||||
{
|
||||
var ioServ = Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
return ioServ.newFileURI(aFile);
|
||||
}
|
||||
|
||||
function ensureExtensionsFiles(aIsProfile)
|
||||
{
|
||||
try {
|
||||
|
@ -749,15 +764,6 @@ nsInstallLogReader.prototype = {
|
|||
dump("*** nsInstallLogReader::_parseLine - failed to remove file " + e + "\n");
|
||||
}
|
||||
break;
|
||||
case this.TOKEN_REGISTER_CHROME:
|
||||
var isProfile = parts[1] == this.TOKEN_PROFILE;
|
||||
try {
|
||||
this._listener.onRegisterChrome(parts[3], lf, parts[2], isProfile);
|
||||
}
|
||||
catch (e) {
|
||||
dump("*** nsInstallLogReader::_parseLine - failed to deregister chrome\n");
|
||||
}
|
||||
break;
|
||||
case this.TOKEN_SKIN:
|
||||
var isProfile = parts[1] == this.TOKEN_PROFILE;
|
||||
try {
|
||||
|
@ -1029,6 +1035,14 @@ nsExtensionInstaller.prototype = {
|
|||
var chromeDir = getDir(this._extDirKey,
|
||||
[DIR_EXTENSIONS, this._extensionID, DIR_CHROME]);
|
||||
|
||||
var manifestFile = getDirNoCreate(this._extDirKey, [DIR_EXTENSIONS,
|
||||
this._extensionID,
|
||||
FILE_CHROMEREG_MANIFEST]);
|
||||
if (manifestFile.exists())
|
||||
manifestFile.remove(false);
|
||||
|
||||
var manifestURI = getURLFromFile(manifestFile);
|
||||
|
||||
var files = this._metadataDS.GetTargets(this._sourceResource, this._fileProperty, true);
|
||||
while (files.hasMoreElements()) {
|
||||
var file = files.getNext().QueryInterface(Components.interfaces.nsIRDFResource);
|
||||
|
@ -1041,111 +1055,32 @@ nsExtensionInstaller.prototype = {
|
|||
var items = this._metadataDS.GetTargets(file, providers[i], true);
|
||||
while (items.hasMoreElements()) {
|
||||
var item = items.getNext().QueryInterface(Components.interfaces.nsIRDFLiteral);
|
||||
this._registerChrome(chromeFile, providers[i], item.Value);
|
||||
this._registerChrome(chromeFile, item.Value, manifestURI);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_registerChrome: function nsExtensionInstaller__registerChrome (aFile, aChromeType, aPath)
|
||||
_registerChrome: function nsExtensionInstaller__registerChrome (aFile, aPath, aManifest)
|
||||
{
|
||||
var fileURL = getURLSpecFromFile(aFile);
|
||||
var fileURLSpec = getURLSpecFromFile(aFile);
|
||||
if (!aFile.isDirectory()) // .jar files
|
||||
fileURL = "jar:" + fileURL + "!/" + aPath;
|
||||
fileURLSpec = "jar:" + fileURLSpec + "!/" + aPath;
|
||||
else // flat chrome hierarchies
|
||||
fileURL = fileURL + aPath;
|
||||
|
||||
fileURLSpec = fileURLSpec + aPath;
|
||||
|
||||
var fileURI = newURI(fileURLSpec);
|
||||
|
||||
var cr = Components.classes["@mozilla.org/chrome/chrome-registry;1"]
|
||||
.getService(Components.interfaces.nsIXULChromeRegistry);
|
||||
var type;
|
||||
if (aChromeType.EqualsNode(this._provTypePackage)) {
|
||||
try {
|
||||
cr.installPackage(fileURL, this._isProfile);
|
||||
}
|
||||
catch (e) {
|
||||
throw new nsChromeRegistrationException(fileURL, this._isProfile, "installPackage");
|
||||
}
|
||||
type = this._writer.CHROME_TYPE_PACKAGE;
|
||||
}
|
||||
else if (aChromeType.EqualsNode(this._provTypeSkin)) {
|
||||
try {
|
||||
cr.installSkin(fileURL, this._isProfile, true); // Extension skins can execute scripts
|
||||
}
|
||||
catch (e) {
|
||||
throw new nsChromeRegistrationException(fileURL, this._isProfile, "installSkin");
|
||||
}
|
||||
type = this._writer.CHROME_TYPE_SKIN;
|
||||
}
|
||||
else if (aChromeType.EqualsNode(this._provTypeLocale)) {
|
||||
try {
|
||||
cr.installLocale(fileURL, this._isProfile);
|
||||
}
|
||||
catch (e) {
|
||||
throw new nsChromeRegistrationException(fileURL, this._isProfile, "installLocale");
|
||||
}
|
||||
type = this._writer.CHROME_TYPE_LOCALE;
|
||||
}
|
||||
var providerNames = this._getProviderNames(fileURL, type);
|
||||
for (var i = 0; i < providerNames.length; ++i) {
|
||||
this._writer.registerChrome(providerNames[i], type, this._isProfile);
|
||||
|
||||
// Make sure we enable overlays for this extension so that if it is disabled by
|
||||
// mismatch checking, installing a newer version (as opposed to enabling as a
|
||||
// result of a version compatibility update) makes the extension's overlaid UI
|
||||
// appear immediately.
|
||||
cr.setAllowOverlaysForPackage(providerNames[i], true);
|
||||
}
|
||||
},
|
||||
|
||||
_getProviderNames: function nsExtensionInstaller__getProviderNames (aBaseURL, aType)
|
||||
{
|
||||
if (aBaseURL.charAt(aBaseURL.length-1) != "/")
|
||||
aBaseURL += "/";
|
||||
var manifestURL = aBaseURL + "contents.rdf";
|
||||
|
||||
var providerNames = [];
|
||||
.getService(Components.interfaces.nsIToolkitChromeRegistry);
|
||||
|
||||
try {
|
||||
// Discover the list of provider names to register for the location
|
||||
// specified in the provider arc.
|
||||
//
|
||||
// The contents.rdf file will look like this:
|
||||
//
|
||||
// <RDF:Seq about="urn:mozilla:<type>:root">
|
||||
// <RDF:li resource="urn:mozilla:<type>:itemName1"/>
|
||||
// <RDF:li resource="urn:mozilla:<type>:itemName2"/>
|
||||
// ..
|
||||
// </RDF:Seq>
|
||||
//
|
||||
// We need to explicitly walk this list here, we don't need to do so
|
||||
// for nsIXULChromeRegistry's |installPackage| method since that does
|
||||
// this same thing itself.
|
||||
|
||||
var ds = gRDF.GetDataSourceBlocking(manifestURL);
|
||||
|
||||
var ctr = Components.classes["@mozilla.org/rdf/container;1"]
|
||||
.createInstance(Components.interfaces.nsIRDFContainer);
|
||||
ctr.Init(ds, gRDF.GetResource("urn:mozilla:" + aType + ":root"));
|
||||
|
||||
var items = ctr.GetElements();
|
||||
while (items.hasMoreElements()) {
|
||||
var item = items.getNext().QueryInterface(Components.interfaces.nsIRDFResource);
|
||||
|
||||
var nameArc = gRDF.GetResource(CHROME_NS("name"));
|
||||
var name;
|
||||
if (ds.hasArcOut(item, nameArc))
|
||||
name = stringData(ds.GetTarget(item, nameArc, true));
|
||||
else {
|
||||
var parts = item.Value.split(":");
|
||||
name = parts[parts.length-1];
|
||||
}
|
||||
providerNames.push(name);
|
||||
}
|
||||
cr.processContentsManifest(fileURI, aManifest, true, false);
|
||||
}
|
||||
catch (e) { }
|
||||
|
||||
return providerNames;
|
||||
}
|
||||
catch (e) {
|
||||
throw new nsChromeRegistrationException(fileURLSpec, this._isProfile, "processContentsManifest");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -1154,14 +1089,11 @@ nsExtensionInstaller.prototype = {
|
|||
//
|
||||
function nsExtensionUninstaller(aExtensionDS)
|
||||
{
|
||||
this._cr = Components.classes["@mozilla.org/chrome/chrome-registry;1"]
|
||||
.getService(Components.interfaces.nsIXULChromeRegistry);
|
||||
this._extensionDS = aExtensionDS;
|
||||
}
|
||||
|
||||
nsExtensionUninstaller.prototype = {
|
||||
_extensionDS : null,
|
||||
_cr : null,
|
||||
_isProfile : true,
|
||||
_extDirKey : "",
|
||||
_extensionsDir: null,
|
||||
|
@ -1215,36 +1147,7 @@ nsExtensionUninstaller.prototype = {
|
|||
!parent.equals(this._extensionsDir)) // stop at the extensions dir
|
||||
this._removeFile(parent);
|
||||
}
|
||||
},
|
||||
|
||||
// XXXben - maybe we should find a way to
|
||||
_packagesForExtension: [],
|
||||
|
||||
onRegisterChrome: function nsExtensionUninstaller_onRegisterChrome (aProviderName, aFile, aChromeType, aIsProfile)
|
||||
{
|
||||
switch (aChromeType) {
|
||||
case this._reader.CHROME_TYPE_PACKAGE:
|
||||
this._packagesForExtension.push(aProviderName);
|
||||
this._cr.uninstallPackage(aProviderName, aIsProfile)
|
||||
break;
|
||||
case this._reader.CHROME_TYPE_SKIN:
|
||||
for (var i = 0; i < this._packagesForExtension.length; ++i) {
|
||||
this._cr.deselectSkinForPackage(aProviderName,
|
||||
this._packagesForExtension[i],
|
||||
aIsProfile);
|
||||
}
|
||||
// this._cr.uninstallSkin(aProviderName, aIsProfile)
|
||||
break;
|
||||
case this._reader.CHROME_TYPE_LOCALE:
|
||||
for (var i = 0; i < this._packagesForExtension.length; ++i) {
|
||||
this._cr.deselectLocaleForPackage(aProviderName,
|
||||
this._packagesForExtension[i],
|
||||
aIsProfile);
|
||||
}
|
||||
// this._cr.uninstallLocale(aProviderName, aIsProfile)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -1253,14 +1156,11 @@ nsExtensionUninstaller.prototype = {
|
|||
//
|
||||
function nsExtensionEnabler(aExtensionDS)
|
||||
{
|
||||
this._cr = Components.classes["@mozilla.org/chrome/chrome-registry;1"]
|
||||
.getService(Components.interfaces.nsIXULChromeRegistry);
|
||||
this._extensionDS = aExtensionDS;
|
||||
}
|
||||
|
||||
nsExtensionEnabler.prototype = {
|
||||
_extensionDS : null,
|
||||
_cr : null,
|
||||
_enable : true,
|
||||
_isProfile : true,
|
||||
_extDirKey : "",
|
||||
|
@ -1282,12 +1182,6 @@ nsExtensionEnabler.prototype = {
|
|||
this._reader.read();
|
||||
},
|
||||
|
||||
onRegisterChrome: function nsExtensionEnabler_onRegisterChrome (aProviderName, aFile, aChromeType, aIsProfile)
|
||||
{
|
||||
if (aChromeType == this._reader.CHROME_TYPE_PACKAGE)
|
||||
this._cr.setAllowOverlaysForPackage(aProviderName, this._enable);
|
||||
},
|
||||
|
||||
onAddFile: function nsExtensionEnabler_onAddFile (aFile)
|
||||
{
|
||||
}
|
||||
|
@ -1433,11 +1327,19 @@ nsThemeInstaller.prototype = {
|
|||
this._writer.addFile(destinationFile.QueryInterface(Components.interfaces.nsILocalFile));
|
||||
this._writer.close();
|
||||
|
||||
var uriSpec = "jar:" + getURLSpecFromFile(destinationFile) + "!/";
|
||||
var uri = newURI(uriSpec);
|
||||
|
||||
var manifest = getDirNoCreate(extDirKey, [DIR_EXTENSIONS,
|
||||
this._themeID,
|
||||
FILE_CHROMEREG_MANIFEST]);
|
||||
var manifestURI = getURLFromFile(manifest);
|
||||
|
||||
// Use the Chrome Registry API to install the theme there
|
||||
var filePath = "jar:" + getURLSpecFromFile(destinationFile) + "!/";
|
||||
var cr = Components.classes["@mozilla.org/chrome/chrome-registry;1"]
|
||||
.getService(Components.interfaces.nsIXULChromeRegistry);
|
||||
cr.installSkin(filePath, aIsProfile, false);
|
||||
.getService(Components.interfaces.nsIToolkitChromeRegistry);
|
||||
|
||||
cr.processContentsManifest(uri, manifestURI, false, true);
|
||||
|
||||
// Insert the theme into the theme list.
|
||||
this._extensionDS.insertForthcomingItem(this._themeID, nsIUpdateItem.TYPE_THEME,
|
||||
|
@ -1465,8 +1367,6 @@ nsThemeInstaller.prototype = {
|
|||
//
|
||||
function nsThemeUninstaller(aExtensionDS)
|
||||
{
|
||||
this._cr = Components.classes["@mozilla.org/chrome/chrome-registry;1"]
|
||||
.getService(Components.interfaces.nsIXULChromeRegistry);
|
||||
}
|
||||
|
||||
nsThemeUninstaller.prototype = {
|
||||
|
@ -1512,7 +1412,6 @@ nsThemeUninstaller.prototype = {
|
|||
|
||||
onInstallSkin: function nsThemeUninstaller_onInstallSkin (aSkinName, aIsProfile)
|
||||
{
|
||||
this._cr.uninstallSkin(aSkinName, aIsProfile);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1547,6 +1446,23 @@ nsExtensionManager.prototype = {
|
|||
observe: function nsExtensionManager_observe (aSubject, aTopic, aData)
|
||||
{
|
||||
switch (aTopic) {
|
||||
case "app-startup":
|
||||
gOS.addObserver(this, "profile-after-change", false);
|
||||
break;
|
||||
|
||||
case "profile-after-change":
|
||||
gOS.removeObserver(this, "profile-after-change");
|
||||
try {
|
||||
if (gPref.getBoolPref(PREF_DSS_SWITCHPENDING)) {
|
||||
var toSelect = gPref.getCharPref(PREF_DSS_SKIN_TO_SELECT);
|
||||
gPref.setCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN, toSelect);
|
||||
gPref.clearUserPref(PREF_DSS_SWITCHPENDING);
|
||||
gPref.clearUserPref(PREF_DSS_SKIN_TO_SELECT);
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
|
||||
case "quit-application-requested":
|
||||
if (this._downloadCount > 0) {
|
||||
var result;
|
||||
|
@ -1605,7 +1521,7 @@ nsExtensionManager.prototype = {
|
|||
// Somehow the component list went away, and for that reason the new one
|
||||
// generated by this function is going to result in a different compreg.
|
||||
// We must force a restart.
|
||||
var componentList = getFile(KEY_PROFILEDIR, [FILE_COMPONENT_MANIFEST]);
|
||||
var componentList = getFile(KEY_PROFILEDIR, [FILE_EXTENSION_MANIFEST]);
|
||||
if (!componentList.exists())
|
||||
needsRestart = true;
|
||||
|
||||
|
@ -1632,7 +1548,8 @@ nsExtensionManager.prototype = {
|
|||
gPref.clearUserPref(PREF_EM_LAST_SELECTED_SKIN);
|
||||
gPref.setCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN, lastSelectedSkin);
|
||||
}
|
||||
catch (e) { }
|
||||
catch (e) {
|
||||
}
|
||||
|
||||
// Walk the list of extensions and re-activate overlays for packages
|
||||
// that aren't disabled.
|
||||
|
@ -1641,12 +1558,6 @@ nsExtensionManager.prototype = {
|
|||
this._finalizeEnableDisable(items[i], false);
|
||||
|
||||
wasInSafeModeFile.remove(false);
|
||||
|
||||
this._writeDefaults(true);
|
||||
try {
|
||||
this._writeDefaults(false);
|
||||
}
|
||||
catch (e) { }
|
||||
}
|
||||
catch (e) {
|
||||
dump("*** nsExtensionManager::start - failure, catching exception so finalize window can close = " + e + "\n");
|
||||
|
@ -1679,12 +1590,6 @@ nsExtensionManager.prototype = {
|
|||
this._finalizeEnableDisable(items[i].id, true);
|
||||
|
||||
this._ds.safeMode = true;
|
||||
|
||||
this._writeDefaults(true);
|
||||
try {
|
||||
this._writeDefaults(false);
|
||||
}
|
||||
catch (e) { }
|
||||
|
||||
needsRestart = true;
|
||||
|
||||
|
@ -1704,6 +1609,7 @@ nsExtensionManager.prototype = {
|
|||
win.close();
|
||||
|
||||
}
|
||||
|
||||
return needsRestart;
|
||||
},
|
||||
|
||||
|
@ -1767,8 +1673,7 @@ nsExtensionManager.prototype = {
|
|||
(new nsInstalledExtensionReader(this)).read();
|
||||
|
||||
// Write bin/components.ini
|
||||
var manifest = getFile(KEY_APPDIR, [FILE_COMPONENT_MANIFEST]);
|
||||
this._writeProfileFile(manifest, this._getComponentsDir, false);
|
||||
this._writeComponentManifest(false);
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -1812,54 +1717,6 @@ nsExtensionManager.prototype = {
|
|||
return rv == 1;
|
||||
},
|
||||
|
||||
// This function checks for and disables any "old-style" extensions
|
||||
// from Firefox 0.8 and earlier created using the "chrome:extension=true" flag.
|
||||
_disableObsoleteExtensions: function nsExtensionManager__disableObsoleteExtensions ()
|
||||
{
|
||||
if (!gPref.prefHasUserValue(PREF_EM_DISABLEDOBSOLETE) || !gPref.getBoolPref(PREF_EM_DISABLEDOBSOLETE)) {
|
||||
var win = this._showProgressWindow();
|
||||
try {
|
||||
var cr = Components.classes["@mozilla.org/chrome/chrome-registry;1"]
|
||||
.getService(Components.interfaces.nsIXULChromeRegistry);
|
||||
var crDS = gRDF.GetDataSource("rdf:chrome");
|
||||
var disabled = false;
|
||||
var sources = crDS.GetSources(gRDF.GetResource(CHROME_NS("extension")), gRDF.GetLiteral("true"), true);
|
||||
while (sources.hasMoreElements()) {
|
||||
disabled = true;
|
||||
|
||||
var source = sources.getNext().QueryInterface(Components.interfaces.nsIRDFResource);
|
||||
var name = crDS.GetTarget(source, gRDF.GetResource(CHROME_NS("name")), true);
|
||||
if (name) {
|
||||
name = name.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
|
||||
cr.setAllowOverlaysForPackage(name, false);
|
||||
}
|
||||
}
|
||||
|
||||
// Re-select the default theme to prevent any incompatibilities with old-style
|
||||
// themes.
|
||||
cr.selectSkin(KEY_DEFAULT_THEME, true);
|
||||
}
|
||||
catch (e) {
|
||||
dump("*** nsExtensionManager::_disableObsoleteExtensions - failure, catching exception so finalize window can close\n");
|
||||
}
|
||||
win.close();
|
||||
|
||||
if (disabled) {
|
||||
const nsIPromptService = Components.interfaces.nsIPromptService;
|
||||
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
|
||||
.getService(nsIPromptService);
|
||||
var sbs = Components.classes["@mozilla.org/intl/stringbundle;1"]
|
||||
.getService(Components.interfaces.nsIStringBundleService);
|
||||
var bundle = sbs.createBundle("chrome://mozapps/locale/extensions/extensions.properties");
|
||||
var title = bundle.GetStringFromName("disabledObsoleteTitle");
|
||||
var message = bundle.GetStringFromName("disabledObsoleteMessage");
|
||||
ps.alert(null, title, message);
|
||||
}
|
||||
|
||||
gPref.setBoolPref(PREF_EM_DISABLEDOBSOLETE, true);
|
||||
}
|
||||
},
|
||||
|
||||
_checkForGlobalInstalls: function nsExtensionManager__checkForGlobalInstalls (aPath, aItemType)
|
||||
{
|
||||
#ifdef XP_UNIX
|
||||
|
@ -1985,35 +1842,6 @@ nsExtensionManager.prototype = {
|
|||
"", "chrome,centerscreen,dialog", null);
|
||||
},
|
||||
|
||||
_loadDefaults: function nsExtensionManager__loadDefaults ()
|
||||
{
|
||||
// Load default preferences files for all extensions
|
||||
var defaultsManifest = getFile(KEY_PROFILEDIR,
|
||||
[DIR_EXTENSIONS, FILE_DEFAULTS]);
|
||||
if (defaultsManifest.exists()) {
|
||||
var fis = Components.classes["@mozilla.org/network/file-input-stream;1"]
|
||||
.createInstance(Components.interfaces.nsIFileInputStream);
|
||||
fis.init(defaultsManifest, -1, -1, false);
|
||||
var lis = fis.QueryInterface(Components.interfaces.nsILineInputStream);
|
||||
var line = { value: "" };
|
||||
var more = false;
|
||||
do {
|
||||
more = lis.readLine(line);
|
||||
var lf = Components.classes["@mozilla.org/file/local;1"]
|
||||
.createInstance(Components.interfaces.nsILocalFile);
|
||||
var path = line.value;
|
||||
if (path) {
|
||||
lf.initWithPath(path);
|
||||
|
||||
if (lf.exists())
|
||||
gPref.readUserPrefs(lf);
|
||||
}
|
||||
}
|
||||
while (more);
|
||||
fis.close();
|
||||
}
|
||||
},
|
||||
|
||||
ensurePreConfiguredItem: function nsExtensionManager_ensurePreConfiguredItem (aItemID, aItemType, aManifest)
|
||||
{
|
||||
this._ds.insertForthcomingItem(aItemID, aItemType, false);
|
||||
|
@ -2025,8 +1853,6 @@ nsExtensionManager.prototype = {
|
|||
{
|
||||
var needsRestart = false;
|
||||
|
||||
this._disableObsoleteExtensions();
|
||||
|
||||
// Check to see if the version of the application that is being started
|
||||
// now is the same one that was started last time.
|
||||
var currAppVersion = gPref.getCharPref(PREF_EM_APP_EXTENSIONS_VERSION);
|
||||
|
@ -2067,7 +1893,7 @@ nsExtensionManager.prototype = {
|
|||
// Somehow the component list went away, and for that reason the new one
|
||||
// generated by this function is going to result in a different compreg.
|
||||
// We must force a restart.
|
||||
var componentList = getFile(KEY_PROFILEDIR, [FILE_COMPONENT_MANIFEST]);
|
||||
var componentList = getFile(KEY_PROFILEDIR, [FILE_EXTENSION_MANIFEST]);
|
||||
if (!componentList.exists())
|
||||
needsRestart = true;
|
||||
|
||||
|
@ -2101,17 +1927,40 @@ nsExtensionManager.prototype = {
|
|||
// for people with write access to bin dir (i.e. uninstall, disable,
|
||||
// enable)
|
||||
this._writeComponentManifest(false);
|
||||
this._writeDefaults(false);
|
||||
}
|
||||
catch (e) {
|
||||
dump("*** ExtensionManager:_updateManifests: no access privileges to application directory, skipping.\n");
|
||||
};
|
||||
this._writeComponentManifest(true);
|
||||
this._writeDefaults(true);
|
||||
},
|
||||
|
||||
_getActiveItems: function nsExtensionManager__getActiveItems (aExtensions, aIsProfile)
|
||||
{
|
||||
var validExtensions = [];
|
||||
for (var i = 0; i < aExtensions.length; ++i) {
|
||||
var extension = aExtensions[i];
|
||||
|
||||
// An extension entry is valid only if it is not disabled, not about to
|
||||
// be disabled, and not about to be uninstalled.
|
||||
var toBeDisabled = this._ds.getItemProperty(extension.id, "toBeDisabled");
|
||||
var toBeUninstalled = this._ds.getItemProperty(extension.id, "toBeUninstalled");
|
||||
var toBeInstalled = this._ds.getItemProperty(extension.id, "toBeInstalled");
|
||||
var disabled = this._ds.getItemProperty(extension.id, "disabled");
|
||||
if (toBeDisabled == "true" || toBeUninstalled == "true" ||
|
||||
disabled == "true" || toBeInstalled == "true")
|
||||
continue;
|
||||
|
||||
var isProfile = this._ds.isProfileItem(extension.id);
|
||||
var sourceDir = getDirNoCreate(getDirKey(aIsProfile), [DIR_EXTENSIONS, extension.id]);
|
||||
if ((aIsProfile == isProfile))
|
||||
validExtensions.push({ sourceDir: sourceDir, isProfile: isProfile });
|
||||
}
|
||||
|
||||
return validExtensions;
|
||||
},
|
||||
|
||||
// XXXben write to temporary file then move to final when done.
|
||||
_writeProfileFile: function nsExtensionManager__writeProfileFile (aFile, aGetDirFunc, aIsProfile)
|
||||
_writeProfileFile: function nsExtensionManager__writeProfileFile (aFile, aIsProfile)
|
||||
{
|
||||
// When an operation is performed that requires a component re-registration
|
||||
// (extension enabled/disabled, installed, uninstalled), we must write the
|
||||
|
@ -2122,6 +1971,15 @@ nsExtensionManager.prototype = {
|
|||
// about all valid items to the file.
|
||||
this._ensureDS();
|
||||
|
||||
var validExtensions =
|
||||
this._getActiveItems(this.getItemList(null, nsIUpdateItem.TYPE_EXTENSION, { }),
|
||||
aIsProfile);
|
||||
var validThemes =
|
||||
this._getActiveItems(this.getItemList(null, nsIUpdateItem.TYPE_THEME, { }),
|
||||
aIsProfile);
|
||||
|
||||
var relativeDir = getDir(aIsProfile ? KEY_PROFILEDIR : KEY_APPDIR, []);
|
||||
|
||||
var fos = Components.classes["@mozilla.org/network/file-output-stream;1"]
|
||||
.createInstance(Components.interfaces.nsIFileOutputStream);
|
||||
const MODE_WRONLY = 0x02;
|
||||
|
@ -2129,40 +1987,32 @@ nsExtensionManager.prototype = {
|
|||
const MODE_TRUNCATE = 0x20;
|
||||
fos.init(aFile, MODE_WRONLY | MODE_CREATE | MODE_TRUNCATE, 0644, 0);
|
||||
|
||||
var extensions = this.getItemList(null, nsIUpdateItem.TYPE_EXTENSION, { });
|
||||
var validExtensions = [];
|
||||
for (var i = 0; i < extensions.length; ++i) {
|
||||
var extension = extensions[i];
|
||||
|
||||
// An extension entry is valid only if it is not disabled, not about to
|
||||
// be disabled, and not about to be uninstalled.
|
||||
var toBeDisabled = this._ds.getItemProperty(extension.id, "toBeDisabled");
|
||||
var toBeUninstalled = this._ds.getItemProperty(extension.id, "toBeUninstalled");
|
||||
var toBeInstalled = this._ds.getItemProperty(extension.id, "toBeInstalled");
|
||||
var disabled = this._ds.getItemProperty(extension.id, "disabled");
|
||||
if (toBeDisabled == "true" || toBeUninstalled == "true" ||
|
||||
disabled == "true" || toBeInstalled == "true")
|
||||
continue;
|
||||
|
||||
var isProfile = this._ds.isProfileItem(extension.id);
|
||||
var sourceDir = aGetDirFunc(isProfile, extension.id);
|
||||
if (sourceDir.exists() && (aIsProfile == isProfile))
|
||||
validExtensions.push({ sourceDir: sourceDir, isProfile: isProfile });
|
||||
}
|
||||
|
||||
var lines = ["[Extra Files]\r\n",
|
||||
var lines = ["[ExtensionDirs]\r\n",
|
||||
"Count=" + validExtensions.length + "\r\n"];
|
||||
for (i = 0; i < lines.length; ++i)
|
||||
fos.write(lines[i], lines[i].length);
|
||||
|
||||
for (i = 0; i < validExtensions.length; ++i) {
|
||||
var e = validExtensions[i];
|
||||
var relativeDir = getDir(e.isProfile ? KEY_PROFILEDIR : KEY_APPDIR, []);
|
||||
var lf = e.sourceDir.QueryInterface(Components.interfaces.nsILocalFile);
|
||||
var relDesc = lf.getRelativeDescriptor(relativeDir);
|
||||
var line = "File" + i + "=" + relDesc + "\r\n";
|
||||
var line = "Extension" + i + "=" + relDesc + "\r\n";
|
||||
fos.write(line, line.length);
|
||||
}
|
||||
|
||||
var lines = ["[ThemeDirs]\r\n",
|
||||
"Count=" + validThemes.length + "\r\n"];
|
||||
for (i = 0; i < lines.length; ++i)
|
||||
fos.write(lines[i], lines[i].length);
|
||||
|
||||
for (i = 0; i < validThemes.length; ++i) {
|
||||
var e = validThemes[i];
|
||||
var lf = e.sourceDir.QueryInterface(Components.interfaces.nsILocalFile);
|
||||
var relDesc = lf.getRelativeDescriptor(relativeDir);
|
||||
var line = "Extension" + i + "=" + relDesc + "\r\n";
|
||||
fos.write(line, line.length);
|
||||
}
|
||||
|
||||
fos.close();
|
||||
},
|
||||
|
||||
|
@ -2181,9 +2031,9 @@ nsExtensionManager.prototype = {
|
|||
|
||||
_writeComponentManifest: function nsExtensionManager__writeComponentManifest (aIsProfile)
|
||||
{
|
||||
var manifest = aIsProfile ? getFile(KEY_PROFILEDIR, [FILE_COMPONENT_MANIFEST]) :
|
||||
getFile(KEY_APPDIR, [FILE_COMPONENT_MANIFEST]);
|
||||
this._writeProfileFile(manifest, this._getComponentsDir, aIsProfile);
|
||||
var manifest = getFile(aIsProfile ? KEY_PROFILEDIR : KEY_APPDIR,
|
||||
[FILE_EXTENSION_MANIFEST]);
|
||||
this._writeProfileFile(manifest, aIsProfile);
|
||||
|
||||
// Now refresh the compatibility manifest.
|
||||
this._setComponentsListChanged(true);
|
||||
|
@ -2205,13 +2055,6 @@ nsExtensionManager.prototype = {
|
|||
catch (e) {}
|
||||
},
|
||||
|
||||
_writeDefaults: function nsExtensionManager__writeDefaults (aIsProfile)
|
||||
{
|
||||
var manifest = aIsProfile ? getFile(KEY_PROFILEDIR, [FILE_DEFAULTS]) :
|
||||
getFile(KEY_APPDIR, [FILE_DEFAULTS]);
|
||||
this._writeProfileFile(manifest, this._getPreferencesDir, aIsProfile);
|
||||
},
|
||||
|
||||
_cleanDirs: function nsExtensionManager__cleanDirs ()
|
||||
{
|
||||
var keys = [KEY_PROFILEDIR, KEY_APPDIR];
|
||||
|
@ -2541,9 +2384,6 @@ nsExtensionManager.prototype = {
|
|||
|
||||
// Update the Components Manifest
|
||||
this._writeComponentManifest(isProfile);
|
||||
|
||||
// Update the Defaults Manifest
|
||||
this._writeDefaults(isProfile);
|
||||
},
|
||||
|
||||
_finalizeEnableDisable: function nsExtensionManager__finalizeEnableDisable (aExtensionID, aDisable)
|
||||
|
@ -2591,9 +2431,6 @@ nsExtensionManager.prototype = {
|
|||
|
||||
// Update the Components Manifest
|
||||
this._writeComponentManifest(isProfile);
|
||||
|
||||
// Update the Defaults Manifest
|
||||
this._writeDefaults(isProfile);
|
||||
}
|
||||
else {
|
||||
// Bad download entry - uri is url, e.g. "http://www.foo.com/test.xpi"
|
||||
|
@ -2610,9 +2447,6 @@ nsExtensionManager.prototype = {
|
|||
|
||||
// Update the Components Manifest
|
||||
this._writeComponentManifest(isProfile);
|
||||
|
||||
// Update the Defaults Manifest
|
||||
this._writeDefaults(isProfile);
|
||||
},
|
||||
|
||||
disableExtension: function nsExtensionManager_disableExtension (aExtensionID)
|
||||
|
@ -2623,9 +2457,6 @@ nsExtensionManager.prototype = {
|
|||
|
||||
// Update the Components Manifest
|
||||
this._writeComponentManifest(isProfile);
|
||||
|
||||
// Update the Defaults Manifest
|
||||
this._writeDefaults(isProfile);
|
||||
},
|
||||
|
||||
enableTheme: function nsExtensionsDataSource_enableTheme (aThemeID)
|
||||
|
@ -2666,14 +2497,16 @@ nsExtensionManager.prototype = {
|
|||
var isProfile = aFlags & nsIExtensionManager.FLAG_INSTALL_PROFILE;
|
||||
var installer = new nsThemeInstaller(this._ds, this);
|
||||
installer.install(aJARFile, isProfile);
|
||||
// XPInstall selects the theme, if necessary.
|
||||
this._writeComponentManifest(isProfile);
|
||||
},
|
||||
|
||||
|
||||
uninstallTheme: function nsExtensionManager_uninstallTheme (aThemeID)
|
||||
{
|
||||
if (!this._ds.isDownloadItem(aThemeID)) {
|
||||
this._ensureDS();
|
||||
var isProfile = this._ds.isProfileItem(aThemeID);
|
||||
this._ds.uninstallTheme(aThemeID);
|
||||
this._writeComponentManifest(isProfile);
|
||||
}
|
||||
else {
|
||||
// Bad download entry - uri is url, e.g. "http://www.foo.com/test.jar"
|
||||
|
@ -4498,10 +4331,6 @@ var gModule = {
|
|||
|
||||
registerSelf: function (aComponentManager, aFileSpec, aLocation, aType)
|
||||
{
|
||||
if (this._firstTime) {
|
||||
this._firstTime = false;
|
||||
throw Components.results.NS_ERROR_FACTORY_REGISTER_AGAIN;
|
||||
}
|
||||
aComponentManager = aComponentManager.QueryInterface(Components.interfaces.nsIComponentRegistrar);
|
||||
|
||||
for (var key in this._objects) {
|
||||
|
@ -4510,14 +4339,12 @@ var gModule = {
|
|||
aFileSpec, aLocation, aType);
|
||||
}
|
||||
|
||||
/*
|
||||
// Make the Extension Manager a startup observer
|
||||
var categoryManager = Components.classes["@mozilla.org/categorymanager;1"]
|
||||
.getService(Components.interfaces.nsICategoryManager);
|
||||
categoryManager.addCategoryEntry("app-startup", this._objects.manager.className,
|
||||
"service," + this._objects.manager.contractID,
|
||||
true, true, null);
|
||||
*/
|
||||
},
|
||||
|
||||
getClassObject: function (aComponentManager, aCID, aIID)
|
||||
|
|
|
@ -50,6 +50,8 @@ REQUIRES = \
|
|||
appcomps \
|
||||
toolkitcomps \
|
||||
appshell \
|
||||
appstartup \
|
||||
chrome \
|
||||
content \
|
||||
docshell \
|
||||
dom \
|
||||
|
|
|
@ -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)
|
||||
|
|
Загрузка…
Ссылка в новой задаче