Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b9e5e99

Browse filesBrowse files
committed
Merge pull request EFForg#526 from EFForg/e10s
Make HTTPS Everywhere compatible with e10s (multiprocess firefox)
2 parents 8f182e1 + 8e92b51 commit b9e5e99
Copy full SHA for b9e5e99

5 files changed

+93-234Lines changed: 93 additions & 234 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/chrome.manifest‎

Copy file name to clipboardExpand all lines: src/chrome.manifest
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ component {32c165b4-fe5e-4964-9250-603c410631b4} components/https-everywhere.js
4141
contract @eff.org/https-everywhere;1 {32c165b4-fe5e-4964-9250-603c410631b4}
4242

4343
category profile-after-change HTTPSEverywhere @eff.org/https-everywhere;1
44-
category content-policy HTTPSEverywhere @eff.org/https-everywhere;1
4544

4645
overlay chrome://browser/content/browser.xul chrome://https-everywhere/content/toolbar_button.xul
4746
overlay chrome://navigator/content/navigator.xul chrome://https-everywhere/content/toolbar_button.xul
Collapse file

‎src/chrome/content/code/ApplicableList.js‎

Copy file name to clipboardExpand all lines: src/chrome/content/code/ApplicableList.js
+12-14Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,16 @@
44

55
serial_number = 0;
66

