[Pkg-mozext-commits] [perspectives-extension] 10/72: Added an option to not always contact notaries in private browsing by default. Fixes #115.

David Prévot taffit at moszumanska.debian.org
Thu Dec 11 02:12:45 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository perspectives-extension.

commit 74c30b942395d1a4ff588014e490e399c834b91d
Author: Gerold Meisinger <gerold.meisinger at gmail.com>
Date:   Mon Jun 16 19:53:24 2014 +0100

    Added an option to not always contact notaries in private browsing by default.
    Fixes #115.
---
 plugin/chrome/content/notaries.js            | 27 +++++++++++++++++++
 plugin/chrome/content/preferences_dialog.js  | 39 ++++++++++++++--------------
 plugin/chrome/content/preferences_dialog.xul | 10 +++++++
 plugin/chrome/locale/de/dialogs.dtd          |  1 +
 plugin/chrome/locale/en-US/dialogs.dtd       |  1 +
 plugin/chrome/locale/es-MX/dialogs.dtd       |  3 +++
 plugin/chrome/locale/fi/dialogs.dtd          |  3 +++
 plugin/chrome/locale/fr/dialogs.dtd          |  3 +++
 plugin/chrome/locale/nl/dialogs.dtd          |  3 +++
 plugin/chrome/locale/zh-CN/dialogs.dtd       |  3 +++
 plugin/defaults/preferences/prefs.js         |  1 +
 11 files changed, 75 insertions(+), 19 deletions(-)

