Bug 1553982 Part 4 - Display a prompt when waiting for the update lock expires. r=bytesized,fluent-reviewers,flod

Differential Revision: https://phabricator.services.mozilla.com/D95629
This commit is contained in:
Molly Howell 2020-12-10 22:13:11 +00:00
Родитель 2dbe4960b4
Коммит 7bfd39732a
9 изменённых файлов: 77 добавлений и 24 удалений

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

@ -154,6 +154,20 @@
</popupnotificationcontent>
</popupnotification>
<popupnotification id="appMenu-update-other-instance-notification"
popupid="update-other-instance"
data-lazy-l10n-id="appmenu-update-other-instance"
data-l10n-attrs="buttonlabel, buttonaccesskey, secondarybuttonlabel, secondarybuttonaccesskey"
closebuttonhidden="true"
dropmarkerhidden="true"
checkboxhidden="true"
buttonhighlight="true"
hidden="true">
<popupnotificationcontent id="update-other-instance-notification-content" orient="vertical">
<description id="update-other-instance-description" data-lazy-l10n-id="appmenu-update-other-instance-message"></description>
</popupnotificationcontent>
</popupnotification>
<popupnotification id="appMenu-addon-installed-notification"
popupid="addon-installed"
closebuttonhidden="true"

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

@ -32,6 +32,14 @@ appmenu-update-restart =
.secondarybuttonlabel = Not Now
.secondarybuttonaccesskey = N
appmenu-update-restart-message = After a quick restart, { -brand-shorter-name } will restore all your open tabs and windows that are not in Private Browsing mode.
appmenu-update-other-instance =
.label = { -brand-shorter-name } is unable to automatically update to the latest version.
.buttonlabel = Update { -brand-shorter-name } anyway
.buttonaccesskey = U
.secondarybuttonlabel = Not Now
.secondarybuttonaccesskey = N
appmenu-update-other-instance-message = A new { -brand-shorter-name } update is available, but it cant be installed because another copy of { -brand-shorter-name } is running. Close it to continue the update, or choose to update anyway (the other copy may not work correctly until you restart it).
appmenu-addon-private-browsing-installed =
.buttonlabel = Okay, Got It
.buttonaccesskey = O

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

