Bug 970200 - Check against user general update settings for webapp updates. r=mfinkle

This commit is contained in:
Martyn Haigh 2014-05-06 07:32:00 -04:00
parent dac30139cf
commit a0290a3144
2 changed files with 23 additions and 9 deletions

View File

@ -56,7 +56,6 @@ WebappsUpdateTimer.prototype = {
}
log("network back online for webapp update check; commencing");
// TODO: observe pref to do this only on wifi.
Services.obs.removeObserver(this, "network:offline-status-changed");
WebappManager.checkForUpdates();
}

View File

@ -303,16 +303,31 @@ this.WebappManager = {
return;
}
let names = [manifestUrlToApp[url].name for (url of outdatedApps)].join(", ");
let accepted = yield this._notify({
title: PluralForm.get(outdatedApps.length, Strings.GetStringFromName("downloadUpdateTitle")).
replace("#1", outdatedApps.length),
message: Strings.formatStringFromName("downloadUpdateMessage", [names], 1),
icon: "drawable://alert_download",
}).dismissed;
let usingLan = function() {
let network = Cc["@mozilla.org/network/network-link-service;1"].getService(Ci.nsINetworkLinkService);
return (network.linkType == network.LINK_TYPE_WIFI || network.linkType == network.LINK_TYPE_ETHERNET);
};
if (accepted) {
let updateAllowed = function() {
let autoUpdatePref = Services.prefs.getCharPref("app.update.autodownload");
return (autoUpdatePref == "enabled") || (autoUpdatePref == "wifi" && usingLan());
};
if (updateAllowed()) {
yield this._updateApks([manifestUrlToApp[url] for (url of outdatedApps)]);
} else {
let names = [manifestUrlToApp[url].name for (url of outdatedApps)].join(", ");
let accepted = yield this._notify({
title: PluralForm.get(outdatedApps.length, Strings.GetStringFromName("downloadUpdateTitle")).
replace("#1", outdatedApps.length),
message: Strings.formatStringFromName("downloadUpdateMessage", [names], 1),
icon: "drawable://alert_download",
}).dismissed;
if (accepted) {
yield this._updateApks([manifestUrlToApp[url] for (url of outdatedApps)]);
}
}
}
// There isn't a catch block because we want the error to propagate through