diff --git a/plugin/chrome/content/notaries.js b/plugin/chrome/content/notaries.js
index a6ac713..2ae751a 100644
--- a/plugin/chrome/content/notaries.js
+++ b/plugin/chrome/content/notaries.js
@@ -634,6 +634,7 @@ var Perspectives = {
 			Pers_debug.d_print("main", ti.uri.host + " needs a request");
 			var needs_perm = Perspectives.root_prefs
 					.getBoolPref("perspectives.require_user_permission");
+
 			if(needs_perm && !ti.has_user_permission) {
 				Pers_debug.d_print("main", "needs user permission");
 				Pers_notify.do_notify(ti, Pers_notify.TYPE_NEEDS_PERMISSION);
@@ -643,6 +644,32 @@ var Perspectives = {
 				return;
 			}
 
+			// respect private browsing mode
+			var contact_private = Perspectives.root_prefs
+				.getBoolPref("extensions.perspectives.contact_in_private_browsing_mode");
+			if(!contact_private) {
+				var is_private = true; // default to true, better err on the save side
+				try { // Firefox 20+
+					Components.utils.import("resource://gre/modules/PrivateBrowsingUtils.jsm");
+					is_private = PrivateBrowsingUtils.isWindowPrivate(win);
+				} catch(e) { // pre Firefox 20
+					try {
+						is_private = Components.classes["@mozilla.org/privatebrowsing;1"].
+							getService(Components.interfaces.nsIPrivateBrowsingService).
+							privateBrowsingEnabled;
+					} catch(e) {
+						Pers_debug.d_print("main", "Can't retrieve private browsing mode. Assume 'private browsing mode activated'.");
+					}
+				}
+
+				if(is_private) {
+					Pers_debug.d_print("main", "don't contact notaries in private browsing mode");
+					var text = Perspectives.strbundle.getString("needsPermission"); // TODO: maybe add an additional localization hinting to private browsing mode
+					Pers_statusbar.setStatus(ti.uri, Pers_statusbar.STATE_NEUT, text);
+					ti.reason_str = text;
+					return;
+				}
+			}
 
 			// make sure we're using the most recent notary list
 			Perspectives.all_notaries = this.getNotaryList();
diff --git a/plugin/chrome/content/preferences_dialog.js b/plugin/chrome/content/preferences_dialog.js
index fb6c89c..447079a 100644
--- a/plugin/chrome/content/preferences_dialog.js
+++ b/plugin/chrome/content/preferences_dialog.js
@@ -20,19 +20,20 @@ var Pers_pref = {
 	root_prefs : Components.classes["@mozilla.org/preferences-service;1"].
 				getService(Components.interfaces.nsIPrefBranch),
 
-	disable_quorum_text: function(is_disabled) { 
+	disable_quorum_text: function(is_disabled) {
 		document.getElementById("quorum-thresh-text").disabled=is_disabled;
-		document.getElementById("quorum-duration-text").disabled=is_disabled; 
-	}, 
+		document.getElementById("quorum-duration-text").disabled=is_disabled;
+	},
 
 	disable_reminder_box: function() {
 		// enable or disable the sub-checkbox based on the value of the parent
 		var checked = document.getElementById("require-user-permission-checkbox").checked;
-		document.getElementById("show-permission-reminder-checkbox").disabled=!checked;
+		document.getElementById("show-permission-reminder-checkbox"        ).disabled = !checked;
+		document.getElementById("contact-in-private-browsing-mode-checkbox").disabled =  checked;
 	},
 
 	menuset: function(qu, du){
-		Pers_pref.disable_quorum_text(true); 
+		Pers_pref.disable_quorum_text(true);
 		document.getElementById("quorum-thresh").value = qu;
 		document.getElementById("quorum-duration").value = du;
 	},
@@ -51,7 +52,7 @@ var Pers_pref = {
 			Pers_pref.menuset(50, 0);
 			break;
 		case -1:
-			Pers_pref.disable_quorum_text(false); 
+			Pers_pref.disable_quorum_text(false);
 			break;
 		}
 
@@ -93,30 +94,30 @@ var Pers_pref = {
 
 	auto_update_changed: function() {
 		try {
-			// Preferences are not necessarily updated at this point, so determine which 
-			// list to show based on whether the checkbox is selected.  
+			// Preferences are not necessarily updated at this point, so determine which
+			// list to show based on whether the checkbox is selected.
 			var auto_update = document.getElementById("enable_default_list_auto_update").checked;
-			if(auto_update) { 
+			if(auto_update) {
 				Pers_util.update_default_notary_list_from_web(this.root_prefs);
-			} else {  
-				Pers_util.update_default_notary_list_from_file(this.root_prefs); 
-			} 
-			this.load_preferences(); 
-		} catch(e) { 
+			} else {
+				Pers_util.update_default_notary_list_from_file(this.root_prefs);
+			}
+			this.load_preferences();
+		} catch(e) {
 			Pers_util.pers_alert(e);
 		}
 
-	},  
-  
+	},
+
 	load_preferences: function(){
 		try {
-			Pers_pref.security_class_change(); 
+			Pers_pref.security_class_change();
 			Pers_pref.disable_reminder_box();
 			var default_notary_text = this.root_prefs.getCharPref("perspectives.default_notary_list");
 			document.getElementById("default_notary_list").value = default_notary_text;
-		} catch(e) { 
+		} catch(e) {
 			Pers_util.pers_alert(e);
-		} 
+		}
 	}
 }
 
diff --git a/plugin/chrome/content/preferences_dialog.xul b/plugin/chrome/content/preferences_dialog.xul
index 87c6d06..1c89f2d 100644
--- a/plugin/chrome/content/preferences_dialog.xul
+++ b/plugin/chrome/content/preferences_dialog.xul
@@ -52,6 +52,10 @@
     name="extensions.perspectives.show_permission_reminder"
     type="bool"/>
   <preference
+    id="contact-in-private-browsing-mode"
+    name="extensions.perspectives.contact_in_private_browsing_mode"
+    type="bool"/>
+  <preference
     id="whitelist"
     name="perspectives.whitelist"
     type="string"/>
@@ -150,6 +154,12 @@
             label="&DisplayPermissionReminder;"
             preference="show-permission-reminder"/>
         </hbox>
+        <hbox>
+          <label value="   "/>
+          <checkbox id="contact-in-private-browsing-mode-checkbox"
+            label="&ContactNotariesInPrivateBrowsingMode;"
+            preference="contact-in-private-browsing-mode"/>
+        </hbox>
   </groupbox>
 
   <groupbox>
diff --git a/plugin/chrome/locale/de/dialogs.dtd b/plugin/chrome/locale/de/dialogs.dtd
index 80422e0..67de6b2 100644
--- a/plugin/chrome/locale/de/dialogs.dtd
+++ b/plugin/chrome/locale/de/dialogs.dtd
@@ -21,6 +21,7 @@
 <!ENTITY ContactNotariesforallHTTPSsites "Für alle HTTPS-Webseiten bei Notaren nachfragen">
 <!ENTITY ContactNotariesonlywhenawebsitescertificatecausesasecurityerror "Nur nachfragen, wenn das Zertifikat einer Webseite einen Sicherheitsfehler verursacht">
 <!ENTITY AlwaysasktheuserbeforecontactingNotaries "Immer nachfragen, bevor Notare kontaktiert werden.">
+<!ENTITY ContactNotariesInPrivateBrowsingMode "Notare auch im privaten Modus kontaktieren">
 <!ENTITY Certificates "Zertifikate">
 <!ENTITY Servers "Notarserver">
 <!ENTITY Help "Hilfe">
diff --git a/plugin/chrome/locale/en-US/dialogs.dtd b/plugin/chrome/locale/en-US/dialogs.dtd
index c31ec60..7702a79 100644
--- a/plugin/chrome/locale/en-US/dialogs.dtd
+++ b/plugin/chrome/locale/en-US/dialogs.dtd
@@ -22,6 +22,7 @@
 <!ENTITY ContactNotariesonlywhenawebsitescertificatecausesasecurityerror "Contact Notaries only when a website's certificate causes a security error">
 <!ENTITY AlwaysasktheuserbeforecontactingNotaries "Always ask before contacting Notaries">
 <!ENTITY DisplayPermissionReminder "Display a notification reminder">
+<!ENTITY ContactNotariesInPrivateBrowsingMode "Also contact notaries while in private browsing mode">
 <!ENTITY Certificates "Certificates">
 <!ENTITY Servers "Notary Servers">
 <!ENTITY Help "Help">
diff --git a/plugin/chrome/locale/es-MX/dialogs.dtd b/plugin/chrome/locale/es-MX/dialogs.dtd
index 90cc18c..84013f5 100644
--- a/plugin/chrome/locale/es-MX/dialogs.dtd
+++ b/plugin/chrome/locale/es-MX/dialogs.dtd
@@ -23,6 +23,9 @@
 <!ENTITY ContactNotariesforallHTTPSsites "Contactar a las Notarías para todos los sitios HTTPS">
 <!ENTITY ContactNotariesonlywhenawebsitescertificatecausesasecurityerror "Contactar a las Notarías solamente cuando el certificado de un sitio web ocasione errores de seguridad">
 <!ENTITY AlwaysasktheuserbeforecontactingNotaries "Preguntar siempre antes de contactar a las Notarías">
+<!-- TODO translate -->
+<!ENTITY ContactNotariesInPrivateBrowsingMode "Also contact notaries while in private browsing mode">
+<!-- -->
 <!ENTITY Certificates "Certificados">
 <!ENTITY Servers "Servidores de Notarías">
 <!ENTITY Help "Ayuda">
diff --git a/plugin/chrome/locale/fi/dialogs.dtd b/plugin/chrome/locale/fi/dialogs.dtd
index df1c296..82d488a 100644
--- a/plugin/chrome/locale/fi/dialogs.dtd
+++ b/plugin/chrome/locale/fi/dialogs.dtd
@@ -23,6 +23,9 @@
 <!ENTITY ContactNotariesforallHTTPSsites "Contact Notaries for all HTTPS sites">
 <!ENTITY ContactNotariesonlywhenawebsitescertificatecausesasecurityerror "Contact Notaries only when a website's certificate causes a security error">
 <!ENTITY AlwaysasktheuserbeforecontactingNotaries "Always ask before contacting Notaries">
+<!-- TODO translate -->
+<!ENTITY ContactNotariesInPrivateBrowsingMode "Also contact notaries while in private browsing mode">
+<!-- -->
 <!ENTITY Certificates "Sertifikaatit">
 <!ENTITY Servers "Notary Servers">
 <!ENTITY Help "Apua">
diff --git a/plugin/chrome/locale/fr/dialogs.dtd b/plugin/chrome/locale/fr/dialogs.dtd
index ff00ec8..94417c6 100644
--- a/plugin/chrome/locale/fr/dialogs.dtd
+++ b/plugin/chrome/locale/fr/dialogs.dtd
@@ -23,6 +23,9 @@
 <!ENTITY ContactNotariesforallHTTPSsites "Contacter les Notaires pour tous les sites HTTPS">
 <!ENTITY ContactNotariesonlywhenawebsitescertificatecausesasecurityerror "Contacter les Notaires seulement quand le certificat d'un site web provoque une erreur de sécurité">
 <!ENTITY AlwaysasktheuserbeforecontactingNotaries "Toujours demander avant de contacter les Notaires">
+<!-- TODO translate -->
+<!ENTITY ContactNotariesInPrivateBrowsingMode "Also contact notaries while in private browsing mode">
+<!-- -->
 <!ENTITY Certificates "Certificats">
 <!ENTITY Servers "Serveurs Notaires">
 <!ENTITY Help "Aide">
diff --git a/plugin/chrome/locale/nl/dialogs.dtd b/plugin/chrome/locale/nl/dialogs.dtd
index 1e13380..676e6b0 100644
--- a/plugin/chrome/locale/nl/dialogs.dtd
+++ b/plugin/chrome/locale/nl/dialogs.dtd
@@ -23,6 +23,9 @@
 <!ENTITY ContactNotariesforallHTTPSsites "Contact Notaries for all HTTPS sites">
 <!ENTITY ContactNotariesonlywhenawebsitescertificatecausesasecurityerror "Contact Notaries only when a website's certificate causes a security error">
 <!ENTITY AlwaysasktheuserbeforecontactingNotaries "Always ask before contacting Notaries">
+<!-- TODO translate -->
+<!ENTITY ContactNotariesInPrivateBrowsingMode "Also contact notaries while in private browsing mode">
+<!-- -->
 <!ENTITY Certificates "Certificates">
 <!ENTITY Servers "Notary Servers">
 <!ENTITY Help "Help">
diff --git a/plugin/chrome/locale/zh-CN/dialogs.dtd b/plugin/chrome/locale/zh-CN/dialogs.dtd
index 0e549f3..e3ae636 100644
--- a/plugin/chrome/locale/zh-CN/dialogs.dtd
+++ b/plugin/chrome/locale/zh-CN/dialogs.dtd
@@ -23,6 +23,9 @@
 <!ENTITY ContactNotariesforallHTTPSsites "对所有的 HTTPS 站点都联系认证服务器">
 <!ENTITY ContactNotariesonlywhenawebsitescertificatecausesasecurityerror "仅在站点的证书引起安全错误时联系认证服务器">
 <!ENTITY AlwaysasktheuserbeforecontactingNotaries "联系认证服务器前总是询问用户">
+<!-- TODO translate -->
+<!ENTITY ContactNotariesInPrivateBrowsingMode "Also contact notaries while in private browsing mode">
+<!-- -->
 <!ENTITY Certificates "证书">
 <!ENTITY Servers "认证服务器">
 <!ENTITY Help "帮助">
diff --git a/plugin/defaults/preferences/prefs.js b/plugin/defaults/preferences/prefs.js
index 788a306..77d3372 100755
--- a/plugin/defaults/preferences/prefs.js
+++ b/plugin/defaults/preferences/prefs.js
@@ -11,6 +11,7 @@ pref("perspectives.exceptions.enabled", true);
 pref("perspectives.check_good_certificates", true);
 pref("perspectives.require_user_permission", false);
 pref("extensions.perspectives.show_permission_reminder", true);
+pref("extensions.perspectives.contact_in_private_browsing_mode", false);
 pref("perspectives.show_label", true);
 pref("perspectives.svg", "");
 pref("perspectives.max_timespan_for_inconsistency_test", 7);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/perspectives-extension.git



More information about the Pkg-mozext-commits mailing list