Bug 1263935 - Expose native version of mapURIToAddonId via amIAddonPathService. r=mossop

This commit is contained in:
Alexandre Poirot 2016-04-26 07:11:15 -07:00
parent be6d109116
commit 30d3ba40c6
2 changed files with 18 additions and 0 deletions

View File

@ -129,6 +129,16 @@ AddonPathService::InsertPath(const nsAString& path, const nsAString& addonIdStri
return NS_OK;
}
NS_IMETHODIMP
AddonPathService::MapURIToAddonId(nsIURI* aURI, nsAString& addonIdString)
{
if (JSAddonId* id = MapURIToAddonID(aURI)) {
JSFlatString* flat = JS_ASSERT_STRING_IS_FLAT(JS::StringOfAddonId(id));
AssignJSFlatString(addonIdString, flat);
}
return NS_OK;
}
static nsresult
ResolveURI(nsIURI* aURI, nsAString& out)
{

View File

@ -5,6 +5,8 @@
#include "nsISupports.idl"
interface nsIURI;
/**
* This service maps file system paths where add-ons reside to the ID
* of the add-on. Paths are added by the add-on manager. They can
@ -26,4 +28,10 @@ interface amIAddonPathService : nsISupports
* associated with the given add-on ID.
*/
void insertPath(in AString path, in AString addonId);
/**
* Given a URI to a file, return the ID of the add-on that the file belongs
* to. Returns an empty string if there is no add-on there.
*/
AString mapURIToAddonId(in nsIURI aURI);
};