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.
authorBenjamin Smedberg <benjamin@smedbergs.us>
Fri, 25 Jun 2010 13:55:46 -0400
changeset 47057 02c36c64f2741e48b1eea0a123eacb69f9527be3
parent 47056 8df96f96cf67a9bbaeae6ec76d107acbcd8dab94
child 47058 d8274b38a72a5e6d6ca2be69e72615ffeb9f05ab
push idunknown
push userunknown
push dateunknown
bugs568691
milestone1.9.3a6pre
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.
xpcom/components/ManifestParser.cpp
xpcom/components/nsComponentManager.cpp
xpcom/components/nsComponentManager.h
--- 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 {