From dda60995a31bd35f52ff98c467957106124ccd7b Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Wed, 14 Sep 2022 02:06:33 -0400 Subject: [PATCH] fx-compat: Fix app update dialog Styling needs to be redone, but it works. --- .../content/zotero/standalone/standalone.js | 2 +- chrome/content/zotero/update/update-header.js | 35 +++++++++++ chrome/content/zotero/update/updates.js | 56 ++++++------------ .../update/{updates.xul => updates.xhtml} | 58 ++++++++++--------- chrome/content/zotero/update/updates.xml | 22 ------- 5 files changed, 85 insertions(+), 88 deletions(-) create mode 100644 chrome/content/zotero/update/update-header.js rename chrome/content/zotero/update/{updates.xul => updates.xhtml} (80%) delete mode 100644 chrome/content/zotero/update/updates.xml diff --git a/chrome/content/zotero/standalone/standalone.js b/chrome/content/zotero/standalone/standalone.js index 6870862ab2..61b531af4f 100644 --- a/chrome/content/zotero/standalone/standalone.js +++ b/chrome/content/zotero/standalone/standalone.js @@ -688,7 +688,7 @@ const ZoteroStandalone = new function() { * Checks for updates */ this.checkForUpdates = function() { - window.open('chrome://mozapps/content/update/updates.xul', 'updateChecker', 'chrome,centerscreen'); + window.open('chrome://zotero/content/update/updates.xhtml', 'updateChecker', 'chrome,centerscreen'); } /** diff --git a/chrome/content/zotero/update/update-header.js b/chrome/content/zotero/update/update-header.js new file mode 100644 index 0000000000..d6bc737050 --- /dev/null +++ b/chrome/content/zotero/update/update-header.js @@ -0,0 +1,35 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +"use strict"; + +{ + Services.scriptloader.loadSubScript("chrome://zotero/content/elements/base.js", this); + const XULElementBaseMixin = MozElements.MozElementMixin(XULElementBase); + + class UpdateHeader extends XULElementBaseMixin { + content = MozXULElement.parseXULToFragment(` + + + + + + + `); + + static get inheritedAttributes() { + return { + ".wizard-header-label": "value=label", + }; + } + + connectedCallback() { + super.connectedCallback(); + this.initializeAttributeInheritance(); + } + } + + customElements.define("update-header", UpdateHeader); +} diff --git a/chrome/content/zotero/update/updates.js b/chrome/content/zotero/update/updates.js index d1d18285c4..c48d55bbd3 100644 --- a/chrome/content/zotero/update/updates.js +++ b/chrome/content/zotero/update/updates.js @@ -8,21 +8,14 @@ /* import-globals-from ../../../content/contentAreaUtils.js */ /* globals DownloadUtils, Services, AUSTLMY */ -ChromeUtils.import("resource://gre/modules/DownloadUtils.jsm", this); -ChromeUtils.import("resource://gre/modules/Services.jsm", this); -ChromeUtils.import("resource://gre/modules/UpdateTelemetry.jsm", this); -ChromeUtils.defineModuleGetter( - this, - "UpdateUtils", - "resource://gre/modules/UpdateUtils.jsm" -); +const { Zotero } = ChromeUtils.import("chrome://zotero/content/include.jsm"); -XPCOMUtils.defineLazyServiceGetter( - this, - "gAUS", - "@mozilla.org/updates/update-service;1", - "nsIApplicationUpdateService" +const { DownloadUtils } = ChromeUtils.import( + "resource://gre/modules/DownloadUtils.jsm" ); +const { UpdateUtils } = ChromeUtils.import("resource://gre/modules/UpdateUtils.jsm"); + +const gAUS = Cc["@mozilla.org/updates/update-service;1"].getService(Ci.nsIApplicationUpdateService); const XMLNS_XUL = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; @@ -35,7 +28,7 @@ const PREF_APP_UPDATE_NOTIFIEDUNSUPPORTED = "app.update.notifiedUnsupported"; const PREF_APP_UPDATE_URL_MANUAL = "app.update.url.manual"; const URI_UPDATES_PROPERTIES = - "chrome://mozapps/locale/update/updates.properties"; + "chrome://zotero/locale/mozilla/updates.properties"; const STATE_DOWNLOADING = "downloading"; const STATE_PENDING = "pending"; @@ -72,10 +65,7 @@ var gUpdatesFoundPageId; * The string to write to the error console.. */ function LOG(module, string) { - if (gLogEnabled) { - dump("*** AUS:UI " + module + ":" + string + "\n"); - Services.console.logStringMessage("AUS:UI " + module + ":" + string); - } + Zotero.debug("AUS:UI " + module + ":" + string); } /** @@ -120,15 +110,6 @@ var gUpdates = { */ _runUnload: true, - /** - * Submit on close telemtry values for the update wizard. - * @param pageID - * The page id for the last page displayed. - */ - _submitTelemetry(aPageID) { - AUSTLMY.pingWizLastPageCode(aPageID); - }, - /** * Helper function for setButtons * Resets button to original label & accesskey if string is null. @@ -247,11 +228,10 @@ var gUpdates = { */ onWizardFinish() { this._runUnload = false; - var pageid = document.documentElement.currentPage.pageid; + var pageid = document.querySelector('wizard').currentPage.pageid; if ("onWizardFinish" in this._pages[pageid]) { this._pages[pageid].onWizardFinish(); } - this._submitTelemetry(pageid); }, /** @@ -260,11 +240,10 @@ var gUpdates = { */ onWizardCancel() { this._runUnload = false; - var pageid = document.documentElement.currentPage.pageid; + var pageid = document.querySelector('wizard').currentPage.pageid; if ("onWizardCancel" in this._pages[pageid]) { this._pages[pageid].onWizardCancel(); } - this._submitTelemetry(pageid); }, /** @@ -272,7 +251,7 @@ var gUpdates = { * the function call to the selected page. */ onWizardNext() { - var cp = document.documentElement.currentPage; + var cp = document.querySelector('wizard').currentPage; if (!cp) { return; } @@ -310,7 +289,7 @@ var gUpdates = { * Called when the wizard UI is loaded. */ onLoad() { - this.wiz = document.documentElement; + this.wiz = document.querySelector('wizard'); gLogEnabled = Services.prefs.getBoolPref(PREF_APP_UPDATE_LOG, false); @@ -427,6 +406,9 @@ var gUpdates = { gFinishedPage.onExtra2(); }); + // Hide default wizard header ("Introduction") + gUpdates.wiz.shadowRoot.querySelector('.wizard-header').hidden = true; + // Advance to the Start page. this.getStartPageID(function(startPageID) { LOG( @@ -633,8 +615,8 @@ var gCheckingPage = { /** * See nsIUpdateCheckListener */ - onCheckComplete(request, updates, updateCount) { - gUpdates.setUpdate(gAUS.selectUpdate(updates, updates.length)); + async onCheckComplete(request, updates) { + gUpdates.setUpdate(gAUS.selectUpdate(updates)); if (gUpdates.update) { LOG("gCheckingPage", "onCheckComplete - update found"); if (gUpdates.update.unsupported) { @@ -666,7 +648,7 @@ var gCheckingPage = { /** * See nsIUpdateCheckListener */ - onError(request, update) { + async onError(request, update) { LOG("gCheckingPage", "onError - proceeding to error page"); gUpdates.setUpdate(update); gUpdates.wiz.goTo("errors"); @@ -1210,7 +1192,7 @@ var gErrorExtraPage = { Services.prefs.clearUserPref(PREF_APP_UPDATE_BACKGROUNDERRORS); } - document.getElementById("genericBackgroundErrorLabel").hidden = false; + document.getElementById("bgErrorLabel").hidden = false; let manualURL = Services.urlFormatter.formatURLPref( PREF_APP_UPDATE_URL_MANUAL ); diff --git a/chrome/content/zotero/update/updates.xul b/chrome/content/zotero/update/updates.xhtml similarity index 80% rename from chrome/content/zotero/update/updates.xul rename to chrome/content/zotero/update/updates.xhtml index b7ef25e4b3..c8a0474df9 100644 --- a/chrome/content/zotero/update/updates.xul +++ b/chrome/content/zotero/update/updates.xhtml @@ -5,20 +5,16 @@ - file, You can obtain one at http://mozilla.org/MPL/2.0/. --> - - + + %updateDTD; %brandDTD; -#if defined(XP_MACOSX) && MOZ_BUILD_APP == browser -#include ../../../../browser/base/content/browser-doctype.inc -#endif ]> - -