Bug 568691 - Register extension components/chrome again. This doesn't remove the EM restart yet, because there's some weirdness about reading default prefs from extensions that needs to be solved first.

This commit is contained in:
Benjamin Smedberg 2010-06-23 12:18:32 -04:00
parent 360af69e24
commit 87b751cfc8
3 changed files with 34 additions and 130 deletions

View File

@ -59,13 +59,3 @@ interface nsIToolkitChromeRegistry : nsIXULChromeRegistry
*/
nsIUTF8StringEnumerator getLocalesForPackage(in AUTF8String aPackage);
};
/**
* 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"
%}

View File

@ -103,11 +103,20 @@
#define PREF_OVERRIDE_DIRNAME "preferences"
static already_AddRefed<nsILocalFile>
CloneAndAppend(nsIFile* aFile, const char* name)
{
nsCOMPtr<nsIFile> file;
aFile->Clone(getter_AddRefs(file));
nsCOMPtr<nsILocalFile> lfile = do_QueryInterface(file);
lfile->AppendNative(nsDependentCString(name));
return lfile.forget();
}
nsXREDirProvider* gDirServiceProvider = nsnull;
nsXREDirProvider::nsXREDirProvider() :
mProfileNotified(PR_FALSE),
mExtensionsLoaded(PR_FALSE)
mProfileNotified(PR_FALSE)
{
gDirServiceProvider = this;
}
@ -139,6 +148,7 @@ nsXREDirProvider::Initialize(nsIFile *aXULAppDir,
}
}
LoadAppBundleDirs();
return NS_OK;
}
@ -407,37 +417,6 @@ nsXREDirProvider::GetFile(const char* aProperty, PRBool* aPersistent,
return NS_OK;
}
static void
LoadPlatformDirectory(nsIFile* aBundleDirectory,
nsCOMArray<nsIFile> &aDirectories)
{
nsCOMPtr<nsIFile> platformDir;
nsresult rv = aBundleDirectory->Clone(getter_AddRefs(platformDir));
if (NS_FAILED(rv))
return;
platformDir->AppendNative(NS_LITERAL_CSTRING("platform"));
#ifdef TARGET_OS_ABI
nsCOMPtr<nsIFile> platformABIDir;
rv = platformDir->Clone(getter_AddRefs(platformABIDir));
if (NS_FAILED(rv))
return;
#endif
platformDir->AppendNative(NS_LITERAL_CSTRING(OS_TARGET));
PRBool exists;
if (NS_SUCCEEDED(platformDir->Exists(&exists)) && exists)
aDirectories.AppendObject(platformDir);
#ifdef TARGET_OS_ABI
platformABIDir->AppendNative(NS_LITERAL_CSTRING(TARGET_OS_ABI));
if (NS_SUCCEEDED(platformABIDir->Exists(&exists)) && exists)
aDirectories.AppendObject(platformABIDir);
#endif
}
static void
LoadAppDirIntoArray(nsIFile* aXULAppDir,
const char *const *aAppendList,
@ -523,7 +502,8 @@ nsXREDirProvider::GetFiles(const char* aProperty, nsISimpleEnumerator** aResult)
static void
LoadExtensionDirectories(nsINIParser &parser,
const char *aSection,
nsCOMArray<nsIFile> &aDirectories)
nsCOMArray<nsIFile> &aDirectories,
NSLocationType aType)
{
nsresult rv;
PRInt32 i = 0;
@ -545,24 +525,17 @@ LoadExtensionDirectories(nsINIParser &parser,
continue;
aDirectories.AppendObject(dir);
LoadPlatformDirectory(dir, aDirectories);
nsCOMPtr<nsILocalFile> manifest =
CloneAndAppend(dir, "chrome.manifest");
XRE_AddComponentLocation(aType, manifest);
}
while (PR_TRUE);
}
void
nsXREDirProvider::LoadBundleDirectories()
nsXREDirProvider::LoadExtensionBundleDirectories()
{
if (mExtensionsLoaded)
return;
mExtensionsLoaded = PR_TRUE;
// first load distribution/bundles
LoadPlatformDirectory(mXULAppDir, mAppBundleDirectories);
LoadAppBundleDirs();
if (mProfileDir && !gSafeMode) {
nsCOMPtr<nsIFile> extensionsINI;
mProfileDir->Clone(getter_AddRefs(extensionsINI));
@ -581,8 +554,10 @@ nsXREDirProvider::LoadBundleDirectories()
if (NS_FAILED(rv))
return;
LoadExtensionDirectories(parser, "ExtensionDirs", mExtensionDirectories);
LoadExtensionDirectories(parser, "ThemeDirs", mThemeDirectories);
LoadExtensionDirectories(parser, "ExtensionDirs", mExtensionDirectories,
NS_COMPONENT_LOCATION);
LoadExtensionDirectories(parser, "ThemeDirs", mThemeDirectories,
NS_SKIN_LOCATION);
}
}
@ -597,10 +572,6 @@ nsXREDirProvider::LoadAppBundleDirs()
dir->AppendNative(NS_LITERAL_CSTRING("distribution"));
dir->AppendNative(NS_LITERAL_CSTRING("bundles"));
PRBool exists;
if (NS_FAILED(dir->Exists(&exists)) || !exists)
return;
nsCOMPtr<nsISimpleEnumerator> e;
rv = dir->GetDirectoryEntries(getter_AddRefs(e));
if (NS_FAILED(rv))
@ -613,7 +584,10 @@ nsXREDirProvider::LoadAppBundleDirs()
nsCOMPtr<nsIFile> subdir;
while (NS_SUCCEEDED(files->GetNextFile(getter_AddRefs(subdir))) && subdir) {
mAppBundleDirectories.AppendObject(subdir);
LoadPlatformDirectory(subdir, mAppBundleDirectories);
nsCOMPtr<nsILocalFile> manifest =
CloneAndAppend(subdir, "chrome.manifest");
XRE_AddComponentLocation(NS_COMPONENT_LOCATION, manifest);
}
}
@ -646,7 +620,6 @@ nsXREDirProvider::GetFilesInternal(const char* aProperty,
static const char *const kAppendNothing[] = { nsnull };
LoadBundleDirectories();
LoadDirsIntoArray(mAppBundleDirectories,
kAppendNothing, directories);
LoadDirsIntoArray(mExtensionDirectories,
@ -654,25 +627,9 @@ nsXREDirProvider::GetFilesInternal(const char* aProperty,
rv = NS_NewArrayEnumerator(aResult, directories);
}
#if 0
else if (!strcmp(aProperty, NS_XPCOM_COMPONENT_DIR_LIST)) {
static const char *const kAppendCompDir[] = { "components", nsnull };
nsCOMArray<nsIFile> directories;
LoadBundleDirectories();
LoadDirsIntoArray(mAppBundleDirectories,
kAppendCompDir, directories);
LoadDirsIntoArray(mExtensionDirectories,
kAppendCompDir, directories);
rv = NS_NewArrayEnumerator(aResult, directories);
}
#endif
else if (!strcmp(aProperty, NS_APP_PREFS_DEFAULTS_DIR_LIST)) {
nsCOMArray<nsIFile> directories;
LoadBundleDirectories();
LoadAppDirIntoArray(mXULAppDir, kAppendPrefDir, directories);
LoadDirsIntoArray(mAppBundleDirectories,
kAppendPrefDir, directories);
@ -682,7 +639,6 @@ nsXREDirProvider::GetFilesInternal(const char* aProperty,
else if (!strcmp(aProperty, NS_EXT_PREFS_DEFAULTS_DIR_LIST)) {
nsCOMArray<nsIFile> directories;
LoadBundleDirectories();
LoadDirsIntoArray(mExtensionDirectories,
kAppendPrefDir, directories);
@ -698,56 +654,12 @@ nsXREDirProvider::GetFilesInternal(const char* aProperty,
rv = NS_NewArrayEnumerator(aResult, directories);
}
else if (!strcmp(aProperty, NS_CHROME_MANIFESTS_FILE_LIST)) {
nsCOMArray<nsIFile> manifests;
#ifdef MOZ_OMNIJAR
if (!mozilla::OmnijarPath()) {
#endif
nsCOMPtr<nsIFile> manifest;
mGREDir->Clone(getter_AddRefs(manifest));
manifest->AppendNative(NS_LITERAL_CSTRING("chrome"));
manifests.AppendObject(manifest);
#ifdef MOZ_OMNIJAR
}
#endif
PRBool eq;
if (NS_SUCCEEDED(mXULAppDir->Equals(mGREDir, &eq)) && !eq) {
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);
}
LoadBundleDirectories();
LoadDirsIntoArray(mAppBundleDirectories,
kAppendChromeManifests,
manifests);
LoadDirsIntoArray(mExtensionDirectories,
kAppendChromeManifests,
manifests);
rv = NS_NewArrayEnumerator(aResult, manifests);
}
else if (!strcmp(aProperty, NS_SKIN_MANIFESTS_FILE_LIST)) {
nsCOMArray<nsIFile> manifests;
LoadBundleDirectories();
LoadDirsIntoArray(mThemeDirectories,
kAppendChromeManifests, manifests);
rv = NS_NewArrayEnumerator(aResult, manifests);
}
else if (!strcmp(aProperty, NS_APP_CHROME_DIR_LIST)) {
// NS_APP_CHROME_DIR_LIST is only used to get default (native) icons
// for OS window decoration.
static const char *const kAppendChromeDir[] = { "chrome", nsnull };
nsCOMArray<nsIFile> directories;
LoadBundleDirectories();
LoadAppDirIntoArray(mXULAppDir,
kAppendChromeDir,
directories);
@ -766,7 +678,6 @@ nsXREDirProvider::GetFilesInternal(const char* aProperty,
// The root dirserviceprovider does quite a bit for us: we're mainly
// interested in xulapp and extension-provided plugins.
LoadBundleDirectories();
LoadDirsIntoArray(mAppBundleDirectories,
kAppendPlugins,
directories);
@ -816,6 +727,9 @@ nsXREDirProvider::DoStartup()
// Init the Extension Manager
nsCOMPtr<nsIObserver> em = do_GetService("@mozilla.org/addons/integration;1");
em->Observe(nsnull, "addons-startup", nsnull);
LoadExtensionBundleDirectories();
obsSvc->NotifyObservers(nsnull, "profile-after-change", kStartup);
// Any component that has registered for the profile-after-change category

View File

@ -134,9 +134,10 @@ protected:
// delimiters.
static inline nsresult AppendProfileString(nsIFile* aFile, const char* aPath);
// Calculate all bundle directories, including distribution bundles,
// extensions, and themes
void LoadBundleDirectories();
// Calculate and register extension and theme bundle directories.
void LoadExtensionBundleDirectories();
// Calculate and register app-bundled extension directories.
void LoadAppBundleDirs();
void Append(nsIFile* aDirectory);
@ -147,7 +148,6 @@ protected:
nsCOMPtr<nsIFile> mProfileDir;
nsCOMPtr<nsIFile> mProfileLocalDir;
PRPackedBool mProfileNotified;
PRPackedBool mExtensionsLoaded;
nsCOMArray<nsIFile> mAppBundleDirectories;
nsCOMArray<nsIFile> mExtensionDirectories;
nsCOMArray<nsIFile> mThemeDirectories;