Skip to content

Commit

Permalink
- fix: gestures customization in options stopped working in Firefox 56
Browse files Browse the repository at this point in the history
 - fix: gestures for opening favourite bookmarks stopped working in Firefox 53
  • Loading branch information
lemon-juice committed Oct 21, 2017
1 parent 9325c18 commit c3bb888
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 20 deletions.
56 changes: 40 additions & 16 deletions source/chrome/content/allinonegest/gestimp.js
Original file line number Diff line number Diff line change
Expand Up @@ -687,27 +687,51 @@ mgsuite.imp = {
},

aioFavoriteURL: function(suffix) {
var shortcutURL = null;
var bmsvc = Components.classes["@mozilla.org/browser/nav-bookmarks-service;1"].getService(Components.interfaces.nsINavBookmarksService);
function loadKeywordPage(keyword, url) {
if (!url) {
alert(mgsuite.overlay.aioGetStr("g.keywordMissing") + " " + keyword);
return;
}

switch (mgsuite.overlay.aioWindowType) {
case "browser":
loadURI(url);
break;

default:
if (mgsuite.overlay.aioIsFx) {
openNewTabWith(url);
} else {
openNewTabWindowOrExistingWith(Components.interfaces.nsIBrowserDOMWindow.OPEN_NEWTAB, url, null, false);
}
}
}

var keyword = mgsuite.overlay.aioGetStr("g.keywordForGesture") + suffix;
var shortcutURI = bmsvc.getURIForKeyword(keyword);
if (shortcutURI) shortcutURL = shortcutURI.spec;
if (!shortcutURL) {
alert(mgsuite.overlay.aioGetStr("g.keywordMissing") + " " + keyword);

try {
// try to fetch url keyword using old method (removed in Fx 53)
var url = null;
var bmsvc = Components.classes["@mozilla.org/browser/nav-bookmarks-service;1"].getService(Components.interfaces.nsINavBookmarksService);
var shortcutURI = bmsvc.getURIForKeyword(keyword);
if (shortcutURI) url = shortcutURI.spec;
loadKeywordPage(keyword, url);
return;

} catch (e) {
}

switch (mgsuite.overlay.aioWindowType) {
case "browser":
loadURI(shortcutURL);
break;
if (!url) {
// if old method failed, then try new method (since Fx 40)
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils", "resource://gre/modules/PlacesUtils.jsm");

default:
if (mgsuite.overlay.aioIsFx) {
openNewTabWith(shortcutURL);
} else {
openNewTabWindowOrExistingWith(Components.interfaces.nsIBrowserDOMWindow.OPEN_NEWTAB, shortcutURL, null, false);
}
PlacesUtils.keywords.fetch(keyword).then(entry => {
/* entry is either null, or a keyword entry */
loadKeywordPage(keyword, entry ? entry.url.href : null);
},
e => { /* failure */}
);
}
},

Expand Down
13 changes: 12 additions & 1 deletion source/chrome/content/allinonegest/pref/customize.js
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,10 @@ function populateTree(aGesturesString, aFuncsString, aRockerString, customGestur
}

function ReadFile(file) {
if (typeof Services == 'undefined') {
Components.utils.import('resource://gre/modules/Services.jsm');
}

var ioService=Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
var scriptableStream=Components
Expand All @@ -644,7 +648,14 @@ function ReadFile(file) {


// newChannel was deprecated in Fx 48 in favour of newChannel2
var channel = ioService.newChannel2 ? ioService.newChannel2(file,null,null,null,null,null,null,null)
var channel = ioService.newChannel2 ? ioService.newChannel2(file,
null,
null,
null,
Services.scriptSecurityManager.getSystemPrincipal(),
Services.scriptSecurityManager.getSystemPrincipal(),
null,
null)
: ioService.newChannel(file,null,null);
var input=channel.open();
scriptableStream.init(input);
Expand Down
6 changes: 3 additions & 3 deletions source/install.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<rdf:Description rdf:about="urn:mozilla:install-manifest">
<em:id>mousegesturessuite@lemon_juice.addons.mozilla.org</em:id>
<em:version>2.5.0</em:version>
<em:version>2.5.1</em:version>
<em:type>2</em:type>
<em:unpack>true</em:unpack>
<em:multiprocessCompatible>true</em:multiprocessCompatible>
Expand All @@ -13,7 +13,7 @@
<Description>
<em:id>{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}</em:id>
<em:minVersion>2.22</em:minVersion>
<em:maxVersion>2.45.*</em:maxVersion>
<em:maxVersion>2.49.*</em:maxVersion>
</Description>
</em:targetApplication>

Expand All @@ -22,7 +22,7 @@
<rdf:Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>25.0</em:minVersion>
<em:maxVersion>50.*</em:maxVersion>
<em:maxVersion>56.*</em:maxVersion>
</rdf:Description>
</em:targetApplication>

Expand Down

0 comments on commit c3bb888

Please sign in to comment.