Bug 890545 - provide a way to enumerate registered manifests, r=froydnj,f=glandium

--HG--
extra : rebase_source : 7534f0d3c0257ff34f1477c0bfdd23b540e7a7c7
This commit is contained in:
Gijs Kruitbosch 2013-07-05 21:20:04 +02:00
parent cf91a893bd
commit 2669f41615
5 changed files with 40 additions and 5 deletions

View File

@ -32,7 +32,6 @@
#include "nsIXPConnect.h"
#include "nsIObserverService.h"
#include "nsIScriptSecurityManager.h"
#include "nsIURI.h"
#include "nsIFileURL.h"
#include "nsIJARURI.h"
#include "nsNetUtil.h"

View File

@ -10,6 +10,7 @@
#include "mozilla/ModuleLoader.h"
#include "nsISupports.h"
#include "nsIObserver.h"
#include "nsIURI.h"
#include "xpcIJSModuleLoader.h"
#include "nsClassHashtable.h"
#include "nsDataHashtable.h"

View File

@ -9,7 +9,6 @@
#include "nsCOMPtr.h"
#include "nsAutoPtr.h"
#include "nsIFile.h"
#include "nsIURI.h"
#include "FileUtils.h"
class nsZipArchive;

View File

@ -65,9 +65,12 @@
#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
@ -1914,6 +1917,32 @@ nsComponentManagerImpl::RemoveBootstrappedManifestLocation(nsIFile* aLocation)
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)
{

View File

@ -2,7 +2,7 @@
/* 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.
*/
@ -11,10 +11,11 @@
interface nsIFile;
interface nsIFactory;
interface nsIArray;
[scriptable, uuid(1d940426-5fe5-42c3-84ae-a300f2d9ebd5)]
[scriptable, uuid(d604ffc3-1ba3-4f6c-b65f-1ed4199364c3)]
interface nsIComponentManager : nsISupports
{
{
/**
* getClassObject
*
@ -89,6 +90,12 @@ interface nsIComponentManager : nsISupports
*/
void removeBootstrappedManifestLocation(in nsIFile aLocation);
/**
* getManifestLocations
*
* Get an array of nsIURIs of all registered and builtin manifest locations.
*/
nsIArray getManifestLocations();
};