summaryrefslogtreecommitdiffstats
path: root/application/palemoon/base/content/utilityOverlay.js
diff options
context:
space:
mode:
Diffstat (limited to 'application/palemoon/base/content/utilityOverlay.js')
-rw-r--r--application/palemoon/base/content/utilityOverlay.js133
1 files changed, 117 insertions, 16 deletions
diff --git a/application/palemoon/base/content/utilityOverlay.js b/application/palemoon/base/content/utilityOverlay.js
index 2c1a95f83..c2a8baeed 100644
--- a/application/palemoon/base/content/utilityOverlay.js
+++ b/application/palemoon/base/content/utilityOverlay.js
@@ -75,16 +75,6 @@ function openTopWin(url) {
openUILinkIn(url, "current");
}
-function getBoolPref(prefname, def)
-{
- try {
- return Services.prefs.getBoolPref(prefname);
- }
- catch(er) {
- return def;
- }
-}
-
/* openUILink handles clicks on UI elements that cause URLs to load.
*
* As the third argument, you may pass an object with the same properties as
@@ -151,7 +141,7 @@ function whereToOpenLink( e, ignoreButton, ignoreAlt )
// ignoreButton allows "middle-click paste" to use function without always opening in a new window.
var middle = !ignoreButton && e.button == 1;
- var middleUsesTabs = getBoolPref("browser.tabs.opentabfor.middleclick", true);
+ var middleUsesTabs = Services.prefs.getBoolPref("browser.tabs.opentabfor.middleclick", true);
// Don't do anything special with right-mouse clicks. They're probably clicks on context menu items.
@@ -162,7 +152,7 @@ function whereToOpenLink( e, ignoreButton, ignoreAlt )
#endif
return shift ? "tabshifted" : "tab";
- if (alt && getBoolPref("browser.altClickSave", false))
+ if (alt && Services.prefs.getBoolPref("browser.altClickSave", false))
return "save";
if (shift || (middle && !middleUsesTabs))
@@ -334,7 +324,7 @@ function openLinkIn(url, where, params) {
if (loadInBackground == null) {
loadInBackground = aFromChrome ?
false :
- getBoolPref("browser.tabs.loadInBackground");
+ Services.prefs.getBoolPref("browser.tabs.loadInBackground");
}
let uriObj;
@@ -515,7 +505,7 @@ function getShellService()
function isBidiEnabled() {
// first check the pref.
- if (getBoolPref("bidi.browser.ui", false))
+ if (Services.prefs.getBoolPref("bidi.browser.ui", false))
return true;
// if the pref isn't set, check for an RTL locale and force the pref to true
@@ -541,6 +531,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()) {
@@ -562,7 +663,7 @@ function openAboutDialog() {
function openPreferences(paneID, extraArgs)
{
- var instantApply = getBoolPref("browser.preferences.instantApply", false);
+ var instantApply = Services.prefs.getBoolPref("browser.preferences.instantApply", false);
var features = "chrome,titlebar,toolbar,centerscreen" + (instantApply ? ",dialog=no" : ",modal");
var win = Services.wm.getMostRecentWindow("Browser:Preferences");
@@ -743,7 +844,7 @@ function openHelpLink(aHelpTopic, aCalledFromModal) {
function openPrefsHelp() {
// non-instant apply prefwindows are usually modal, so we can't open in the topmost window,
// since its probably behind the window.
- var instantApply = getBoolPref("browser.preferences.instantApply");
+ var instantApply = Services.prefs.getBoolPref("browser.preferences.instantApply");
var helpTopic = document.getElementsByTagName("prefwindow")[0].currentPane.helpTopic;
openHelpLink(helpTopic, !instantApply);