@ -330,7 +330,18 @@ class AppUpdater {
case Cr.NS_OK:
this.aus.removeDownloadListener(this);
if (this.updateStagingEnabled) {
this._setStatus(AppUpdater.STATUS.STAGING);
// It could be that another instance was started during the download,
// and if that happened, then we actually should not advance to the
// STAGING status because the staging process isn't really happening
// until that instance exits (or we time out waiting).
if (this.aus.isOtherInstanceHandlingUpdates) {
this._setStatus(AppUpdater.OTHER_INSTANCE_HANDLING_UPDATES);
} else {
this._setStatus(AppUpdater.STATUS.STAGING);
}
// But we should register the staging observer in either case, because
// if we do time out waiting for the other instance to exit, then
// staging really will start at that point.
this._awaitStagingComplete();
} else {
this._awaitDownloadComplete();

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

@ -63,6 +63,7 @@
#PanelUI-menu-button[badge-status="update-available"] > .toolbarbutton-badge-stack > .toolbarbutton-badge,
#PanelUI-menu-button[badge-status="update-downloading"] > .toolbarbutton-badge-stack > .toolbarbutton-badge,
#PanelUI-menu-button[badge-status="update-manual"] > .toolbarbutton-badge-stack > .toolbarbutton-badge,
#PanelUI-menu-button[badge-status="update-other-instance"] > .toolbarbutton-badge-stack > .toolbarbutton-badge,
#PanelUI-menu-button[badge-status="update-restart"] > .toolbarbutton-badge-stack > .toolbarbutton-badge,
#PanelUI-menu-button[badge-status="update-unsupported"] > .toolbarbutton-badge-stack > .toolbarbutton-badge {
border-radius: 50%;
@ -77,6 +78,7 @@
#PanelUI-menu-button[badge-status="update-available"] > .toolbarbutton-badge-stack > .toolbarbutton-badge,
#PanelUI-menu-button[badge-status="update-downloading"] > .toolbarbutton-badge-stack > .toolbarbutton-badge,
#PanelUI-menu-button[badge-status="update-manual"] > .toolbarbutton-badge-stack > .toolbarbutton-badge,
#PanelUI-menu-button[badge-status="update-other-instance"] > .toolbarbutton-badge-stack > .toolbarbutton-badge,
#PanelUI-menu-button[badge-status="update-restart"] > .toolbarbutton-badge-stack > .toolbarbutton-badge {
background: #74BF43 url(chrome://browser/skin/update-badge.svg) no-repeat center;
}
@ -88,6 +90,7 @@
.panel-banner-item[notificationid="update-available"]::after,
.panel-banner-item[notificationid="update-downloading"]::after,
.panel-banner-item[notificationid="update-manual"]::after,
.panel-banner-item[notificationid="update-other-instance"]::after,
.panel-banner-item[notificationid="update-restart"]::after {
background: #74BF43 url(chrome://browser/skin/update-badge.svg) no-repeat center;
border-radius: 50%;

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

@ -415,6 +415,7 @@ html|*#webRTC-previewVideo {
.popup-notification-icon[popupid="update-available"],
.popup-notification-icon[popupid="update-downloading"],
.popup-notification-icon[popupid="update-manual"],
.popup-notification-icon[popupid="update-other-instance"],
.popup-notification-icon[popupid="update-restart"] {
background: #74BF43 url(chrome://browser/skin/notification-icons/update.svg) no-repeat center;
border-radius: 50%;

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

@ -302,6 +302,7 @@ toolbar[brighttext] {
#PanelUI-menu-button[badge-status="update-available"],
#PanelUI-menu-button[badge-status="update-downloading"],
#PanelUI-menu-button[badge-status="update-manual"],
#PanelUI-menu-button[badge-status="update-other-instance"],
#PanelUI-menu-button[badge-status="update-restart"] {
list-style-image: url("chrome://browser/skin/menu-badged.svg");
}

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

@ -6778,10 +6778,10 @@
"alert_emails": ["application-update-telemetry-alerts@mozilla.com", "bytesized@mozilla.com"],
"expires_in_version": "never",
"kind": "categorical",
"bug_numbers": [893505, 1521427],
"bug_numbers": [893505, 1521427, 1553982],
"releaseChannelCollection": "opt-out",
"description": "Update: the application update doorhanger type that was displayed.",
"labels": ["restart", "available", "manual", "unsupported"]
"labels": ["restart", "available", "manual", "unsupported", "otherinstance"]
},
"UPDATE_NOTIFICATION_BADGE_SHOWN": {
"record_in_processes": ["main"],
@ -6789,10 +6789,10 @@
"alert_emails": ["application-update-telemetry-alerts@mozilla.com", "bytesized@mozilla.com"],
"expires_in_version": "never",
"kind": "categorical",
"bug_numbers": [893505, 1365204, 1521427],
"bug_numbers": [893505, 1365204, 1521427, 1553982],
"releaseChannelCollection": "opt-out",
"description": "Update: the application update badge type that was displayed.",
"labels": ["restart", "available", "manual", "unsupported"]
"labels": ["restart", "available", "manual", "unsupported", "otherinstance"]
},
"UPDATE_NOTIFICATION_DISMISSED": {
"record_in_processes": ["main"],
@ -6800,10 +6800,10 @@
"alert_emails": ["application-update-telemetry-alerts@mozilla.com", "bytesized@mozilla.com"],
"expires_in_version": "never",
"kind": "categorical",
"bug_numbers": [893505, 1521427],
"bug_numbers": [893505, 1521427, 1553982],
"releaseChannelCollection": "opt-out",
"description": "Update: the dismiss action was executed for this application update doorhanger type.",
"labels": ["restart", "available", "manual", "unsupported"]
"labels": ["restart", "available", "manual", "unsupported", "otherinstance"]
},
"UPDATE_NOTIFICATION_MAIN_ACTION_DOORHANGER": {
"record_in_processes": ["main"],
@ -6811,10 +6811,10 @@
"alert_emails": ["application-update-telemetry-alerts@mozilla.com", "bytesized@mozilla.com"],
"expires_in_version": "never",
"kind": "categorical",
"bug_numbers": [893505, 1521427],
"bug_numbers": [893505, 1521427, 1553982],
"releaseChannelCollection": "opt-out",
"description": "Update: the main update action was initiated for this application update doorhanger type.",
"labels": ["restart", "available", "manual", "unsupported"]
"labels": ["restart", "available", "manual", "unsupported", "otherinstance"]
},
"UPDATE_NOTIFICATION_MAIN_ACTION_MENU": {
"record_in_processes": ["main"],
@ -6822,10 +6822,10 @@
"alert_emails": ["application-update-telemetry-alerts@mozilla.com", "bytesized@mozilla.com"],
"expires_in_version": "never",
"kind": "categorical",
"bug_numbers": [893505, 1521427],
"bug_numbers": [893505, 1521427, 1553982],
"releaseChannelCollection": "opt-out",
"description": "Update: the update action was initiated from the PanelUI application update menu item.",
"labels": ["restart", "available", "manual", "unsupported"]
"labels": ["restart", "available", "manual", "unsupported", "otherinstance"]
},
"UPDATE_CAN_USE_BITS_EXTERNAL": {
"record_in_processes": ["main"],

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

@ -10,6 +10,9 @@ const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { clearTimeout, setTimeout } = ChromeUtils.import(
"resource://gre/modules/Timer.jsm"
);
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
ChromeUtils.defineModuleGetter(
this,
@ -17,6 +20,13 @@ ChromeUtils.defineModuleGetter(
"resource://gre/modules/AppMenuNotifications.jsm"
);
XPCOMUtils.defineLazyServiceGetter(
this,
"AppUpdateService",
"@mozilla.org/updates/update-service;1",
"nsIApplicationUpdateService"
);
const PREF_APP_UPDATE_UNSUPPORTED_URL = "app.update.unsupported.url";
// Setup the hamburger button badges for updates.
@ -29,7 +39,7 @@ var UpdateListener = {
init() {
// Persist the unsupported notification across sessions. If at some point an
// update is found this pref is cleared and the notifcation won't be shown.
// update is found this pref is cleared and the notification won't be shown.
let url = Services.prefs.getCharPref(PREF_APP_UPDATE_UNSUPPORTED_URL, null);
if (url) {
this.showUpdateNotification("unsupported", true, true, win =>
@ -116,7 +126,9 @@ var UpdateListener = {
const addTelemetry = id => {
// No telemetry for the "downloading" state.
if (type !== "downloading") {
Services.telemetry.getHistogramById(id).add(type);
// Histogram category labels can't have dashes in them.
let telemetryType = type.replaceAll("-", "");
Services.telemetry.getHistogramById(id).add(telemetryType);
}
};
let action = {
@ -150,8 +162,11 @@ var UpdateListener = {
}
},
showRestartNotification(dismissed) {
this.showUpdateNotification("restart", true, dismissed, () =>
showRestartNotification(update, dismissed) {
let notification = AppUpdateService.isOtherInstanceHandlingUpdates
? "other-instance"
: "restart";
this.showUpdateNotification(notification, true, dismissed, () =>
this.requestRestart()
);
},
@ -162,10 +177,7 @@ var UpdateListener = {
false,
dismissed,
() => {
let updateService = Cc[
"@mozilla.org/updates/update-service;1"
].getService(Ci.nsIApplicationUpdateService);
updateService.downloadUpdate(update, true);
AppUpdateService.downloadUpdate(update, true);
},
doc => this.replaceReleaseNotes(doc, update, "updateAvailableWhatsNew")
);
@ -253,19 +265,22 @@ var UpdateListener = {
if (badgeWaitTimeMs < doorhangerWaitTimeMs) {
this.addTimeout(badgeWaitTimeMs, () => {
this.showRestartNotification(true);
// Skip the badge if we're waiting for another instance.
if (!AppUpdateService.isOtherInstanceHandlingUpdates) {
this.showRestartNotification(update, true);
}
// doorhangerWaitTimeMs is relative to when we initially received
// the event. Since we've already waited badgeWaitTimeMs, subtract
// that from doorhangerWaitTimeMs.
let remainingTime = doorhangerWaitTimeMs - badgeWaitTimeMs;
this.addTimeout(remainingTime, () => {
this.showRestartNotification(false);
this.showRestartNotification(update, false);
});
});
} else {
this.addTimeout(doorhangerWaitTimeMs, () => {
this.showRestartNotification(false);
this.showRestartNotification(update, false);
});
}
break;

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

@ -4008,7 +4008,7 @@ UpdateManager.prototype = {
/**
* See nsIUpdateService.idl
*/
refreshUpdateStatus: function UM_refreshUpdateStatus() {
refreshUpdateStatus: async function UM_refreshUpdateStatus() {
var update = this._readyUpdate;
if (!update) {
return;
@ -5707,7 +5707,7 @@ Downloader.prototype = {
let update = this._update;
promiseLangPacksUpdated(update).then(() => {
LOG(
"UpdateManager:refreshUpdateStatus - Notifying observers that " +
"Downloader:onStopRequest - Notifying observers that " +
"an update was downloaded. topic: update-downloaded, status: " +
update.state
);