Add an option to not show the proxy redirection notification

This commit is contained in:
LinuxMercedes 2015-03-11 22:21:40 -05:00
parent a5ce4d2a66
commit 34c0e746f5
6 changed files with 42 additions and 14 deletions

View file

@ -50,6 +50,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;"

View file

@ -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;
},
@ -141,6 +144,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");
}

View file

@ -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
if(Zotero.Proxies.showRedirectNotification) {
_showNotification(bw,
Zotero.getString('proxies.notification.redirected.label', [channel.URI.hostPort, proxiedURI.hostPort]),
"settings", function() { _prefsOpenCallback(bw[1]) });
[
{ 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,27 +425,38 @@ 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
*/

View file

@ -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">

View file

@ -55,6 +55,7 @@ general.numMore = %S more…
general.openPreferences = Open Preferences
general.keys.ctrlShift = Ctrl+Shift+
general.keys.cmdShift = Cmd+Shift+
general.dontShowAgain = Dont Show Again
general.operationInProgress = A Zotero operation is currently in progress.
general.operationInProgress.waitUntilFinished = Please wait until it has finished.

View file

@ -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);