Bug 890545 - provide a way to enumerate registered manifests, r=froydnj,f=glandium
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Fri, 05 Jul 2013 21:20:04 +0200
changeset 171813 e28e95dc0795f065383948d776a29fe1835b1fea
parent 171812 1a83f8d13bdb402ba7b34f033794d0b348f5ab49
child 171814 ba12d004093fbd0ea8e7c0a7004002e375a71dda
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs890545
milestone28.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 890545 - provide a way to enumerate registered manifests, r=froydnj,f=glandium
js/xpconnect/loader/mozJSComponentLoader.cpp
js/xpconnect/loader/mozJSComponentLoader.h
xpcom/build/FileLocation.h
xpcom/components/nsComponentManager.cpp
xpcom/components/nsIComponentManager.idl
--- a/js/xpconnect/loader/mozJSComponentLoader.cpp
+++ b/js/xpconnect/loader/mozJSComponentLoader.cpp
@@ -27,17 +27,16 @@
 #include "mozilla/Module.h"
 #include "nsIFile.h"
 #include "mozJSComponentLoader.h"
 #include "mozJSLoaderUtils.h"
 #include "nsIJSRuntimeService.h"
 #include "nsIXPConnect.h"
 #include "nsIObserverService.h"
 #include "nsIScriptSecurityManager.h"
-#include "nsIURI.h"
 #include "nsIFileURL.h"
 #include "nsIJARURI.h"
 #include "nsNetUtil.h"
 #include "nsDOMBlobBuilder.h"
 #include "jsprf.h"
 #include "nsJSPrincipals.h"
 #include "xpcprivate.h"
 #include "xpcpublic.h"
--- a/js/xpconnect/loader/mozJSComponentLoader.h
+++ b/js/xpconnect/loader/mozJSComponentLoader.h
@@ -5,16 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozJSComponentLoader_h
 #define mozJSComponentLoader_h
 
 #include "mozilla/ModuleLoader.h"
 #include "nsISupports.h"
 #include "nsIObserver.h"
+#include "nsIURI.h"
 #include "xpcIJSModuleLoader.h"
 #include "nsClassHashtable.h"
 #include "nsDataHashtable.h"
 #include "jsapi.h"
 
 #include "xpcIJSGetFactory.h"
 
 class nsIFile;
--- a/xpcom/build/FileLocation.h
+++ b/xpcom/build/FileLocation.h
@@ -4,17 +4,16 @@
 
 #ifndef mozilla_FileLocation_h
 #define mozilla_FileLocation_h
 
 #include "nsString.h"
 #include "nsCOMPtr.h"
 #include "nsAutoPtr.h"
 #include "nsIFile.h"
-#include "nsIURI.h"
 #include "FileUtils.h"
 
 class nsZipArchive;
 class nsZipItem;
 
 namespace mozilla {
 
 class FileLocation
--- a/xpcom/components/nsComponentManager.cpp
+++ b/xpcom/components/nsComponentManager.cpp
@@ -60,19 +60,22 @@
 #include "nsTArray.h"
 #include "prio.h"
 #include "ManifestParser.h"
 #include "mozilla/Services.h"
 
 #include "nsManifestLineReader.h"
 #include "mozilla/GenericFactory.h"
 #include "nsSupportsPrimitives.h"
+#include "nsArray.h"
+#include "nsIMutableArray.h"
 #include "nsArrayEnumerator.h"
 #include "nsStringEnumerator.h"
 #include "mozilla/FileUtils.h"
+#include "nsNetUtil.h"
 
 #include <new>     // for placement new
 
 #include "mozilla/Omnijar.h"
 
 #include "prlog.h"
 
 using namespace mozilla;
@@ -1909,16 +1912,42 @@ nsComponentManagerImpl::RemoveBootstrapp
 
   // Remove reference.
   nsComponentManagerImpl::sModuleLocations->RemoveElement(elem, ComponentLocationComparator());
 
   rv = cr->CheckForNewChrome();
   return rv;
 }
 
+NS_IMETHODIMP
+nsComponentManagerImpl::GetManifestLocations(nsIArray **aLocations)
+{
+  NS_ENSURE_ARG_POINTER(aLocations);
+  *aLocations = nullptr;
+
+  if (!sModuleLocations)
+    return NS_ERROR_NOT_INITIALIZED;
+
+  nsCOMPtr<nsIMutableArray> locations = nsArray::Create();
+  nsresult rv;
+  for (uint32_t i = 0; i < sModuleLocations->Length(); ++i) {
+    ComponentLocation& l = sModuleLocations->ElementAt(i);
+    FileLocation loc = l.location;
+    nsCString uriString;
+    loc.GetURIString(uriString);
+    nsCOMPtr<nsIURI> uri;
+    rv = NS_NewURI(getter_AddRefs(uri), uriString);
+    if (NS_SUCCEEDED(rv))
+      locations->AppendElement(uri, false);
+  }
+
+  locations.forget(aLocations);
+  return NS_OK;
+}
+
 EXPORT_XPCOM_API(nsresult)
 XRE_AddManifestLocation(NSLocationType aType, nsIFile* aLocation)
 {
     nsComponentManagerImpl::InitializeModuleLocations();
     nsComponentManagerImpl::ComponentLocation* c = 
         nsComponentManagerImpl::sModuleLocations->AppendElement();
     c->type = aType;
     c->location.Init(aLocation);
--- a/xpcom/components/nsIComponentManager.idl
+++ b/xpcom/components/nsIComponentManager.idl
@@ -1,25 +1,26 @@
 /* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-  
+
 /**
  * The nsIComponentManager interface.
  */
 
 #include "nsISupports.idl"
 
 interface nsIFile;
 interface nsIFactory;
+interface nsIArray;
 
-[scriptable, uuid(1d940426-5fe5-42c3-84ae-a300f2d9ebd5)]
+[scriptable, uuid(d604ffc3-1ba3-4f6c-b65f-1ed4199364c3)]
 interface nsIComponentManager : nsISupports
-{    
+{
     /**
      * getClassObject
      *
      * Returns the factory object that can be used to create instances of
      * CID aClass
      *
      * @param aClass The classid of the factory that is being requested
      */
@@ -84,16 +85,22 @@ interface nsIComponentManager : nsISuppo
      *
      * Removes a bootstrapped manifest location on runtime.
      *
      * @param aLocation : A directory where chrome.manifest resides,
      *                    or an XPI with it on the root.
      */
     void removeBootstrappedManifestLocation(in nsIFile aLocation);
 
+    /**
+     * getManifestLocations
+     *
+     * Get an array of nsIURIs of all registered and builtin manifest locations.
+     */
+    nsIArray getManifestLocations();
 };
 
 
 %{ C++
 #ifdef MOZILLA_INTERNAL_API
 #include "nsComponentManagerUtils.h"
 #endif
 %} C++