зеркало из https://github.com/mozilla/pjs.git
Add an 'errors' page to the update wizard to report verification errors.
This commit is contained in:
Родитель
ac081d05f9
Коммит
4a4999af78
|
@ -35,6 +35,8 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
// XXX Toolkit-specific preferences should be moved into toolkit.js
|
||||
|
||||
#filter substitution
|
||||
|
||||
# SYNTAX HINTS: dashes are delimiters. Use underscores instead.
|
||||
|
@ -56,11 +58,6 @@ pref("xpinstall.dialog.progress.type.chrome", "Extension:Manager-extensions");
|
|||
// compared to this value. A trailing "+" indicates the post-release trunk.
|
||||
pref("app.extensions.version", "1.0+");
|
||||
|
||||
// Whether or not app updates are enabled
|
||||
pref("update.app.enabled", true);
|
||||
pref("update.app.url", "chrome://mozapps/locale/update/update.properties");
|
||||
|
||||
pref("update.extensions.enabled", true);
|
||||
pref("extensions.getMoreExtensionsURL", "chrome://mozapps/locale/extensions/extensions.properties");
|
||||
pref("extensions.getMoreThemesURL", "chrome://mozapps/locale/extensions/extensions.properties");
|
||||
// Developers can set this to |true| if they are constantly changing files in their
|
||||
|
@ -81,7 +78,10 @@ pref("app.update.autoInstallEnabled", true);
|
|||
// the user to install.
|
||||
pref("app.update.autoInstallMode", 0);
|
||||
|
||||
pref("app.update.url", "chrome://mozapps/locale/update/update.properties");
|
||||
// XXX these prefs and others like them are distribution specific and should move
|
||||
// into chrome://browser
|
||||
pref("app.update.url", "chrome://mozapps/locale/update/updates.properties");
|
||||
pref("app.update.manual.url", "chrome://mozapps/locale/update/updates.properties");
|
||||
pref("app.update.updatesAvailable", false);
|
||||
// Check for updates to Firefox every day
|
||||
pref("app.update.interval", 86400000);
|
||||
|
@ -118,20 +118,6 @@ pref("extensions.dss.enabled", false); // Dynamic Skin Switching
|
|||
pref("extensions.dss.switchPending", false); // Non-dynamic switch pending after next
|
||||
// restart.
|
||||
|
||||
// General Update preferences
|
||||
pref("update.interval", 3600000); // Check each of the above intervals
|
||||
// every 60 mins
|
||||
pref("update.showSlidingNotification", true); // Windows-only slide-up taskbar
|
||||
// notification.
|
||||
// These prefs relate to the number and severity of updates available. This is a
|
||||
// cache that the browser notification mechanism uses to determine if it should show
|
||||
// status bar UI if updates are detected and the app is shut down before installing
|
||||
// them.
|
||||
// 0 = low (extension/theme updates),
|
||||
// 1 = medium (numerous extension/theme updates),
|
||||
// 2 = high (new version of Firefox/Security patch)
|
||||
pref("update.severity", 0);
|
||||
|
||||
pref("xpinstall.whitelist.add", "update.mozilla.org");
|
||||
pref("xpinstall.whitelist.add.103", "addons.mozilla.org");
|
||||
|
||||
|
|
|
@ -36,3 +36,8 @@
|
|||
<!ENTITY close.label "Close">
|
||||
<!ENTITY close.accesskey "C">
|
||||
|
||||
<!ENTITY error.label "There were problems installing this update. &brandShortName; could
|
||||
not be updated because:">
|
||||
|
||||
<!ENTITY errorManual.label "You can update &brandShortName; manually by visiting this link
|
||||
and downloading the latest version:">
|
||||
|
|
|
@ -3,3 +3,8 @@ updateType_major=New Version
|
|||
updateType_minor=Security Update
|
||||
introType_minor=An important Security Update for %S is available:
|
||||
introType_major=A new version of %S is available:
|
||||
verificationError=%S could not confirm the integrity of the update package.
|
||||
app.update.url=http://localhost/updates-test-1.xml
|
||||
app.update.manual.url=http://localhost/manual.html
|
||||
errorsPageHeader=Update Failed
|
||||
downloadingPageTitle=Downloading Updates
|
||||
|
|
|
@ -68,6 +68,7 @@
|
|||
const nsIUpdateItem = Components.interfaces.nsIUpdateItem;
|
||||
const nsIUpdateService = Components.interfaces.nsIUpdateService;
|
||||
|
||||
const PREF_UPDATE_EXTENSIONS_ENABLED = "extensions.update.enabled";
|
||||
const PREF_UPDATE_EXTENSIONS_AUTOUPDATEENABLED = "extensions.update.autoUpdateEnabled";
|
||||
const PREF_UPDATE_EXTENSIONS_COUNT = "extensions.update.count";
|
||||
const PREF_UPDATE_EXTENSIONS_SEVERITY_THRESHOLD = "extensions.update.severity.threshold";
|
||||
|
@ -130,7 +131,7 @@ var gUpdateWizard = {
|
|||
var pref = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefBranch);
|
||||
if (this.shouldSuggestAutoChecking)
|
||||
pref.setBoolPref("update.extensions.enabled", this.shouldAutoCheck);
|
||||
pref.setBoolPref(PREF_EXTENSIONS_UPDATE_ENABLED, this.shouldAutoCheck);
|
||||
|
||||
if (this.succeeded) {
|
||||
// Downloading and Installed Extension
|
||||
|
|
|
@ -1,7 +1,13 @@
|
|||
.wizard-header {
|
||||
wizard[label=""][description=""] .wizard-header,
|
||||
wizard[label=""] .wizard-header-label,
|
||||
wizard[description=""] .wizard-header-description {
|
||||
display: none;
|
||||
}
|
||||
|
||||
wizard[currentpageid="errors"] .wizard-buttons {
|
||||
display: -moz-box;
|
||||
}
|
||||
|
||||
.wizard-buttons {
|
||||
display: none;
|
||||
}
|
||||
|
@ -14,16 +20,30 @@
|
|||
margin: 10px 44px 10px 44px;
|
||||
}
|
||||
|
||||
#errorReason {
|
||||
margin-top: 1px;
|
||||
margin-bottom: 2px;
|
||||
-moz-margin-start: 6px !important;
|
||||
-moz-margin-end: 5px;
|
||||
}
|
||||
|
||||
link {
|
||||
-moz-binding: url("chrome://mozapps/content/update/updates.xml#link");
|
||||
-moz-user-focus: normal;
|
||||
color: blue;
|
||||
border: 1px solid transparent;
|
||||
}
|
||||
|
||||
.linkLabel {
|
||||
cursor: pointer;
|
||||
text-decoration: underline !important;
|
||||
margin-top: 1px;
|
||||
margin-bottom: 2px;
|
||||
-moz-margin-start: 6px;
|
||||
-moz-margin-end: 5px;
|
||||
}
|
||||
|
||||
link > label {
|
||||
margin: 0px;
|
||||
padding: 1px;
|
||||
cursor: inherit;
|
||||
}
|
||||
|
||||
link:hover:active {
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
const nsIUpdateItem = Components.interfaces.nsIUpdateItem;
|
||||
const nsIIncrementalDownload = Components.interfaces.nsIIncrementalDownload;
|
||||
const XMLNS_XUL = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
||||
const PREF_UPDATE_MANUAL_URL = "app.update.manual.url";
|
||||
|
||||
/**
|
||||
* Logs a string to the error console.
|
||||
|
@ -66,6 +67,28 @@ var gUpdates = {
|
|||
document.documentElement.advance();
|
||||
}
|
||||
},
|
||||
|
||||
advanceToErrorPage: function(currentPage, reason) {
|
||||
currentPage.setAttribute("next", "errors");
|
||||
var errorReason = document.getElementById("errorReason");
|
||||
errorReason.value = reason;
|
||||
var errorLink = document.getElementById("errorLink");
|
||||
var pref = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefBranch2);
|
||||
var manualURL = pref.getComplexValue(PREF_UPDATE_MANUAL_URL,
|
||||
Components.interfaces.nsIPrefLocalizedString);
|
||||
errorLink.href = manualURL.data;
|
||||
var errorLinkLabel = document.getElementById("errorLinkLabel");
|
||||
errorLinkLabel.value = manualURL.data;
|
||||
|
||||
var updateStrings = document.getElementById("updateStrings");
|
||||
var pageTitle = updateStrings.getString("errorsPageHeader");
|
||||
|
||||
var errorPage = document.getElementById("errors");
|
||||
errorPage.setAttribute("label", pageTitle);
|
||||
document.documentElement.setAttribute("label", pageTitle);
|
||||
document.documentElement.advance();
|
||||
},
|
||||
}
|
||||
|
||||
var gCheckingPage = {
|
||||
|
@ -202,12 +225,15 @@ var gDownloadingPage = {
|
|||
var updates =
|
||||
Components.classes["@mozilla.org/updates/update-service;1"].
|
||||
getService(Components.interfaces.nsIApplicationUpdateService);
|
||||
LOG("intergoat");
|
||||
updates.downloadUpdate(gUpdates.update, false);
|
||||
updates.addDownloadListener(this);
|
||||
var state = updates.downloadUpdate(gUpdates.update, false);
|
||||
if (state == "failed")
|
||||
this.showVerificationError();
|
||||
else
|
||||
updates.addDownloadListener(this);
|
||||
|
||||
// Build the UI for previously installed updates
|
||||
// ...
|
||||
|
||||
},
|
||||
|
||||
_paused: false,
|
||||
|
@ -257,6 +283,8 @@ var gDownloadingPage = {
|
|||
onStopRequest: function(request, context, status) {
|
||||
request.QueryInterface(nsIIncrementalDownload);
|
||||
LOG("gDownloadingPage.onStopRequest: " + request.URI.spec + ", status = " + status);
|
||||
|
||||
const NS_BINDING_ABORTED = 0x804b0002;
|
||||
var updates =
|
||||
Components.classes["@mozilla.org/updates/update-service;1"]
|
||||
.getService(Components.interfaces.nsIApplicationUpdateService);
|
||||
|
@ -266,11 +294,26 @@ var gDownloadingPage = {
|
|||
// failed, log this and then commence downloading the complete update.
|
||||
LOG("Verification of patch failed, downloading complete update");
|
||||
gUpdates.update.isCompleteUpdate = true;
|
||||
updates.downloadUpdate(gUpdates.update, false);
|
||||
return;
|
||||
var state = updates.downloadUpdate(gUpdates.update, false);
|
||||
if (state == "failed")
|
||||
this.showVerificationError();
|
||||
else
|
||||
return;
|
||||
}
|
||||
else if (status == NS_BINDING_ABORTED) {
|
||||
LOG("Download PAUSED");
|
||||
}
|
||||
updates.removeDownloadListener(this);
|
||||
},
|
||||
|
||||
showVerificationError: function() {
|
||||
var updateStrings = document.getElementById("updateStrings");
|
||||
var brandStrings = document.getElementById("brandStrings");
|
||||
var brandName = brandStrings.getString("brandShortName");
|
||||
var verificationError = updateStrings.getFormattedString("verificationError", [brandName]);
|
||||
var downloadingPage = document.getElementById("downloading");
|
||||
gUpdates.advanceToErrorPage(downloadingPage, verificationError);
|
||||
},
|
||||
|
||||
/**
|
||||
* See nsISupports.idl
|
||||
|
@ -284,3 +327,11 @@ var gDownloadingPage = {
|
|||
}
|
||||
};
|
||||
|
||||
var gErrorsPage = {
|
||||
onPageShow: function() {
|
||||
document.documentElement.getButton("back").disabled = true;
|
||||
document.documentElement.getButton("cancel").disabled = true;
|
||||
document.documentElement.getButton("finish").focus();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -7,10 +7,7 @@
|
|||
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
xmlns:xbl="http://www.mozilla.org/xbl">
|
||||
|
||||
<binding id="link" extends="chrome://global/content/bindings/text.xml#text-base">
|
||||
<content>
|
||||
<xul:label xbl:inherits="value=label,crop" class="linkLabel" flex="1"/>
|
||||
</content>
|
||||
<binding id="link">
|
||||
<implementation>
|
||||
<property name="href"
|
||||
onget="return this.getAttribute('href');"
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
<wizard id="updates"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
title="&updateWizard.title;"
|
||||
label="" description=""
|
||||
windowtype="Update:Wizard" style="width: 36em;"
|
||||
onwizardfinished="gUpdates.onFinish();"
|
||||
onclose="return gUpdates.onClose();"
|
||||
|
@ -123,7 +124,7 @@
|
|||
-->
|
||||
</wizardpage>
|
||||
|
||||
<wizardpage id="downloading" pageid="downloading"
|
||||
<wizardpage id="downloading" pageid="downloading" next="finished"
|
||||
onpageshow="gDownloadingPage.onPageShow();" flex="1">
|
||||
|
||||
<label id="downloadingIntro">&downloading.intro;</label>
|
||||
|
@ -138,4 +139,22 @@
|
|||
</hbox>
|
||||
</wizardpage>
|
||||
|
||||
<wizardpage id="errors" pageid="errors" class="content"
|
||||
onpageshow="gErrorsPage.onPageShow();">
|
||||
<label id="errorIntro">&error.label;</label>
|
||||
<separator/>
|
||||
<textbox class="plain" readonly="true" id="errorReason"/>
|
||||
<separator/>
|
||||
<label id="errorManual">&errorManual.label;</label>
|
||||
<hbox>
|
||||
<link id="errorLink">
|
||||
<label id="errorLinkLabel"/>
|
||||
</link>
|
||||
</hbox>
|
||||
</wizardpage>
|
||||
|
||||
<wizardpage id="finished" pageid="finished" align="start">
|
||||
<label>Finished</label>
|
||||
</wizardpage>
|
||||
|
||||
</wizard>
|
||||
|
|
|
@ -193,7 +193,7 @@ interface nsIApplicationUpdateService : nsISupports
|
|||
/**
|
||||
*
|
||||
*/
|
||||
void downloadUpdate(in nsIUpdate update, in boolean background);
|
||||
AString downloadUpdate(in nsIUpdate update, in boolean background);
|
||||
|
||||
/**
|
||||
* Pauses the active update download process
|
||||
|
|
|
@ -575,7 +575,7 @@ UpdateService.prototype = {
|
|||
this._downloader.cancel();
|
||||
}
|
||||
this._downloader = new Downloader(background);
|
||||
this._downloader.downloadUpdate(update);
|
||||
return this._downloader.downloadUpdate(update);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -719,8 +719,7 @@ Checker.prototype = {
|
|||
|
||||
get _updateURL() {
|
||||
try {
|
||||
//return gPref.getComplexValue(PREF_APP_UPDATE_URL, nsIPrefLocalizedString).data;
|
||||
return gPref.getCharPref(PREF_APP_UPDATE_URL);
|
||||
return gPref.getComplexValue(PREF_APP_UPDATE_URL, nsIPrefLocalizedString).data;
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
|
@ -931,7 +930,7 @@ Downloader.prototype = {
|
|||
function getPatchOfType(type) {
|
||||
for (var i = 0; i < update.patchCount; ++i) {
|
||||
var patch = update.getPatchAt(i);
|
||||
if (patch.type == type)
|
||||
if (patch && patch.type == type)
|
||||
return patch;
|
||||
}
|
||||
return null;
|
||||
|
@ -941,7 +940,7 @@ Downloader.prototype = {
|
|||
function getPatchWithHash(hashvalue) {
|
||||
for (var i = 0; i < update.patchCount; ++i) {
|
||||
var patch = update.getPatchAt(i);
|
||||
if (patch.hashvalue == hashvalue)
|
||||
if (patch && patch.hashvalue == hashvalue)
|
||||
return patch;
|
||||
}
|
||||
return null;
|
||||
|
@ -1060,9 +1059,10 @@ Downloader.prototype = {
|
|||
// This function may return null, which indicates that there are no patches
|
||||
// to download.
|
||||
this._patch = this._selectPatch(update, updateDir);
|
||||
LOG("PATCH = " + this._patch);
|
||||
if (!this._patch) {
|
||||
LOG("no patch to download");
|
||||
return;
|
||||
return this._readStatusFile(updateDir);
|
||||
}
|
||||
this.isCompleteUpdate = this._patch.type == "complete";
|
||||
|
||||
|
@ -1086,6 +1086,7 @@ Downloader.prototype = {
|
|||
this._request.start(this, null);
|
||||
|
||||
this._writeStatusFile(updateDir, STATE_DOWNLOADING);
|
||||
return STATE_DOWNLOADING;
|
||||
},
|
||||
|
||||
_listeners: [],
|
||||
|
|
Загрузка…
Ссылка в новой задаче