Bug 1215965 - Remove use of non-standard features from toolkit/components/social/SocialService.jsm. r=mixedpuppy

--HG--
extra : commitid : JmV9F7hd3C
extra : rebase_source : 51e5ce38105a0ccd3eaf5565314af3403c80cc16
extra : amend_source : 5681fd3aab1d475e6b9ce822622a51acea623c24
This commit is contained in:
Tooru Fujisawa 2015-10-19 05:07:55 +09:00
Родитель fbb1c0bfe7
Коммит d43b11316b
1 изменённых файлов: 15 добавлений и 12 удалений

Просмотреть файл

@ -39,9 +39,9 @@ var SocialServiceInternal = {
},
get providerArray() {
return [p for ([, p] of Iterator(this.providers))];
return Object.keys(this.providers).map(origin => this.providers[origin]);
},
get manifests() {
*manifestsGenerator() {
// Retrieve the manifests of installed providers from prefs
let MANIFEST_PREFS = Services.prefs.getBranch("social.manifest.");
let prefs = MANIFEST_PREFS.getChildList("", []);
@ -59,6 +59,9 @@ var SocialServiceInternal = {
}
}
},
get manifests() {
return this.manifestsGenerator();
},
getManifestPrefname: function(origin) {
// Retrieve the prefname for a given origin/manifest.
// If no existing pref, return a generated prefname.
@ -96,13 +99,13 @@ var SocialServiceInternal = {
p.frecency = 0;
providers[p.domain] = p;
hosts.push(p.domain);
};
}
// cannot bind an array to stmt.params so we have to build the string
let stmt = PlacesUtils.history.QueryInterface(Ci.nsPIPlacesDatabase)
.DBConnection.createAsyncStatement(
"SELECT host, frecency FROM moz_hosts WHERE host IN (" +
[ '"' + host + '"' for each (host in hosts) ].join(",") + ") "
hosts.map(host => '"' + host + '"').join(",") + ") "
);
try {
@ -361,7 +364,7 @@ this.SocialService = {
// not yet flushed so we check the active providers array
for (let p in ActiveProviders._providers) {
return true;
};
}
return false;
},
get enabled() {
@ -519,7 +522,7 @@ this.SocialService = {
data.origin = principal.origin;
// iconURL and name are required
let providerHasFeatures = [url for (url of featureURLs) if (data[url])].length > 0;
let providerHasFeatures = featureURLs.some(url => data[url]);
if (!providerHasFeatures) {
Cu.reportError("SocialService.manifestFromData manifest missing required urls.");
return null;
@ -948,7 +951,7 @@ SocialProvider.prototype = {
return null;
}
}
}
};
function getAddonIDFromOrigin(origin) {
let originUri = Services.io.newURI(origin, null, null);
@ -988,10 +991,10 @@ function AddonInstaller(sourceURI, aManifest, installCallback) {
installCallback(aManifest);
};
this.cancel = function() {
Services.prefs.clearUserPref(getPrefnameFromOrigin(aManifest.origin))
},
Services.prefs.clearUserPref(getPrefnameFromOrigin(aManifest.origin));
};
this.addon = new AddonWrapper(aManifest);
};
}
var SocialAddonProvider = {
startup: function() {},
@ -1029,7 +1032,7 @@ var SocialAddonProvider = {
aCallback([]);
return;
}
aCallback([new AddonWrapper(a) for each (a in SocialServiceInternal.manifests)]);
aCallback([...SocialServiceInternal.manifests].map(a => new AddonWrapper(a)));
},
removeAddon: function(aAddon, aCallback) {
@ -1042,7 +1045,7 @@ var SocialAddonProvider = {
if (aCallback)
schedule(aCallback);
}
}
};
function AddonWrapper(aManifest) {