Bug 877061 - PluginProvider can't find Home plugins on Android. r=Mossop

This commit is contained in:
Richard Newman 2013-05-29 14:18:41 -07:00
parent 6c61de1ac0
commit 2a6ad33ade

View File

@ -422,18 +422,23 @@ function PluginWrapper(aId, aName, aDescription, aTags) {
let path = aTags[0].fullpath;
// Plugins inside the application directory are in the application scope
let dir = Services.dirsvc.get("APlugns", Ci.nsIFile);
if (path.substring(0, dir.path.length) == dir.path)
if (path.startsWith(dir.path))
return AddonManager.SCOPE_APPLICATION;
// Plugins inside the profile directory are in the profile scope
dir = Services.dirsvc.get("ProfD", Ci.nsIFile);
if (path.substring(0, dir.path.length) == dir.path)
if (path.startsWith(dir.path))
return AddonManager.SCOPE_PROFILE;
// Plugins anywhere else in the user's home are in the user scope
dir = Services.dirsvc.get("Home", Ci.nsIFile);
if (path.substring(0, dir.path.length) == dir.path)
return AddonManager.SCOPE_USER;
// Plugins anywhere else in the user's home are in the user scope,
// but not all platforms have a home directory.
try {
dir = Services.dirsvc.get("Home", Ci.nsIFile);
if (path.startsWith(dir.path))
return AddonManager.SCOPE_USER;
} catch (e if (e.result && e.result == Components.results.NS_ERROR_FAILURE)) {
// Do nothing: missing "Home".
}
// Any other locations are system scope
return AddonManager.SCOPE_SYSTEM;