7-
function ApplicableList(logger, doc, domWin) {
8-
this.domWin = domWin;
9-
this.uri = doc.baseURIObject.clone();
7+
function ApplicableList(logger, uri) {
8+
this.log = logger;
9+
this.uri = uri.clone();
1010
if (!this.uri) {
1111
this.log(WARN,"NULL CLONING URI " + doc);
12-
if (doc)
13-
this.log(WARN,"NULL CLONING URI " + doc.baseURIObject);
14-
if (doc.baseURIObject)
15-
this.log(WARN,"NULL CLONING URI " + doc.baseURIObject.spec);
12+
if (uri) {
13+
this.log(WARN,"NULL CLONING URI " + uri.spec);
14+
}
1615
}
17-
this.home = doc.baseURIObject.spec; // what doc we're housekeeping for
18-
this.log = logger;
16+
this.home = uri.spec; // what doc we're housekeeping for
1917
this.active = {};
2018
this.breaking = {}; // rulesets with redirection loops
2119
this.inactive = {};
@@ -40,22 +38,22 @@ ApplicableList.prototype = {
4038

4139
active_rule: function(ruleset) {
4240
this.log(INFO,"active rule " + ruleset.name +" in "+ this.home +" -> " +
43-
this.domWin.document.baseURIObject.spec+ " serial " + this.serial);
41+
this.uri.spec+ " serial " + this.serial);
4442
this.active[ruleset.name] = ruleset;
4543
this.all[ruleset.name] = ruleset;
4644
},
4745

4846
breaking_rule: function(ruleset) {
4947
this.log(NOTE,"breaking rule " + ruleset.name +" in "+ this.home +" -> " +
50-
this.domWin.document.baseURIObject.spec+ " serial " + this.serial);
48+
this.uri.spec+ " serial " + this.serial);
5149
this.breaking[ruleset.name] = ruleset;
5250
this.all[ruleset.name] = ruleset;
5351
},
5452

5553
inactive_rule: function(ruleset) {
5654

5755
this.log(INFO,"inactive rule " + ruleset.name +" in "+ this.home +" -> " +
58-
this.domWin.document.baseURIObject.spec+ " serial " + this.serial);
56+
this.uri.spec+ " serial " + this.serial);
5957
this.inactive[ruleset.name] = ruleset;
6058
this.all[ruleset.name] = ruleset;
6159
},
@@ -140,8 +138,8 @@ ApplicableList.prototype = {
140138
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
141139
.getService(Components.interfaces.nsIWindowMediator);
142140

143-
var domWin = wm.getMostRecentWindow("navigator:browser").content.document.defaultView.top;
144-
var location = domWin.document.baseURIObject.asciiSpec; //full url, including about:certerror details
141+
var browser = wm.getMostRecentWindow("navigator:browser").gBrowser.selectedBrowser;
142+
var location = browser.currentURI.asciiSpec; //full url, including about:certerror details
145143

146144
if(location.substr(0, 6) == "about:"){
147145
//"From" portion of the rule is retrieved from the location bar via document.getElementById("urlbar").value
Collapse file

‎src/chrome/content/toolbar_button.js‎

Copy file name to clipboardExpand all lines: src/chrome/content/toolbar_button.js
+25-45Lines changed: 25 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -82,19 +82,22 @@ httpsEverywhere.toolbarButton = {
8282
false
8383
);
8484

85-
// hook event for when page loads
86-
var onPageLoad = function() {
87-
// Timeout is used for a number of reasons.
88-
// 1) For Performance since we want to defer computation.
89-
// 2) Sometimes the page is loaded before all applied rulesets are
90-
// calculated; in such a case, a half-second wait works.
91-
setTimeout(tb.updateRulesetsApplied, 500);
85+
// add listener for top-level location change across all tabs
86+
let httpseProgressListener = {
87+
onLocationChange: function(aBrowser, aWebProgress, aReq, aLoc) {
88+
HTTPSEverywhere.log(DBUG, "Got on location change!");
89+
HTTPSEverywhere.onLocationChange(aBrowser);
90+
},
91+
onStateChange: function(aBrowser, aWebProgress, aReq, aFlags, aStatus) {
92+
if ((gBrowser.selectedBrowser === aBrowser) &&
93+
(aFlags & CI.nsIWebProgressListener.STATE_STOP) &&
94+
aWebProgress.isTopLevel) {
95+
HTTPSEverywhere.log(DBUG, "Got on state change");
96+
tb.updateRulesetsApplied();
97+
}
98+
}
9299
};
93-
94-
var appcontent = document.getElementById('appcontent');
95-
if (appcontent) {
96-
appcontent.addEventListener('load', onPageLoad, true);
97-
}
100+
gBrowser.addTabsProgressListener(httpseProgressListener);
98101

99102
// decide whether to show toolbar hint
100103
let hintPref = "extensions.https_everywhere.toolbar_hint_shown";
@@ -145,8 +148,8 @@ httpsEverywhere.toolbarButton = {
145148
return;
146149
}
147150

148-
var domWin = content.document.defaultView.top;
149-
var alist = HTTPSEverywhere.getExpando(domWin,"applicable_rules", null);
151+
var browser = window.gBrowser.selectedBrowser;
152+
var alist = HTTPSEverywhere.getExpando(browser,"applicable_rules");
150153
if (!alist) {
151154
return;
152155
}
@@ -270,20 +273,20 @@ function stitch_context_menu2() {
270273
var rulesetTestsMenuItem = null;
271274

272275
function show_applicable_list(menupopup) {
273-
var domWin = content.document.defaultView.top;
274-
if (!(domWin instanceof CI.nsIDOMWindow)) {
275-
alert(domWin + " is not an nsIDOMWindow");
276-
return null;
276+
var browser = gBrowser.selectedBrowser;
277+
if (!browser) {
278+
HTTPSEverywhere.log(WARN, "No browser for applicable list");
279+
return;
277280
}
278281

279-
var alist = HTTPSEverywhere.getExpando(domWin,"applicable_rules", null);
282+
var alist = HTTPSEverywhere.getExpando(browser,"applicable_rules");
280283
var weird=false;
281-
284+
282285
if (!alist) {
283286
// This case occurs for error pages and similar. We need a dummy alist
284287
// because populate_menu lives in there. Would be good to refactor this
285288
// away.
286-
alist = new HTTPSEverywhere.ApplicableList(HTTPSEverywhere.log, document, domWin);
289+
alist = new HTTPSEverywhere.ApplicableList(HTTPSEverywhere.log, browser.currentURI);
287290
weird = true;
288291
}
289292
alist.populate_menu(document, menupopup, weird);
@@ -303,38 +306,16 @@ function show_applicable_list(menupopup) {
303306
if(!menupopup.contains(rulesetTestsMenuItem))
304307
menupopup.appendChild(rulesetTestsMenuItem);
305308
}
306-
307309
}
308310

309311
function toggle_rule(rule_id) {
310312
// toggle the rule state
311313
HTTPSEverywhere.https_rules.rulesetsByID[rule_id].toggle();
312-
var domWin = content.document.defaultView.top;
313-
/*if (domWin instanceof CI.nsIDOMWindow) {
314-
var alist = HTTPSEverywhere.getExpando(domWin,"applicable_rules", null);
315-
if (alist) alist.empty();
316-
}*/
317314
reload_window();
318315
}
319316

320317
function reload_window() {
321-
var domWin = content.document.defaultView.top;
322-
if (!(domWin instanceof CI.nsIDOMWindow)) {
323-
HTTPSEverywhere.log(WARN, domWin + " is not an nsIDOMWindow");
324-
return null;
325-
}
326-
try {
327-
var webNav = domWin.QueryInterface(CI.nsIInterfaceRequestor)
328-
.getInterface(CI.nsIWebNavigation)
329-
.QueryInterface(CI.nsIDocShell);
330-
} catch(e) {
331-
HTTPSEverywhere.log(WARN,"failed to get webNav");
332-
return null;
333-
}
334-
// The choice of LOAD_FLAGS_CHARSET_CHANGE comes from NoScript's quickReload
335-
// function; not sure if it's optimal
336-
let flags = webNav.LOAD_FLAGS_BYPASS_CACHE & webNav.LOAD_FLAGS_CHARSET_CHANGE;
337-
webNav.reload(flags);
318+
gBrowser.reloadTab(gBrowser.selectedTab);
338319
}
339320

340321
function toggleEnabledState(){
@@ -402,4 +383,3 @@ function migratePreferences() {
402383
HTTPSEverywhere.prefs.setIntPref("prefs_version", prefs_version+1);
403384
}
404385
}
405-

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.