mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 03:45:46 +00:00
Bug 1263935 - Forward AddonManager.mapURIToAddonId to AddonPathService.mapURIToAddonId. r=mossop
This commit is contained in:
parent
30d3ba40c6
commit
912faf0bc9
@ -71,6 +71,10 @@ XPCOMUtils.defineLazyServiceGetter(this,
|
||||
"AddonPolicyService",
|
||||
"@mozilla.org/addons/policy-service;1",
|
||||
"nsIAddonPolicyService");
|
||||
XPCOMUtils.defineLazyServiceGetter(this,
|
||||
"AddonPathService",
|
||||
"@mozilla.org/addon-path-service;1",
|
||||
"amIAddonPathService");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "CertUtils", function() {
|
||||
let certUtils = {};
|
||||
@ -2435,8 +2439,7 @@ this.XPIProvider = {
|
||||
logger.info("Mapping " + aID + " to " + aFile.path);
|
||||
this._addonFileMap.set(aID, aFile.path);
|
||||
|
||||
let service = Cc["@mozilla.org/addon-path-service;1"].getService(Ci.amIAddonPathService);
|
||||
service.insertPath(aFile.path, aID);
|
||||
AddonPathService.insertPath(aFile.path, aID);
|
||||
},
|
||||
|
||||
/**
|
||||
@ -4106,20 +4109,8 @@ this.XPIProvider = {
|
||||
* @see amIAddonManager.mapURIToAddonID
|
||||
*/
|
||||
mapURIToAddonID: function(aURI) {
|
||||
if (aURI.scheme == "moz-extension") {
|
||||
return AddonPolicyService.extensionURIToAddonId(aURI);
|
||||
}
|
||||
|
||||
let resolved = this._resolveURIToFile(aURI);
|
||||
if (!resolved || !(resolved instanceof Ci.nsIFileURL))
|
||||
return null;
|
||||
|
||||
for (let [id, path] of this._addonFileMap) {
|
||||
if (resolved.file.path.startsWith(path))
|
||||
return id;
|
||||
}
|
||||
|
||||
return null;
|
||||
// Returns `null` instead of empty string if the URI can't be mapped.
|
||||
return AddonPathService.mapURIToAddonId(aURI) || null;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -83,8 +83,10 @@ function run_test_early() {
|
||||
"resource://gre/modules/addons/XPIProvider.jsm", {});
|
||||
|
||||
// Make the early API call.
|
||||
do_check_null(s.XPIProvider.mapURIToAddonID(uri));
|
||||
// AddonManager still misses its provider and so doesn't work yet.
|
||||
do_check_null(AddonManager.mapURIToAddonID(uri));
|
||||
// But calling XPIProvider directly works immediately
|
||||
do_check_eq(s.XPIProvider.mapURIToAddonID(uri), id);
|
||||
|
||||
// Actually start up the manager.
|
||||
startupManager(false);
|
||||
|
Loading…
Reference in New Issue
Block a user