Skip to content

Commit 3fcda8c

Browse files
author
katmagic
committed
Add enable() and disable() function to ruleset objects.
1 parent 5a24229 commit 3fcda8c

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

src/chrome/content/code/HTTPSRules.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ function RuleSet(name, match_rule, default_off) {
3636
this.rules = [];
3737
this.exclusions = [];
3838
this.cookierules = [];
39-
var prefs = HTTPSEverywhere.instance.get_prefs();
39+
this.prefs = HTTPSEverywhere.instance.get_prefs();
4040
try {
4141
// if this pref exists, use it
42-
this.active = prefs.getBoolPref(name);
42+
this.active = this.prefs.getBoolPref(name);
4343
} catch (e) {
4444
// if not, create it
4545
this.log(DBUG, "Creating new pref " + name);
4646
this.active = true;
47-
prefs.setBoolPref(name, this.on_by_default);
47+
this.prefs.setBoolPref(name, this.on_by_default);
4848
}
4949
}
5050

@@ -100,6 +100,18 @@ RuleSet.prototype = {
100100
newuri = newuri.QueryInterface(CI.nsIURI);
101101
return newuri;
102102
},
103+
104+
enable: function() {
105+
// Enable us.
106+
this.prefs.setBoolPref(this.name, true);
107+
this.active = true;
108+
},
109+
110+
disable: function() {
111+
// Disable us.
112+
this.prefs.setBoolPref(this.name, false);
113+
this.active = false;
114+
}
103115
};
104116

105117
const RuleWriter = {

src/chrome/content/preferences.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,12 @@ function https_prefs_init(doc) {
3939
},
4040
setCellValue: function(row, col, val) { // toggle a rule's activation
4141
var rule = this.rules[row];
42-
var active = (val == "true");
4342

44-
o_httpsprefs.setBoolPref(rule.name, active);
45-
rule.active = active;
43+
if (val == "true") {
44+
rule.enable();
45+
} else {
46+
rule.disable();
47+
}
4648

4749
this.treebox.invalidateRow(row);
4850
},

0 commit comments

Comments
 (0)