Bug 568691 - Normalize relative paths on Windows to use back slashes, and add a manifest processing directive for XPT files so that extension chrome.manifest can point to them and we don't have to troll around in extension components/ directories.
--- a/xpcom/components/ManifestParser.cpp
+++ b/xpcom/components/ManifestParser.cpp
@@ -85,16 +85,18 @@ struct ManifestDirective
int lineno, char *const *argv,
bool platform, bool contentaccessible);
bool isContract;
};
static const ManifestDirective kParsingTable[] = {
{ "binary-component", 1, true, false, false,
&nsComponentManagerImpl::ManifestBinaryComponent, NULL },
+ { "xpt", 1, true, false, false,
+ &nsComponentManagerImpl::ManifestXPT, NULL },
{ "component", 2, true, false, false,
&nsComponentManagerImpl::ManifestComponent, NULL },
{ "contract", 2, true, false, false,
&nsComponentManagerImpl::ManifestContract, NULL, true},
{ "category", 3, true, false, false,
&nsComponentManagerImpl::ManifestCategory, NULL },
{ "content", 2, true, true, true,
NULL, &nsChromeRegistry::ManifestContent },
--- a/xpcom/components/nsComponentManager.cpp
+++ b/xpcom/components/nsComponentManager.cpp
@@ -612,21 +612,37 @@ nsComponentManagerImpl::RegisterManifest
return;
totalRead += read;
}
data[fileInfo.size] = '\0';
ParseManifest(aType, aFile, data, aChromeOnly);
}
+#if defined(XP_WIN) || defined(XP_OS2)
+#define TRANSLATE_SLASHES
+static void
+TranslateSlashes(char* path)
+{
+ for (; *path; ++path) {
+ if ('/' == *path)
+ *path = '\\';
+ }
+}
+#endif
+
void
nsComponentManagerImpl::ManifestBinaryComponent(ManifestProcessingContext& cx, int lineno, char *const * argv)
{
char* file = argv[0];
+#ifdef TRANSLATE_SLASHES
+ TranslateSlashes(file);
+#endif
+
nsCOMPtr<nsIFile> cfile;
cx.mFile->GetParent(getter_AddRefs(cfile));
nsCOMPtr<nsILocalFile> clfile = do_QueryInterface(cfile);
nsresult rv = clfile->AppendRelativeNativePath(nsDependentCString(file));
if (NS_FAILED(rv)) {
NS_WARNING("Couldn't append relative path?");
return;
@@ -636,21 +652,48 @@ nsComponentManagerImpl::ManifestBinaryCo
if (!m) {
// XXX report load error
return;
}
RegisterModule(m, clfile);
}
void
+nsComponentManagerImpl::ManifestXPT(ManifestProcessingContext& cx, int lineno, char *const * argv)
+{
+ char* file = argv[0];
+
+#ifdef TRANSLATE_SLASHES
+ TranslateSlashes(file);
+#endif
+
+ nsCOMPtr<nsIFile> cfile;
+ cx.mFile->GetParent(getter_AddRefs(cfile));
+ nsCOMPtr<nsILocalFile> clfile = do_QueryInterface(cfile);
+
+ nsresult rv = clfile->AppendRelativeNativePath(nsDependentCString(file));
+ if (NS_FAILED(rv)) {
+ NS_WARNING("Couldn't append relative path?");
+ return;
+ }
+
+ xptiInterfaceInfoManager::GetSingleton()
+ ->RegisterFile(clfile, xptiInterfaceInfoManager::XPT);
+}
+
+void
nsComponentManagerImpl::ManifestComponent(ManifestProcessingContext& cx, int lineno, char *const * argv)
{
char* id = argv[0];
char* file = argv[1];
+#ifdef TRANSLATE_SLASHES
+ TranslateSlashes(file);
+#endif
+
nsID cid;
if (!cid.Parse(id)) {
// XXX report parse error
return;
}
nsAutoMonitor mon(mMon);
nsFactoryEntry* f = mFactories.Get(cid);
--- a/xpcom/components/nsComponentManager.h
+++ b/xpcom/components/nsComponentManager.h
@@ -249,16 +249,17 @@ public:
{ }
~ManifestProcessingContext() { }
NSLocationType mType;
nsCOMPtr<nsILocalFile> mFile;
};
void ManifestBinaryComponent(ManifestProcessingContext& cx, int lineno, char *const * argv);
+ void ManifestXPT(ManifestProcessingContext& cx, int lineno, char *const * argv);
void ManifestComponent(ManifestProcessingContext& cx, int lineno, char *const * argv);
void ManifestContract(ManifestProcessingContext& cx, int lineno, char* const * argv);
void ManifestCategory(ManifestProcessingContext& cx, int lineno, char* const * argv);
void RereadChromeManifests();
// Shutdown
enum {