Skip to content

Commit

Permalink
Add workaround to run CAA on Waterfox in multi-process mode
Browse files Browse the repository at this point in the history
  • Loading branch information
JustOff committed Oct 14, 2018
1 parent ef65b7d commit a565810
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 5 deletions.
29 changes: 24 additions & 5 deletions bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,27 +161,46 @@ let caaIn = function (w) {
m = null;
},
run : function () {
if (Services.ppmm.childCount > 1) {
Services.prompt.alert(null, "Classic Add-ons Archive", "Multi-process mode is not supported now,\nplease disable it and restart the browser.");
function isRemote (win) {
let loadContext = win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation).QueryInterface(Ci.nsILoadContext);
return loadContext.useRemoteTabs;
}
let e10s = isRemote(Services.wm.getMostRecentWindow("navigator:browser"));
if (e10s && Services.appinfo.name != "Waterfox") {
Services.prompt.alert(null, "Classic Add-ons Archive", "Multi-process mode is not supported now,\nplease disable it and restart " + Services.appinfo.name + ".");
return;
}
let isOpen = false;
let isOpen = false, ne10win = null;
let winenu = Services.wm.getEnumerator("navigator:browser");
loop: while (winenu.hasMoreElements()) {
let window = winenu.getNext().QueryInterface(Ci.nsIDOMWindow);
for (let tab of window.gBrowser.tabs) {
if (tab.linkedBrowser.currentURI.scheme == "caa") {
window.focus()
window.focus();
window.gBrowser.selectedTab = tab;
isOpen = true;
break loop;
}
}
if (e10s && ne10win === null) {
if (!isRemote(window)) {
ne10win = window;
}
}
}
if (!isOpen) {
let mrw = Services.wm.getMostRecentWindow("navigator:browser");
let url = Services.prefs.getBranch(branch).getCharPref("url");
mrw.gBrowser.selectedTab = mrw.gBrowser.addTab(url);
if (!e10s) {
mrw.gBrowser.selectedTab = mrw.gBrowser.addTab(url);
} else {
if (ne10win === null) {
mrw.openDialog("chrome://browser/content/", "_blank", "chrome,all,dialog=no,non-remote", url);
} else {
ne10win.focus();
ne10win.gBrowser.selectedTab = ne10win.gBrowser.addTab(url);
}
}
if (url == "caa:about") {
Services.prefs.getBranch(branch).setCharPref("url", "caa:");
}
Expand Down
14 changes: 14 additions & 0 deletions content/tcloud.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
"use strict";
let EXPORTED_SYMBOLS = ["TCloud"];

var Cu = Components.utils;
Cu.import("resource://gre/modules/Services.jsm");

let TCloud = {

showPage: function(document, db) {
let template = this.template;
template = this.processTemplate(template);
document.title = "Tag Cloud :: Classic Add-ons Archive";

let contfrag = document.createRange().createContextualFragment(template);
Expand All @@ -13,6 +17,15 @@ let TCloud = {
page.appendChild(frag);
},

processTemplate: function(template) {
if (Services.appinfo.browserTabsRemoteAutostart) {
template = template.replace("%E10S%", "<div style='float: right; border: 1px solid #c9ddf2; padding: 3px; margin-top: 2px;'><a style='text-decoration: none;' href='https://github.com/JustOff/ca-archive/issues/2' target='_blank'>&lowast;&#8201;" + Services.appinfo.name + " in multi-process mode can't restore <span style='font-style: italic;'>caa:</span> urls after restart&#8202;&lowast;</a></div>");
} else {
template = template.replace("%E10S%", "");
}
return template;
},

template: `<html>
<body>
<div>
Expand Down Expand Up @@ -47,6 +60,7 @@ let TCloud = {
</section>
<section class="primary">
%E10S%
<h1>Most Popular Tags</h1>
<div class="island hero c listing">
Expand Down

1 comment on commit a565810

@JustOff
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tag #2.

Please sign in to comment.