summaryrefslogtreecommitdiff
path: root/application
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@wolfbeast.com>2019-02-12 16:13:57 +0100
committerwolfbeast <mcwerewolf@wolfbeast.com>2019-02-12 16:13:57 +0100
commitdd418226c6a91301002134f699117ba00f1e0804 (patch)
treef3cd6bb7ed885199bb60e54ca09f0b19951fc32c /application
parent487afe9f45a846daaf8aab8b0cc0022dbc92ce09 (diff)
downloaduxp-dd418226c6a91301002134f699117ba00f1e0804.tar.gz
Add "check for updates" to main menu and AppMenu v2
Tag #963.
Diffstat (limited to 'application')
-rw-r--r--application/palemoon/base/content/baseMenuOverlay.xul10
-rw-r--r--application/palemoon/base/content/browser-appmenu.inc9
-rw-r--r--application/palemoon/base/content/utilityOverlay.js111
-rw-r--r--application/palemoon/locales/en-US/chrome/browser/baseMenuOverlay.dtd1
-rw-r--r--application/palemoon/locales/en-US/chrome/browser/browser.properties16
5 files changed, 145 insertions, 2 deletions
diff --git a/application/palemoon/base/content/baseMenuOverlay.xul b/application/palemoon/base/content/baseMenuOverlay.xul
index e9019dc55c..d7c9836711 100644
--- a/application/palemoon/base/content/baseMenuOverlay.xul
+++ b/application/palemoon/base/content/baseMenuOverlay.xul
@@ -41,7 +41,7 @@
label="&helpMenu.label;"
accesskey="&helpMenu.accesskey;">
#endif
- <menupopup id="menu_HelpPopup">
+ <menupopup id="menu_HelpPopup" onpopupshowing="buildHelpMenu();">
<menuitem id="menu_openHelp"
oncommand="openHelpLink('firefox-help')"
onclick="checkForMiddleClick(this, event);"
@@ -66,6 +66,14 @@
accesskey="&helpSafeMode.accesskey;"
label="&helpSafeMode.label;"
oncommand="restart(true);"/>
+ <menuseparator id="updateSeparator"/>
+ <menuitem id="checkForUpdates" class="menuitem-iconic"
+#ifdef MOZ_UPDATER
+ label="&updateCmd.label;"
+ oncommand="checkForUpdates();"/>
+#else
+ hidden="true"/>
+#endif
<menuseparator id="aboutSeparator"/>
<menuitem id="aboutName"
accesskey="&aboutProduct.accesskey;"
diff --git a/application/palemoon/base/content/browser-appmenu.inc b/application/palemoon/base/content/browser-appmenu.inc
index cfc855484a..ffb117a605 100644
--- a/application/palemoon/base/content/browser-appmenu.inc
+++ b/application/palemoon/base/content/browser-appmenu.inc
@@ -341,7 +341,7 @@
<splitmenu id="appmenu_help"
label="&helpMenu.label;"
oncommand="openHelpLink('firefox-help')">
- <menupopup id="appmenu_helpMenupopup">
+ <menupopup id="appmenu_helpMenupopup" onpopupshowing="buildHelpMenu();">
<menuitem id="appmenu_openHelp"
label="&helpMenu.label;"
oncommand="openHelpLink('firefox-help')"
@@ -358,6 +358,13 @@
<menuitem id="appmenu_safeMode"
label="&appMenuSafeMode.label;"
oncommand="restart(true);"/>
+#ifdef MOZ_UPDATER
+ <menuseparator/>
+ <menuitem id="appmenu_checkForUpdates"
+ class="menuitem-iconic"
+ label="&updateCmd.label;"
+ oncommand="checkForUpdates();"/>
+#endif
<menuseparator/>
<menuitem id="appmenu_about"
label="&aboutProduct.label;"
diff --git a/application/palemoon/base/content/utilityOverlay.js b/application/palemoon/base/content/utilityOverlay.js
index 2c1a95f83c..fe148ad04a 100644
--- a/application/palemoon/base/content/utilityOverlay.js
+++ b/application/palemoon/base/content/utilityOverlay.js
@@ -541,6 +541,117 @@ function isBidiEnabled() {
return rv;
}
+#ifdef MOZ_UPDATER
+/**
+ * Opens the update manager and checks for updates to the application.
+ */
+function checkForUpdates()
+{
+ var um =
+ Components.classes["@mozilla.org/updates/update-manager;1"].
+ getService(Components.interfaces.nsIUpdateManager);
+ var prompter =
+ Components.classes["@mozilla.org/updates/update-prompt;1"].
+ createInstance(Components.interfaces.nsIUpdatePrompt);
+
+ // If there's an update ready to be applied, show the "Update Downloaded"
+ // UI instead and let the user know they have to restart the application for
+ // the changes to be applied.
+ if (um.activeUpdate && um.activeUpdate.state == "pending")
+ prompter.showUpdateDownloaded(um.activeUpdate);
+ else
+ prompter.checkForUpdates();
+}
+#endif
+
+/**
+ * Set up the help menu software update items to show proper status,
+ * also disabling the items if update is disabled.
+ */
+function buildHelpMenu()
+{
+#ifdef MOZ_UPDATER
+ var updates =
+ Components.classes["@mozilla.org/updates/update-service;1"].
+ getService(Components.interfaces.nsIApplicationUpdateService);
+ var um =
+ Components.classes["@mozilla.org/updates/update-manager;1"].
+ getService(Components.interfaces.nsIUpdateManager);
+
+ // Disable the UI if the update enabled pref has been locked by the
+ // administrator or if we cannot update for some other reason.
+ var checkForUpdates = document.getElementById("checkForUpdates");
+ var appMenuCheckForUpdates = document.getElementById("appmenu_checkForUpdates");
+ var canCheckForUpdates = updates.canCheckForUpdates;
+ checkForUpdates.setAttribute("disabled", !canCheckForUpdates);
+ appMenuCheckForUpdates.setAttribute("disabled", !canCheckForUpdates);
+ if (!canCheckForUpdates)
+ return;
+
+ var strings = document.getElementById("bundle_browser");
+ var activeUpdate = um.activeUpdate;
+
+ // If there's an active update, substitute its name into the label
+ // we show for this item, otherwise display a generic label.
+ function getStringWithUpdateName(key) {
+ if (activeUpdate && activeUpdate.name)
+ return strings.getFormattedString(key, [activeUpdate.name]);
+ return strings.getString(key + "Fallback");
+ }
+
+ // By default, show "Check for Updates..." from updatesItem_default or
+ // updatesItem_defaultFallback
+ var key = "default";
+ if (activeUpdate) {
+ switch (activeUpdate.state) {
+ case "downloading":
+ // If we're downloading an update at present, show the text:
+ // "Downloading Thunderbird x.x..." from updatesItem_downloading or
+ // updatesItem_downloadingFallback, otherwise we're paused, and show
+ // "Resume Downloading Thunderbird x.x..." from updatesItem_resume or
+ // updatesItem_resumeFallback
+ key = updates.isDownloading ? "downloading" : "resume";
+ break;
+ case "pending":
+ // If we're waiting for the user to restart, show: "Apply Downloaded
+ // Updates Now..." from updatesItem_pending or
+ // updatesItem_pendingFallback
+ key = "pending";
+ break;
+ }
+ }
+
+ checkForUpdates.label = getStringWithUpdateName("updatesItem_" + key);
+ appMenuCheckForUpdates.label = getStringWithUpdateName("updatesItem_" + key);
+ // updatesItem_default.accesskey, updatesItem_downloading.accesskey,
+ // updatesItem_resume.accesskey or updatesItem_pending.accesskey
+ checkForUpdates.accessKey = strings.getString("updatesItem_" + key +
+ ".accesskey");
+ appMenuCheckForUpdates.accessKey = strings.getString("updatesItem_" + key +
+ ".accesskey");
+ if (um.activeUpdate && updates.isDownloading) {
+ checkForUpdates.setAttribute("loading", "true");
+ appMenuCheckForUpdates.setAttribute("loading", "true");
+ } else {
+ checkForUpdates.removeAttribute("loading");
+ appMenuCheckForUpdates.removeAttribute("loading");
+ }
+#else
+#ifndef XP_MACOSX
+ // Some extensions may rely on these being present so only hide the about
+ // separator when there are no elements besides the check for updates menuitem
+ // in between the about separator and the updates separator.
+ var updatesSeparator = document.getElementById("updatesSeparator");
+ var aboutSeparator = document.getElementById("aboutSeparator");
+ var checkForUpdates = document.getElementById("checkForUpdates");
+ if (updatesSeparator.nextSibling === checkForUpdates &&
+ checkForUpdates.nextSibling === aboutSeparator)
+ updatesSeparator.hidden = true;
+#endif
+#endif
+}
+
+
function openAboutDialog() {
var enumerator = Services.wm.getEnumerator("Browser:About");
while (enumerator.hasMoreElements()) {
diff --git a/application/palemoon/locales/en-US/chrome/browser/baseMenuOverlay.dtd b/application/palemoon/locales/en-US/chrome/browser/baseMenuOverlay.dtd
index a926b0ed24..27de3797f3 100644
--- a/application/palemoon/locales/en-US/chrome/browser/baseMenuOverlay.dtd
+++ b/application/palemoon/locales/en-US/chrome/browser/baseMenuOverlay.dtd
@@ -14,6 +14,7 @@
for the help button in the menubar but Gnome does not. -->
<!ENTITY helpMenuWin.label "Help">
<!ENTITY helpMenuWin.accesskey "H">
+<!ENTITY updateCmd.label "Check for Updates…">
<!ENTITY aboutProduct.label "About &brandShortName;">
<!ENTITY aboutProduct.accesskey "A">
<!ENTITY productHelp.label "&brandShortName; Help">
diff --git a/application/palemoon/locales/en-US/chrome/browser/browser.properties b/application/palemoon/locales/en-US/chrome/browser/browser.properties
index dbe6dbaa1a..0144af0c79 100644
--- a/application/palemoon/locales/en-US/chrome/browser/browser.properties
+++ b/application/palemoon/locales/en-US/chrome/browser/browser.properties
@@ -201,6 +201,22 @@ update.openUpdateUI.upgradeButton.accesskey=U
update.restart.upgradeButton.label=Upgrade Now
update.restart.upgradeButton.accesskey=U
+# Check for Updates in the Help Menu
+# LOCALIZATION NOTE (updatesItem_*): these are alternative labels for Check for Update item in Help menu.
+# Which one is used depends on Update process state.
+updatesItem_default=Check for Updates…
+updatesItem_defaultFallback=Check for Updates…
+updatesItem_default.accesskey=C
+updatesItem_downloading=Downloading %S…
+updatesItem_downloadingFallback=Downloading Update…
+updatesItem_downloading.accesskey=D
+updatesItem_resume=Resume Downloading %S…
+updatesItem_resumeFallback=Resume Downloading Update…
+updatesItem_resume.accesskey=D
+updatesItem_pending=Apply Downloaded Update Now…
+updatesItem_pendingFallback=Apply Downloaded Update Now…
+updatesItem_pending.accesskey=D
+
# RSS Pretty Print
feedShowFeedNew=Subscribe to '%S'…