Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

Commit

Permalink
Remove dependency on FUEL which is removed since Firefox 47 (closes #18
Browse files Browse the repository at this point in the history
…).
  • Loading branch information
spasche committed Mar 20, 2016
1 parent d425ac9 commit 0c604d0
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 13 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,7 @@
## 1.17

Remove dependency on FUEL which is removed in Firefox 47 (closes #18).

## 1.16

Prevent the browser from caching the response (closes #9). Thanks to Alexander Rosenberg for the fix.
Expand Down
37 changes: 25 additions & 12 deletions chrome/content/openInBrowser.js
Expand Up @@ -22,6 +22,8 @@
*
* ***** END LICENSE BLOCK ***** */

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

var Ci = Components.interfaces;
var Cc = Components.classes;

Expand Down Expand Up @@ -68,7 +70,9 @@ var OpenInBrowser = {
if (/^http/.test(uri.scheme)) {
mimes = this.MIMES_HTTP;

var additionalMimes = Application.prefs.getValue(this.ADDITIONAL_MIMES_PREF, null);
try {
var additionalMimes = Services.prefs.getCharPref(this.ADDITIONAL_MIMES_PREF);
} catch (e) { }
if (additionalMimes) {
mimes = mimes.slice();
for each (let m in additionalMimes.split("|")) {
Expand Down Expand Up @@ -137,19 +141,28 @@ var OpenInBrowser = {
getService().wrappedJSObject;
interceptor.addInterceptInfo(uri.spec, mime);
}
var tab = Application.activeWindow.activeTab;

let targetBrowser = Services.wm.getMostRecentWindow("navigator:browser").gBrowser.selectedBrowser;

if (doc) {
var matchingTabs = [];
Application.windows.forEach(function(window) {
window.tabs.forEach(function(tab) {
if (tab.document == doc)
matchingTabs.push(tab);
})
});
if (matchingTabs.length == 1) {
tab = matchingTabs[0];
let matchingBrowsers = [];

let enumerator = Services.wm.getEnumerator("navigator:browser");
while (enumerator.hasMoreElements()) {
let window = enumerator.getNext();

for (let browser of window.gBrowser.browsers) {
if (browser.contentDocument == doc) {
matchingBrowsers.push(browser);
}
}
}

if (matchingBrowsers.length == 1) {
targetBrowser = matchingBrowsers[0];
}
}
tab.load(uri);

targetBrowser.loadURI(uri.spec, null, null);
}
};
2 changes: 1 addition & 1 deletion install.rdf
Expand Up @@ -6,7 +6,7 @@

<em:id>openinbrowser@www.spasche.net</em:id>
<em:name>Open in Browser</em:name>
<em:version>1.16</em:version>
<em:version>1.17</em:version>
<em:type>2</em:type>
<em:description>Offers the possibility to display documents in browser window.</em:description>
<em:creator>Sylvain Pasche</em:creator>
Expand Down

0 comments on commit 0c604d0

Please sign in to comment.