[Pkg-mozext-commits] [perspectives-extension] 18/44: Perspectives - Add functions to retrieve root prefs and override
David Prévot
taffit at moszumanska.debian.org
Sun Jun 26 04:59:19 UTC 2016
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository perspectives-extension.
commit b3b5ab63b69855bfc8e5511ed18d6c89abd8771d
Author: Dave Schaefer <dave.schaefer at gmail.com>
Date: Sun Jun 12 21:36:25 2016 -0700
Perspectives - Add functions to retrieve root prefs and override
The object can track state and initialize these itself if necessary
This way no callers have to worry about whether they've been initialized,
and nothing has to call init_data().
We should change all uses of the variables to call these instead.
---
plugin/chrome/content/notaries.js | 42 +++++++++++++++++++++++++++++++++++----
1 file changed, 38 insertions(+), 4 deletions(-)
diff --git a/plugin/chrome/content/notaries.js b/plugin/chrome/content/notaries.js
index 63f6428..a28a892 100644
--- a/plugin/chrome/content/notaries.js
+++ b/plugin/chrome/content/notaries.js
@@ -56,6 +56,9 @@ var Perspectives = {
init_data: function() {
var success = true;
+ // TODO: replace everything that calls init_data
+ // or relies on root_prefs or overrideService
+ // with calls to getRootPrefs and getOverrideService
if(Perspectives.root_prefs === null) {
var prefstr = "@mozilla.org/preferences-service;1";
if(prefstr in Components.classes) {
@@ -95,6 +98,37 @@ var Perspectives = {
Components.interfaces.nsIWebProgressListener.STATE_IS_SECURE
},
+ getRootPrefs: function() {
+ if (Perspectives.root_prefs === null) {
+ var prefstr = "@mozilla.org/preferences-service;1";
+ if (prefstr in Components.classes) {
+ Perspectives.root_prefs = Components.classes[prefstr].
+ getService(Components.interfaces.nsIPrefBranchInternal);
+ }
+ else {
+ Pers_debug.d_print("error",
+ "Could not define Perspectives.root_prefs!");
+ }
+ }
+ return Perspectives.root_prefs
+ },
+
+ getOverrideService: function() {
+
+ if(Perspectives.overrideService === null) {
+ var servstr = "@mozilla.org/security/certoverride;1";
+ if (servstr in Components.classes) {
+ Perspectives.overrideService = Components.classes[servstr].
+ getService(Components.interfaces.nsICertOverrideService);
+ }
+ else {
+ Pers_debug.d_print("error",
+ "Could not define Perspectives.overrideServices!");
+ }
+ }
+ return Perspectives.overrideService
+ },
+
is_nonrouted_ip: function(ip_str) {
for(var i = 0; i < Perspectives.nonrouted_ips.length; i++) {
if(ip_str.match(Perspectives.nonrouted_ips[i])) {
@@ -634,10 +668,10 @@ var Perspectives = {
ti.state = ti.browser.securityUI.state;
- ti.is_override_cert = Perspectives.overrideService.isCertUsedForOverrides(ti.cert, true, true);
+ ti.is_override_cert = Perspectives.getOverrideService().isCertUsedForOverrides(ti.cert, true, true);
Pers_debug.d_print("main",
"is_override_cert = " + ti.is_override_cert);
- var check_good = Perspectives.root_prefs.
+ var check_good = Perspectives.getRootPrefs().
getBoolPref("extensions.perspectives.check_good_certificates");
@@ -1012,9 +1046,9 @@ var Perspectives = {
var auto_update = this.root_prefs.getBoolPref("extensions.perspectives.enable_default_list_auto_update");
if(auto_update) {
- Pers_util.update_default_notary_list_from_web(this.root_prefs);
+ Pers_util.update_default_notary_list_from_web(Perspectives.getRootPrefs());
} else {
- Pers_util.update_default_notary_list_from_file(this.root_prefs);
+ Pers_util.update_default_notary_list_from_file(Perspectives.getRootPrefs());
}
Pers_debug.d_print("main", Perspectives.notaries);
Pers_statusbar.setStatus(null, Pers_statusbar.STATE_NEUT, "");
--
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