www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 6e4eb61694b1068817c92aef644723a05003a2f3
parent 83529340093673a28982158e9cf7dfdd1fbb3329
Author: Dan Stillman <dstillman@zotero.org>
Date:   Mon, 25 May 2015 21:57:16 -0400

Merge pull request #673 from sendecomp/optional-proxy-redirect-notification

Add an option to not show the proxy redirection notification
Diffstat:
Mchrome/content/zotero/preferences/preferences_firefox.xul | 2++
Mchrome/content/zotero/preferences/preferences_proxies.js | 6+++++-
Mchrome/content/zotero/xpcom/proxy.js | 45++++++++++++++++++++++++++++++++-------------
Mchrome/locale/en-US/zotero/preferences.dtd | 1+
Mchrome/locale/en-US/zotero/zotero.properties | 1+
Mdefaults/preferences/zotero.js | 1+
6 files changed, 42 insertions(+), 14 deletions(-)

diff --git a/chrome/content/zotero/preferences/preferences_firefox.xul b/chrome/content/zotero/preferences/preferences_firefox.xul @@ -53,6 +53,8 @@ <vbox style="margin-left: 1em"> <checkbox id="zotero-proxies-autoRecognize" label="&zotero.preferences.proxies.autoRecognize;" command="zotero-proxies-update"/> + <checkbox id="zotero-proxies-showRedirectNotification" label="&zotero.preferences.proxies.showRedirectNotification;" + command="zotero-proxies-update"/> <hbox style="display: block; line-height: 1.75em"> <checkbox id="zotero-proxies-disableByDomain-checkbox" label="&zotero.preferences.proxies.disableByDomain;" diff --git a/chrome/content/zotero/preferences/preferences_proxies.js b/chrome/content/zotero/preferences/preferences_proxies.js @@ -40,6 +40,7 @@ Zotero_Preferences.Proxies = { var transparent = document.getElementById('zotero-proxies-transparent').checked; Zotero.Prefs.set("proxies.transparent", transparent); Zotero.Prefs.set("proxies.autoRecognize", document.getElementById('zotero-proxies-autoRecognize').checked); + Zotero.Prefs.set("proxies.showRedirectNotification", document.getElementById('zotero-proxies-showRedirectNotification').checked); Zotero.Prefs.set("proxies.disableByDomainString", document.getElementById('zotero-proxies-disableByDomain-textbox').value); Zotero.Prefs.set("proxies.disableByDomain", document.getElementById('zotero-proxies-disableByDomain-checkbox').checked && document.getElementById('zotero-proxies-disableByDomain-textbox').value != ""); @@ -50,8 +51,10 @@ Zotero_Preferences.Proxies = { document.getElementById('proxyTree-delete').disabled = document.getElementById('proxyTree').disabled = document.getElementById('zotero-proxies-autoRecognize').disabled = + document.getElementById('zotero-proxies-showRedirectNotification').disabled = document.getElementById('zotero-proxies-disableByDomain-checkbox').disabled = - document.getElementById('zotero-proxies-disableByDomain-textbox').disabled = !transparent; + document.getElementById('zotero-proxies-disableByDomain-textbox').disabled = + !transparent; }, @@ -150,6 +153,7 @@ Zotero_Preferences.Proxies = { document.getElementById('proxyTree-delete').disabled = true; document.getElementById('zotero-proxies-transparent').checked = Zotero.Prefs.get("proxies.transparent"); document.getElementById('zotero-proxies-autoRecognize').checked = Zotero.Prefs.get("proxies.autoRecognize"); + document.getElementById('zotero-proxies-showRedirectNotification').checked = Zotero.Prefs.get("proxies.showRedirectNotification"); document.getElementById('zotero-proxies-disableByDomain-checkbox').checked = Zotero.Prefs.get("proxies.disableByDomain"); document.getElementById('zotero-proxies-disableByDomain-textbox').value = Zotero.Prefs.get("proxies.disableByDomainString"); } diff --git a/chrome/content/zotero/xpcom/proxy.js b/chrome/content/zotero/xpcom/proxy.js @@ -69,6 +69,8 @@ Zotero.Proxies = new function() { Zotero.Proxies.lastIPCheck = 0; Zotero.Proxies.lastIPs = ""; Zotero.Proxies.disabledByDomain = false; + + Zotero.Proxies.showRedirectNotification = Zotero.Prefs.get("proxies.showRedirectNotification"); } /** @@ -107,7 +109,7 @@ Zotero.Proxies = new function() { if(!bw) return; _showNotification(bw, Zotero.getString('proxies.notification.associated.label', [host, channel.URI.hostPort]), - "settings", function() { _prefsOpenCallback(bw[1]) }); + [{ label: "proxies.notification.settings.button", callback: function() { _prefsOpenCallback(bw[1]); } }]); } } else { // otherwise, try to detect a proxy @@ -132,7 +134,7 @@ Zotero.Proxies = new function() { // Ask to save only if automatic proxy recognition is on savedTransparent = _showNotification(bw, Zotero.getString('proxies.notification.recognized.label', [proxy.hosts[0], channel.URI.hostPort]), - "enable", function() { _showDialog(proxy.hosts[0], channel.URI.hostPort, proxy) }); + [{ label: "proxies.notification.enable.button", callback: function() { _showDialog(proxy.hosts[0], channel.URI.hostPort, proxy); } }]); } proxy.save(); @@ -234,9 +236,15 @@ Zotero.Proxies = new function() { // Otherwise, redirect. Note that we save the URI we're redirecting from as the // referrer, since we can't make a proper redirect - _showNotification(bw, - Zotero.getString('proxies.notification.redirected.label', [channel.URI.hostPort, proxiedURI.hostPort]), - "settings", function() { _prefsOpenCallback(bw[1]) }); + if(Zotero.Proxies.showRedirectNotification) { + _showNotification(bw, + Zotero.getString('proxies.notification.redirected.label', [channel.URI.hostPort, proxiedURI.hostPort]), + [ + { label: "general.dontShowAgain", callback: function() { _disableRedirectNotification(); } }, + { label: "proxies.notification.settings.button", callback: function() { _prefsOpenCallback(bw[1]); } } + ]); + } + browser.loadURIWithFlags(proxied, 0, channel.URI, null, null); } @@ -417,26 +425,37 @@ Zotero.Proxies = new function() { * Show a proxy-related notification * @param {Array} bw output of _getBrowserWindow * @param {String} label notification text - * @param {String} button button text ("settings" or "enable") - * @param {Function} callback callback to be executed if button is pressed + * @param {Array} buttons dicts of button label resource string and associated callback */ - function _showNotification(bw, label, button, callback) { + function _showNotification(bw, label, buttons) { var browser = bw[0]; var window = bw[1]; - + + buttons = buttons.map(function(button) { + return { + label: Zotero.getString(button.label), + callback: button.callback + } + }); + var listener = function() { var nb = window.gBrowser.getNotificationBox(); nb.appendNotification(label, 'zotero-proxy', 'chrome://browser/skin/Info.png', nb.PRIORITY_WARNING_MEDIUM, - [{ - label:Zotero.getString('proxies.notification.'+button+'.button'), - callback:callback - }]); + buttons); browser.removeEventListener("pageshow", listener, false); } browser.addEventListener("pageshow", listener, false); } + + /** + * Disables proxy redirection notification + */ + function _disableRedirectNotification() { + Zotero.Proxies.showRedirectNotification = false; + Zotero.Prefs.set("proxies.showRedirectNotification",false); + } /** * Opens preferences window diff --git a/chrome/locale/en-US/zotero/preferences.dtd b/chrome/locale/en-US/zotero/preferences.dtd @@ -144,6 +144,7 @@ <!ENTITY zotero.preferences.proxies.desc_after_link "for more information."> <!ENTITY zotero.preferences.proxies.transparent "Enable proxy redirection"> <!ENTITY zotero.preferences.proxies.autoRecognize "Automatically recognize proxied resources"> +<!ENTITY zotero.preferences.proxies.showRedirectNotification "Show notification when redirecting through a proxy"> <!ENTITY zotero.preferences.proxies.disableByDomain "Disable proxy redirection when my domain name contains "> <!ENTITY zotero.preferences.proxies.configured "Configured Proxies"> <!ENTITY zotero.preferences.proxies.hostname "Hostname"> diff --git a/chrome/locale/en-US/zotero/zotero.properties b/chrome/locale/en-US/zotero/zotero.properties @@ -55,6 +55,7 @@ general.numMore = %S more… general.openPreferences = Open Preferences general.keys.ctrlShift = Ctrl+Shift+ general.keys.cmdShift = Cmd+Shift+ +general.dontShowAgain = Don’t Show Again general.operationInProgress = A Zotero operation is currently in progress. general.operationInProgress.waitUntilFinished = Please wait until it has finished. diff --git a/defaults/preferences/zotero.js b/defaults/preferences/zotero.js @@ -154,6 +154,7 @@ pref("extensions.zotero.proxies.autoRecognize", true); pref("extensions.zotero.proxies.transparent", true); pref("extensions.zotero.proxies.disableByDomain", false); pref("extensions.zotero.proxies.disableByDomainString", ".edu"); +pref("extensions.zotero.proxies.showRedirectNotification", true); // Data layer purging pref("extensions.zotero.purge.creators", false);