зеркало из https://github.com/mozilla/gecko-dev.git
1. main patch - Bug 530872 - app.update.url params / update.xml cleanup and addition of a custom string property for apps. r=dtownsend
This commit is contained in:
Родитель
73ed222e26
Коммит
7ca0c8e98f
|
@ -63,7 +63,7 @@ var gUpdateHistory = {
|
|||
|
||||
// Don't display updates that are downloading since they don't have
|
||||
// valid statusText for the UI (bug 485493).
|
||||
if (update.statusText == "" || update.statusText == "undefined")
|
||||
if (!update.statusText)
|
||||
continue;
|
||||
|
||||
var element = document.createElementNS(NS_XUL, "update");
|
||||
|
@ -72,7 +72,10 @@ var gUpdateHistory = {
|
|||
[update.name, update.buildID]);
|
||||
element.type = bundle.getString("updateType_" + update.type);
|
||||
element.installDate = this._formatDate(update.installDate);
|
||||
if (update.detailsURL)
|
||||
element.detailsURL = update.detailsURL;
|
||||
else
|
||||
element.hideDetailsURL = true;
|
||||
element.status = update.statusText;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,11 +48,11 @@ const CoR = Components.results;
|
|||
|
||||
const XMLNS_XUL = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
||||
|
||||
const PREF_UPDATE_MANUAL_URL = "app.update.url.manual";
|
||||
const PREF_APP_UPDATE_ENABLED = "app.update.enabled";
|
||||
const PREF_APP_UPDATE_LOG = "app.update.log";
|
||||
const PREF_UPDATE_TEST_LOOP = "app.update.test.loop";
|
||||
const PREF_UPDATE_NEVER_BRANCH = "app.update.never.";
|
||||
const PREF_AUTO_UPDATE_ENABLED = "app.update.enabled";
|
||||
const PREF_APP_UPDATE_MANUAL_URL = "app.update.url.manual";
|
||||
const PREF_APP_UPDATE_NEVER_BRANCH = "app.update.never.";
|
||||
const PREF_APP_UPDATE_TEST_LOOP = "app.update.test.loop";
|
||||
const PREF_PLUGINS_UPDATEURL = "plugins.update.url";
|
||||
|
||||
const UPDATE_TEST_LOOP_INTERVAL = 2000;
|
||||
|
@ -222,14 +222,10 @@ var gUpdates = {
|
|||
},
|
||||
|
||||
never: function () {
|
||||
// If the user clicks "Never", we should not prompt them about updating to
|
||||
// this major update version again, unless they manually do
|
||||
// "Check for Updates..." which will clear the "never" pref for the version
|
||||
// presented and remind them later about this available update.
|
||||
//
|
||||
// Encode version since it could be a non-ascii string (bug 359093)
|
||||
var neverPrefName = PREF_UPDATE_NEVER_BRANCH +
|
||||
encodeURIComponent(gUpdates.update.version);
|
||||
// If the user clicks "No Thanks", we should not prompt them to update to
|
||||
// this version again unless they manually select "Check for Updates..."
|
||||
// which will clear all of the "never" prefs.
|
||||
var neverPrefName = PREF_APP_UPDATE_NEVER_BRANCH + gUpdates.update.appVersion;
|
||||
gPref.setBoolPref(neverPrefName, true);
|
||||
this.wiz.cancel();
|
||||
},
|
||||
|
@ -597,7 +593,7 @@ var gNoUpdatesPage = {
|
|||
LOG("gNoUpdatesPage", "onPageShow - could not select an appropriate " +
|
||||
"update. Either there were no updates or |selectUpdate| failed");
|
||||
|
||||
if (getPref("getBoolPref", PREF_AUTO_UPDATE_ENABLED, true))
|
||||
if (getPref("getBoolPref", PREF_APP_UPDATE_ENABLED, true))
|
||||
document.getElementById("noUpdatesAutoEnabled").hidden = false;
|
||||
else
|
||||
document.getElementById("noUpdatesAutoDisabled").hidden = false;
|
||||
|
@ -648,8 +644,8 @@ var gIncompatibleCheckPage = {
|
|||
var ai = CoC["@mozilla.org/xre/app-info;1"].getService(CoI.nsIXULAppInfo);
|
||||
var vc = CoC["@mozilla.org/xpcom/version-comparator;1"].
|
||||
getService(CoI.nsIVersionComparator);
|
||||
if (!gUpdates.update.extensionVersion ||
|
||||
vc.compare(gUpdates.update.extensionVersion, ai.version) == 0) {
|
||||
if (!gUpdates.update.appVersion ||
|
||||
vc.compare(gUpdates.update.appVersion, ai.version) == 0) {
|
||||
// Go to the next page
|
||||
gUpdates.wiz.advance();
|
||||
return;
|
||||
|
@ -657,7 +653,7 @@ var gIncompatibleCheckPage = {
|
|||
|
||||
var em = CoC["@mozilla.org/extensions/manager;1"].
|
||||
getService(CoI.nsIExtensionManager);
|
||||
this.addons = em.getIncompatibleItemList(gUpdates.update.extensionVersion,
|
||||
this.addons = em.getIncompatibleItemList(gUpdates.update.appVersion,
|
||||
gUpdates.update.platformVersion,
|
||||
CoI.nsIUpdateItem.TYPE_ANY, false);
|
||||
if (this.addons.length > 0) {
|
||||
|
@ -696,7 +692,7 @@ var gIncompatibleCheckPage = {
|
|||
em.update(this.addons, this.addons.length,
|
||||
CoI.nsIExtensionManager.UPDATE_NOTIFY_NEWVERSION, this,
|
||||
CoI.nsIExtensionManager.UPDATE_WHEN_NEW_APP_DETECTED,
|
||||
gUpdates.update.extensionVersion, gUpdates.update.platformVersion);
|
||||
gUpdates.update.appVersion, gUpdates.update.platformVersion);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -768,17 +764,14 @@ var gManualUpdatePage = {
|
|||
onPageShow: function() {
|
||||
var formatter = CoC["@mozilla.org/toolkit/URLFormatterService;1"].
|
||||
getService(CoI.nsIURLFormatter);
|
||||
var manualURL = formatter.formatURLPref(PREF_UPDATE_MANUAL_URL);
|
||||
var manualURL = formatter.formatURLPref(PREF_APP_UPDATE_MANUAL_URL);
|
||||
var manualUpdateLinkLabel = document.getElementById("manualUpdateLinkLabel");
|
||||
manualUpdateLinkLabel.value = manualURL;
|
||||
manualUpdateLinkLabel.setAttribute("url", manualURL);
|
||||
|
||||
// Prevent multiple notifications for the same update when the user is
|
||||
// unable to apply updates.
|
||||
// Encode version since it could be a non-ascii string (bug 359093)
|
||||
var neverPrefName = PREF_UPDATE_NEVER_BRANCH +
|
||||
encodeURIComponent(gUpdates.update.version);
|
||||
gPref.setBoolPref(neverPrefName, true);
|
||||
gUpdates.never();
|
||||
|
||||
gUpdates.setButtons(null, null, "okButton", true);
|
||||
gUpdates.wiz.getButton("finish").focus();
|
||||
|
@ -799,10 +792,10 @@ var gUpdatesAvailablePage = {
|
|||
* Initialize
|
||||
*/
|
||||
onPageShow: function() {
|
||||
var severity = gUpdates.update.type;
|
||||
var update = gUpdates.update;
|
||||
gUpdates.setButtons("askLaterButton",
|
||||
severity == "major" ? "noThanksButton" : null,
|
||||
"updateButton_" + severity, true);
|
||||
update.showNeverForVersion ? "noThanksButton" : null,
|
||||
"updateButton_" + update.type, true);
|
||||
var btn = gUpdates.wiz.getButton("next");
|
||||
btn.className += " heed";
|
||||
btn.focus();
|
||||
|
@ -810,37 +803,37 @@ var gUpdatesAvailablePage = {
|
|||
if (this._loaded)
|
||||
return;
|
||||
|
||||
if (!gUpdates.update.licenseURL) {
|
||||
if (!update.licenseURL) {
|
||||
if (gIncompatibleCheckPage.addons.length == 0)
|
||||
gUpdates.wiz.currentPage.setAttribute("next", "downloading");
|
||||
else
|
||||
gUpdates.wiz.currentPage.setAttribute("next", "incompatibleList");
|
||||
}
|
||||
|
||||
var updateName = gUpdates.update.name;
|
||||
if (gUpdates.update.channel == "nightly") {
|
||||
var updateName = update.name;
|
||||
if (update.channel == "nightly") {
|
||||
updateName = gUpdates.getAUSString("updateName", [gUpdates.brandName,
|
||||
gUpdates.update.version]);
|
||||
updateName = updateName + " " + gUpdates.update.buildID + " nightly";
|
||||
update.displayVersion]);
|
||||
updateName = updateName + " " + update.buildID + " nightly";
|
||||
}
|
||||
var updateNameElement = document.getElementById("updateName");
|
||||
updateNameElement.value = updateName;
|
||||
var updateTypeElement = document.getElementById("updateType");
|
||||
updateTypeElement.setAttribute("severity", severity);
|
||||
updateTypeElement.setAttribute("severity", update.type);
|
||||
|
||||
var moreInfoContent = document.getElementById("moreInfoContent");
|
||||
var intro;
|
||||
if (severity == "major") {
|
||||
if (update.billboardURL) {
|
||||
// for major updates, use the brandName and the version for the intro
|
||||
intro = gUpdates.getAUSString("intro_major_app_and_version",
|
||||
[gUpdates.brandName, gUpdates.update.version]);
|
||||
[gUpdates.brandName, update.displayVersion]);
|
||||
var remoteContent = document.getElementById("updateMoreInfoContent");
|
||||
// update_name and update_version need to be set before url
|
||||
// so that when attempting to download the url, we can show
|
||||
// the formatted "Download..." string
|
||||
remoteContent.update_name = gUpdates.brandName;
|
||||
remoteContent.update_version = gUpdates.update.version;
|
||||
remoteContent.url = gUpdates.update.detailsURL;
|
||||
remoteContent.update_version = update.displayVersion;
|
||||
remoteContent.url = update.billboardURL;
|
||||
|
||||
moreInfoContent.hidden = false;
|
||||
document.getElementById("moreInfoURL").hidden = true;
|
||||
|
@ -849,29 +842,27 @@ var gUpdatesAvailablePage = {
|
|||
document.getElementById("upgradeEvangelism").hidden = true;
|
||||
document.getElementById("upgradeEvangelismSep").hidden = true;
|
||||
|
||||
// Clear the "never" pref for this version. this is to handle the
|
||||
// scenario where the user clicked "never" for a major update and then at
|
||||
// a later point, did "Check for Updates..." and then canceled. If we
|
||||
// don't clear the "never" pref future notifications for this version
|
||||
// will never happen.
|
||||
//
|
||||
// Encode version since it could be a non-ascii string (bug 359093)
|
||||
var neverPrefName = PREF_UPDATE_NEVER_BRANCH +
|
||||
encodeURIComponent(gUpdates.update.version);
|
||||
gPref.setBoolPref(neverPrefName, false);
|
||||
// Clear all of the "never" prefs to handle the scenario where the user
|
||||
// clicked "never" for an update, selected "Check for Updates...", and
|
||||
// then canceled. If we don't clear the "never" prefs future
|
||||
// notifications will never happen.
|
||||
gPref.deleteBranch(PREF_APP_UPDATE_NEVER_BRANCH);
|
||||
}
|
||||
else {
|
||||
// for minor updates, just use the brandName for the intro
|
||||
intro = gUpdates.getAUSString("intro_minor_app", [gUpdates.brandName]);
|
||||
// This element when hidden still receives focus events which will
|
||||
// cause assertions with debug builds so remove it if it isn't used.
|
||||
// cause assertions with debug builds so remove it when it isn't used.
|
||||
moreInfoContent.parentNode.removeChild(moreInfoContent);
|
||||
var updateMoreInfoURL = document.getElementById("updateMoreInfoURL");
|
||||
updateMoreInfoURL.setAttribute("url", gUpdates.update.detailsURL);
|
||||
if (update.detailsURL)
|
||||
updateMoreInfoURL.setAttribute("url", update.detailsURL);
|
||||
else
|
||||
updateMoreInfoURL.hidden = true;
|
||||
}
|
||||
updateTypeElement.textContent = intro;
|
||||
|
||||
var updateTitle = gUpdates.getAUSString("updatesfound_" + severity +
|
||||
var updateTitle = gUpdates.getAUSString("updatesfound_" + update.type +
|
||||
".title");
|
||||
gUpdates.wiz.currentPage.setAttribute("label", updateTitle);
|
||||
// this is necessary to make this change to the label of the current
|
||||
|
@ -954,7 +945,7 @@ var gLicensePage = {
|
|||
// can display the formatted "Download..." string when attempting to
|
||||
// download the url.
|
||||
licenseContent.update_name = gUpdates.brandName;
|
||||
licenseContent.update_version = gUpdates.update.version;
|
||||
licenseContent.update_version = gUpdates.update.displayVersion;
|
||||
licenseContent.url = gUpdates.update.licenseURL;
|
||||
},
|
||||
|
||||
|
@ -1051,7 +1042,8 @@ var gIncompatibleListPage = {
|
|||
var intro;
|
||||
if (severity == "major")
|
||||
intro = gUpdates.getAUSString("incompatibleAddons_" + severity,
|
||||
[gUpdates.brandName, gUpdates.update.version,
|
||||
[gUpdates.brandName,
|
||||
gUpdates.update.displayVersion,
|
||||
gUpdates.brandName]);
|
||||
else
|
||||
intro = gUpdates.getAUSString("incompatibleAddons_" + severity,
|
||||
|
@ -1170,7 +1162,10 @@ var gDownloadingPage = {
|
|||
}
|
||||
|
||||
var link = document.getElementById("downloadDetailsLink");
|
||||
if (gUpdates.update.detailsURL)
|
||||
link.setAttribute("url", gUpdates.update.detailsURL);
|
||||
else
|
||||
link.hidden = true;
|
||||
|
||||
gUpdates.setButtons("hideButton", null, null, false);
|
||||
gUpdates.wiz.getButton("extra1").focus();
|
||||
|
@ -1500,7 +1495,7 @@ var gErrorsPage = {
|
|||
errorReason.value = statusText;
|
||||
var formatter = CoC["@mozilla.org/toolkit/URLFormatterService;1"].
|
||||
getService(CoI.nsIURLFormatter);
|
||||
var manualURL = formatter.formatURLPref(PREF_UPDATE_MANUAL_URL);
|
||||
var manualURL = formatter.formatURLPref(PREF_APP_UPDATE_MANUAL_URL);
|
||||
var errorLinkLabel = document.getElementById("errorLinkLabel");
|
||||
errorLinkLabel.value = manualURL;
|
||||
errorLinkLabel.setAttribute("url", manualURL);
|
||||
|
@ -1568,12 +1563,16 @@ var gFinishedPage = {
|
|||
updateFinishedName.value = gUpdates.update.name;
|
||||
|
||||
var link = document.getElementById("finishedBackgroundLink");
|
||||
if (gUpdates.update.detailsURL) {
|
||||
link.setAttribute("url", gUpdates.update.detailsURL);
|
||||
// The details link is stealing focus so it is disabled by default and
|
||||
// should only be enabled after onPageShow has been called.
|
||||
link.disabled = false;
|
||||
}
|
||||
else
|
||||
link.hidden = true;
|
||||
|
||||
if (getPref("getBoolPref", PREF_UPDATE_TEST_LOOP, false)) {
|
||||
if (getPref("getBoolPref", PREF_APP_UPDATE_TEST_LOOP, false)) {
|
||||
setTimeout(function () {
|
||||
gUpdates.wiz.getButton("finish").click();
|
||||
}, UPDATE_TEST_LOOP_INTERVAL);
|
||||
|
|
|
@ -187,7 +187,7 @@
|
|||
<content>
|
||||
<xul:hbox>
|
||||
<xul:label class="update-name" xbl:inherits="value=name" flex="1" crop="right"/>
|
||||
<xul:label xbl:inherits="href=detailsURL" class="text-link"
|
||||
<xul:label xbl:inherits="href=detailsURL,hidden=hideDetailsURL" class="text-link"
|
||||
value="&update.details.label;"/>
|
||||
</xul:hbox>
|
||||
<xul:label class="update-type" xbl:inherits="value=type"/>
|
||||
|
@ -221,6 +221,9 @@
|
|||
<property name="type"
|
||||
onget="return this.getAttribute('type');"
|
||||
onset="this.setAttribute('type', val); return val;"/>
|
||||
<property name="hideDetailsURL"
|
||||
onget="return this.getAttribute('hideDetailsURL');"
|
||||
onset="this.setAttribute('hideDetailsURL', val); return val;"/>
|
||||
<property name="status"
|
||||
onget="return this.getAttribute('status');">
|
||||
<setter><![CDATA[
|
||||
|
|
|
@ -113,7 +113,7 @@ interface nsIUpdatePatch : nsISupports
|
|||
* that the front end and other application services can use to learn more
|
||||
* about what is going on.
|
||||
*/
|
||||
[scriptable, uuid(9d6a388b-2e0c-4d0e-9a60-5c9739a7ada5)]
|
||||
[scriptable, uuid(31eced2b-8adb-46f9-992b-26858ab3d558)]
|
||||
interface nsIUpdate : nsISupports
|
||||
{
|
||||
/**
|
||||
|
@ -128,10 +128,16 @@ interface nsIUpdate : nsISupports
|
|||
*/
|
||||
attribute AString name;
|
||||
|
||||
/**
|
||||
* The string to display in the user interface for the version. If you want
|
||||
* a real version number use appVersion.
|
||||
*/
|
||||
attribute AString displayVersion;
|
||||
|
||||
/**
|
||||
* The Application version of this update.
|
||||
*/
|
||||
attribute AString version;
|
||||
attribute AString appVersion;
|
||||
|
||||
/**
|
||||
* The Toolkit version of this update.
|
||||
|
@ -139,10 +145,9 @@ interface nsIUpdate : nsISupports
|
|||
attribute AString platformVersion;
|
||||
|
||||
/**
|
||||
* The Addon version of this update. Used by the Extension System to track
|
||||
* compatibility of installed addons with this update.
|
||||
* The Application version prior to the application being updated.
|
||||
*/
|
||||
attribute AString extensionVersion;
|
||||
attribute AString previousAppVersion;
|
||||
|
||||
/**
|
||||
* The Build ID of this update. Used to determine a particular build, down
|
||||
|
@ -160,6 +165,12 @@ interface nsIUpdate : nsISupports
|
|||
*/
|
||||
attribute AString detailsURL;
|
||||
|
||||
/**
|
||||
* The URL to a page that is typically localized to display in the update
|
||||
* prompt.
|
||||
*/
|
||||
attribute AString billboardURL;
|
||||
|
||||
/**
|
||||
* The URL to a HTML fragment that contains a license for this update. If
|
||||
* this is specified, the user is shown the license file after they choose
|
||||
|
@ -178,6 +189,37 @@ interface nsIUpdate : nsISupports
|
|||
*/
|
||||
attribute AString channel;
|
||||
|
||||
/**
|
||||
* Stores custom string data provided by the update xml for use by the
|
||||
* application.
|
||||
*
|
||||
* Implementation Note: After an update has been successfully applied this
|
||||
* value will be added to the app.update.extra preference and if an
|
||||
* application uses this preference to determine that an update has been
|
||||
* applied it should also delete the preference.
|
||||
*/
|
||||
attribute AString extra1;
|
||||
|
||||
/**
|
||||
* Whether to show the update prompt which requires user confirmation when an
|
||||
* update is found during a background update check. This overrides the
|
||||
* default setting to download the update in the background.
|
||||
*/
|
||||
attribute boolean showPrompt;
|
||||
|
||||
/**
|
||||
* Whether to show the "No Thanks" button in the update prompt. This allows
|
||||
* the user to never receive a notification for that specific update version
|
||||
* again.
|
||||
*/
|
||||
attribute boolean showNeverForVersion;
|
||||
|
||||
/**
|
||||
* Whether to show the survey link in the update prompt. The url must also be
|
||||
* present in the app.update.surveyURL preference.
|
||||
*/
|
||||
attribute boolean showSurvey;
|
||||
|
||||
/**
|
||||
* Whether or not the update being downloaded is a complete replacement of
|
||||
* the user's existing installation or a patch representing the difference
|
||||
|
|
|
@ -49,22 +49,24 @@ const Cc = Components.classes;
|
|||
const Ci = Components.interfaces;
|
||||
const Cr = Components.results;
|
||||
|
||||
const PREF_APP_UPDATE_ENABLED = "app.update.enabled";
|
||||
const PREF_APP_UPDATE_AUTO = "app.update.auto";
|
||||
const PREF_APP_UPDATE_MODE = "app.update.mode";
|
||||
const PREF_APP_UPDATE_SILENT = "app.update.silent";
|
||||
const PREF_APP_UPDATE_INTERVAL = "app.update.interval";
|
||||
const PREF_APP_UPDATE_IDLETIME = "app.update.idletime";
|
||||
const PREF_APP_UPDATE_LOG = "app.update.log";
|
||||
const PREF_APP_UPDATE_PROMPTWAITTIME = "app.update.promptWaitTime";
|
||||
const PREF_APP_UPDATE_URL = "app.update.url";
|
||||
const PREF_APP_UPDATE_URL_OVERRIDE = "app.update.url.override";
|
||||
const PREF_APP_UPDATE_URL_DETAILS = "app.update.url.details";
|
||||
const PREF_APP_UPDATE_CHANNEL = "app.update.channel";
|
||||
const PREF_APP_UPDATE_BACKGROUND_INTERVAL = "app.update.download.backgroundInterval";
|
||||
const PREF_APP_UPDATE_SHOW_INSTALLED_UI = "app.update.showInstalledUI";
|
||||
const PREF_APP_UPDATE_CHANNEL = "app.update.channel";
|
||||
const PREF_APP_UPDATE_ENABLED = "app.update.enabled";
|
||||
const PREF_APP_UPDATE_EXTRA1 = "app.update.extra1";
|
||||
const PREF_APP_UPDATE_IDLETIME = "app.update.idletime";
|
||||
const PREF_APP_UPDATE_INCOMPATIBLE_MODE = "app.update.incompatible.mode";
|
||||
const PREF_UPDATE_NEVER_BRANCH = "app.update.never.";
|
||||
const PREF_APP_UPDATE_INTERVAL = "app.update.interval";
|
||||
const PREF_APP_UPDATE_LOG = "app.update.log";
|
||||
const PREF_APP_UPDATE_MODE = "app.update.mode";
|
||||
const PREF_APP_UPDATE_NEVER_BRANCH = "app.update.never.";
|
||||
const PREF_APP_UPDATE_PROMPTWAITTIME = "app.update.promptWaitTime";
|
||||
const PREF_APP_UPDATE_SHOW_INSTALLED_UI = "app.update.showInstalledUI";
|
||||
const PREF_APP_UPDATE_SILENT = "app.update.silent";
|
||||
const PREF_APP_UPDATE_URL = "app.update.url";
|
||||
const PREF_APP_UPDATE_URL_DETAILS = "app.update.url.details";
|
||||
const PREF_APP_UPDATE_URL_OVERRIDE = "app.update.url.override";
|
||||
|
||||
const PREF_PARTNER_BRANCH = "app.partner.";
|
||||
const PREF_APP_DISTRIBUTION = "distribution.id";
|
||||
const PREF_APP_DISTRIBUTION_VERSION = "distribution.version";
|
||||
|
@ -474,7 +476,7 @@ function writeStatusFile(dir, state) {
|
|||
/**
|
||||
# Writes the update's application version to a file in the patch directory. If
|
||||
# the update doesn't provide application version information via the
|
||||
# extensionVersion attribute the string "null" will be written to the file.
|
||||
# appVersion attribute the string "null" will be written to the file.
|
||||
# This value is compared during startup (in nsUpdateDriver.cpp) to determine if
|
||||
# the update should be applied. Note that this won't provide protection from
|
||||
# downgrade of the application for the nightly user case where the application
|
||||
|
@ -484,8 +486,7 @@ function writeStatusFile(dir, state) {
|
|||
# written.
|
||||
# @param version
|
||||
# The version value to write. Will be the string "null" when the
|
||||
# update doesn't provide the extensionVersion attribute in the update
|
||||
# xml.
|
||||
# update doesn't provide the appVersion attribute in the update xml.
|
||||
*/
|
||||
function writeVersionFile(dir, version) {
|
||||
var versionFile = dir.clone();
|
||||
|
@ -824,8 +825,10 @@ UpdatePatch.prototype = {
|
|||
function Update(update) {
|
||||
this._properties = {};
|
||||
this._patches = [];
|
||||
this.installDate = 0;
|
||||
this.isCompleteUpdate = false;
|
||||
this.showPrompt = false;
|
||||
this.showSurvey = false;
|
||||
this.showNeverForVersion = false;
|
||||
this.channel = "default"
|
||||
|
||||
// Null <update>, assume this is a message container and do no
|
||||
|
@ -855,20 +858,45 @@ function Update(update) {
|
|||
for (var i = 0; i < update.attributes.length; ++i) {
|
||||
var attr = update.attributes.item(i);
|
||||
attr.QueryInterface(Ci.nsIDOMAttr);
|
||||
if (attr.name == "installDate" && attr.value)
|
||||
if (attr.value == "undefined")
|
||||
continue;
|
||||
else if (attr.name == "installDate" && attr.value)
|
||||
this.installDate = parseInt(attr.value);
|
||||
else if (attr.name == "isCompleteUpdate")
|
||||
this.isCompleteUpdate = attr.value == "true";
|
||||
else if (attr.name == "isSecurityUpdate")
|
||||
this.isSecurityUpdate = attr.value == "true";
|
||||
else if (attr.name == "showPrompt")
|
||||
this.showPrompt = attr.value == "true";
|
||||
else if (attr.name == "showNeverForVersion")
|
||||
this.showNeverForVersion = attr.value == "true";
|
||||
else if (attr.name == "showSurvey")
|
||||
this.showSurvey = attr.value == "true";
|
||||
else if (attr.name == "detailsURL")
|
||||
this._detailsURL = attr.value;
|
||||
else if (attr.name == "channel")
|
||||
this.channel = attr.value;
|
||||
else if (attr.name == "extensionVersion") {
|
||||
// Prevent extensionVersion from replacing appVersion if appVersion is
|
||||
// present in the update xml.
|
||||
if (!this.appVersion)
|
||||
this.appVersion = attr.value;
|
||||
}
|
||||
else if (attr.name == "version") {
|
||||
// Prevent version from replacing displayVersion if displayVersion is
|
||||
// present in the update xml.
|
||||
if (!this.displayVersion)
|
||||
this.displayVersion = attr.value;
|
||||
}
|
||||
else
|
||||
this[attr.name] = attr.value;
|
||||
}
|
||||
|
||||
// Set the initial value with the current time when it doesn't already have a
|
||||
// value or the value is already set to 0 (bug 316328).
|
||||
if (!this.installDate && this.installDate != 0)
|
||||
this.installDate = (new Date()).getTime();
|
||||
|
||||
// The Update Name is either the string provided by the <update> element, or
|
||||
// the string: "<App Name> <Update App Version>"
|
||||
var name = "";
|
||||
|
@ -880,7 +908,7 @@ function Update(update) {
|
|||
createBundle(URI_BRAND_PROPERTIES);
|
||||
var appName = brandBundle.GetStringFromName("brandShortName");
|
||||
name = gUpdateBundle.formatStringFromName("updateName",
|
||||
[appName, this.version], 2);
|
||||
[appName, this.displayVersion], 2);
|
||||
}
|
||||
this.name = name;
|
||||
}
|
||||
|
@ -961,17 +989,34 @@ Update.prototype = {
|
|||
var update = updates.createElementNS(URI_UPDATE_NS, "update");
|
||||
update.setAttribute("type", this.type);
|
||||
update.setAttribute("name", this.name);
|
||||
update.setAttribute("version", this.version);
|
||||
update.setAttribute("displayVersion", this.displayVersion);
|
||||
// for backwards compatibility in case the user downgrades
|
||||
update.setAttribute("version", this.displayVersion);
|
||||
update.setAttribute("appVersion", this.appVersion);
|
||||
update.setAttribute("buildID", this.buildID);
|
||||
// for backwards compatibility in case the user downgrades
|
||||
update.setAttribute("extensionVersion", this.appVersion);
|
||||
if (this.platformVersion)
|
||||
update.setAttribute("platformVersion", this.platformVersion);
|
||||
update.setAttribute("extensionVersion", this.extensionVersion);
|
||||
if (this.previousAppVersion)
|
||||
update.setAttribute("previousAppVersion", this.previousAppVersion);
|
||||
if (this.detailsURL)
|
||||
update.setAttribute("detailsURL", this.detailsURL);
|
||||
if (this.billboardURL)
|
||||
update.setAttribute("billboardURL", this.billboardURL);
|
||||
if (this.licenseURL)
|
||||
update.setAttribute("licenseURL", this.licenseURL);
|
||||
update.setAttribute("serviceURL", this.serviceURL);
|
||||
update.setAttribute("installDate", this.installDate);
|
||||
if (this.statusText)
|
||||
update.setAttribute("statusText", this.statusText);
|
||||
update.setAttribute("buildID", this.buildID);
|
||||
update.setAttribute("isCompleteUpdate", this.isCompleteUpdate);
|
||||
update.setAttribute("channel", this.channel);
|
||||
update.setAttribute("showPrompt", this.showPrompt);
|
||||
update.setAttribute("showSurvey", this.showSurvey);
|
||||
update.setAttribute("showNeverForVersion", this.showNeverForVersion);
|
||||
if (this.extra1)
|
||||
update.setAttribute("extra1", this.extra1);
|
||||
updates.documentElement.appendChild(update);
|
||||
|
||||
for (var p in this._properties) {
|
||||
|
@ -1021,8 +1066,7 @@ Update.prototype = {
|
|||
* See nsIPropertyBag.idl
|
||||
*/
|
||||
getProperty: function Update_getProperty(name) {
|
||||
if (name in this._properties &&
|
||||
this._properties[name].present)
|
||||
if (name in this._properties && this._properties[name].present)
|
||||
return this._properties[name].data;
|
||||
throw Cr.NS_ERROR_FAILURE;
|
||||
},
|
||||
|
@ -1153,7 +1197,8 @@ UpdateService.prototype = {
|
|||
|
||||
// Update the patch's metadata.
|
||||
um.activeUpdate = update;
|
||||
|
||||
gPref.setCharPref(PREF_APP_UPDATE_EXTRA1,
|
||||
update.extra1 ? update.extra1 : "undefined");
|
||||
prompter.showUpdateInstalled();
|
||||
|
||||
// Done with this update. Clean it up.
|
||||
|
@ -1171,12 +1216,12 @@ UpdateService.prototype = {
|
|||
if (update.errorCode == WRITE_ERROR) {
|
||||
prompter.showUpdateError(update);
|
||||
writeStatusFile(getUpdatesDir(), update.state = STATE_PENDING);
|
||||
writeVersionFile(getUpdatesDir(), update.extensionVersion);
|
||||
writeVersionFile(getUpdatesDir(), update.appVersion);
|
||||
return;
|
||||
}
|
||||
else if (update.errorCode == ELEVATION_CANCELED) {
|
||||
writeStatusFile(getUpdatesDir(), update.state = STATE_PENDING);
|
||||
writeVersionFile(getUpdatesDir(), update.extensionVersion);
|
||||
writeVersionFile(getUpdatesDir(), update.appVersion);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1258,13 +1303,13 @@ UpdateService.prototype = {
|
|||
|
||||
for (var i = 0; i < updates.length; ++i) {
|
||||
// Ignore updates for older versions of the application
|
||||
if (gVC.compare(updates[i].extensionVersion, gApp.version) < 0)
|
||||
if (gVC.compare(updates[i].appVersion, gApp.version) < 0)
|
||||
continue;
|
||||
if (updates[i].type == "major" &&
|
||||
gVC.compare(newestMajor.version, updates[i].version) <= 0)
|
||||
gVC.compare(newestMajor.appVersion, updates[i].appVersion) <= 0)
|
||||
majorUpdate = newestMajor = updates[i];
|
||||
if (updates[i].type == "minor" &&
|
||||
gVC.compare(newestMinor.version, updates[i].version) <= 0)
|
||||
gVC.compare(newestMinor.appVersion, updates[i].appVersion) <= 0)
|
||||
minorUpdate = newestMinor = updates[i];
|
||||
}
|
||||
|
||||
|
@ -1325,28 +1370,17 @@ UpdateService.prototype = {
|
|||
# a scenario where this could potentially be an issue.
|
||||
*/
|
||||
|
||||
// Encode version since it could be a non-ascii string (bug 359093)
|
||||
var neverPrefName = PREF_UPDATE_NEVER_BRANCH +
|
||||
encodeURIComponent(update.version);
|
||||
|
||||
if (!gCanApplyUpdates) {
|
||||
var neverPrefName = PREF_APP_UPDATE_NEVER_BRANCH + update.appVersion;
|
||||
if (getPref("getBoolPref", neverPrefName, false)) {
|
||||
LOG("Checker:_selectAndInstallUpdate - the user is unable to apply " +
|
||||
"updates. Not prompting because the preference " + neverPrefName +
|
||||
" is true");
|
||||
}
|
||||
else {
|
||||
LOG("Checker:_selectAndInstallUpdate - the user is unable to apply " +
|
||||
"updates... prompting");
|
||||
this._showPrompt(update);
|
||||
}
|
||||
LOG("Checker:_selectAndInstallUpdate - not prompting because the " +
|
||||
"preference " + neverPrefName + " is true");
|
||||
return;
|
||||
}
|
||||
|
||||
if (update.type == "major" &&
|
||||
getPref("getBoolPref", neverPrefName, false)) {
|
||||
LOG("Checker:_selectAndInstallUpdate - not prompting because this is a " +
|
||||
"major update and the preference " + neverPrefName + " is true");
|
||||
if (!gCanApplyUpdates) {
|
||||
LOG("Checker:_selectAndInstallUpdate - the user is unable to apply " +
|
||||
"updates... prompting");
|
||||
this._showPrompt(update);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1368,9 +1402,9 @@ UpdateService.prototype = {
|
|||
# Minor 1 or 2 Yes Notify
|
||||
# Minor 1 or 2 No Auto Install
|
||||
*/
|
||||
if (update.type == "major") {
|
||||
LOG("Checker:_selectAndInstallUpdate - prompting because it is a major " +
|
||||
"update");
|
||||
if (update.showPrompt) {
|
||||
LOG("Checker:_selectAndInstallUpdate - prompting because the update " +
|
||||
"snippet specified showPrompt");
|
||||
this._showPrompt(update);
|
||||
return;
|
||||
}
|
||||
|
@ -1393,8 +1427,7 @@ UpdateService.prototype = {
|
|||
}
|
||||
|
||||
// Only check add-on compatibility when the version changes.
|
||||
if (update.extensionVersion &&
|
||||
gVC.compare(update.extensionVersion, gApp.version) != 0) {
|
||||
if (update.appVersion && gVC.compare(update.appVersion, gApp.version) != 0) {
|
||||
this._update = update;
|
||||
this._checkAddonCompatibility();
|
||||
}
|
||||
|
@ -1418,7 +1451,7 @@ UpdateService.prototype = {
|
|||
getService(Ci.nsIExtensionManager);
|
||||
// Get the add-ons that are incompatible with the update's application
|
||||
// version and toolkit version.
|
||||
var currentAddons = em.getIncompatibleItemList(this._update.extensionVersion,
|
||||
var currentAddons = em.getIncompatibleItemList(this._update.appVersion,
|
||||
this._update.platformVersion,
|
||||
Ci.nsIUpdateItem.TYPE_ANY,
|
||||
false);
|
||||
|
@ -1469,7 +1502,7 @@ UpdateService.prototype = {
|
|||
Ci.nsIExtensionManager.UPDATE_NOTIFY_NEWVERSION;
|
||||
em.update(currentAddons, currentAddons.length, mode, this,
|
||||
Ci.nsIExtensionManager.UPDATE_WHEN_NEW_APP_DETECTED,
|
||||
this._update.extensionVersion, this._update.platformVersion);
|
||||
this._update.appVersion, this._update.platformVersion);
|
||||
}
|
||||
else {
|
||||
LOG("UpdateService:_checkAddonCompatibility - no need to show prompt, " +
|
||||
|
@ -1586,14 +1619,14 @@ UpdateService.prototype = {
|
|||
// current application's version or the update's version is the same as the
|
||||
// application's version and the build ID is the same as the application's
|
||||
// build ID.
|
||||
if (update.extensionVersion &&
|
||||
(gVC.compare(update.extensionVersion, gApp.version) < 0 ||
|
||||
if (update.appVersion &&
|
||||
(gVC.compare(update.appVersion, gApp.version) < 0 ||
|
||||
update.buildID && update.buildID == gApp.appBuildID &&
|
||||
update.extensionVersion == gApp.version)) {
|
||||
update.appVersion == gApp.version)) {
|
||||
LOG("UpdateService:downloadUpdate - canceling download of update since " +
|
||||
"it is for an earlier or same application version and build ID.\n" +
|
||||
"current application version: " + gApp.version + "\n" +
|
||||
"update application version : " + update.extensionVersion + "\n" +
|
||||
"update application version : " + update.appVersion + "\n" +
|
||||
"current build ID: " + gApp.appBuildID + "\n" +
|
||||
"update build ID : " + update.buildID);
|
||||
cleanupActiveUpdate();
|
||||
|
@ -1609,6 +1642,8 @@ UpdateService.prototype = {
|
|||
}
|
||||
this._downloader.cancel();
|
||||
}
|
||||
// Set the previous application version prior to downloading the update.
|
||||
update.previousAppVersion = gApp.version;
|
||||
this._downloader = new Downloader(background);
|
||||
return this._downloader.downloadUpdate(update);
|
||||
},
|
||||
|
@ -1798,7 +1833,7 @@ UpdateManager.prototype = {
|
|||
if (this._updates) {
|
||||
for (var i = 0; i < this._updates.length; ++i) {
|
||||
if (this._updates[i] &&
|
||||
this._updates[i].version == update.version &&
|
||||
this._updates[i].appVersion == update.appVersion &&
|
||||
this._updates[i].buildID == update.buildID) {
|
||||
// Replace the existing entry with the new value, updating
|
||||
// all metadata.
|
||||
|
@ -2496,7 +2531,7 @@ Downloader.prototype = {
|
|||
|
||||
// Tell the updater.exe we're ready to apply.
|
||||
writeStatusFile(getUpdatesDir(), state);
|
||||
writeVersionFile(getUpdatesDir(), this._update.extensionVersion);
|
||||
writeVersionFile(getUpdatesDir(), this._update.appVersion);
|
||||
this._update.installDate = (new Date()).getTime();
|
||||
this._update.statusText = gUpdateBundle.GetStringFromName("installPending");
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче