Register protocol handler dynamically
Fixes reader but not reports yet.
This commit is contained in:
parent
2f49999a0f
commit
506482551d
3 changed files with 27 additions and 24 deletions
|
@ -66,9 +66,6 @@ skin zotero default chrome/skin/default/zotero/
|
|||
component {06a2ed11-d0a4-4ff0-a56f-a44545eee6ea} components/zotero-autocomplete.js
|
||||
contract @mozilla.org/autocomplete/search;1?name=zotero {06a2ed11-d0a4-4ff0-a56f-a44545eee6ea}
|
||||
|
||||
component {9BC3D762-9038-486A-9D70-C997AF848A7C} components/zotero-protocol-handler.js process=main
|
||||
contract @mozilla.org/network/protocol;1?name=zotero {9BC3D762-9038-486A-9D70-C997AF848A7C} process=main
|
||||
|
||||
# Scaffold
|
||||
content scaffold chrome/content/scaffold/
|
||||
locale scaffold en-US chrome/locale/en-US/scaffold/
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
***** END LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
const EXPORTED_SYMBOLS = ['ZoteroProtocolHandler'];
|
||||
|
||||
const ZOTERO_SCHEME = "zotero";
|
||||
const ZOTERO_PROTOCOL_CID = Components.ID("{9BC3D762-9038-486A-9D70-C997AF848A7C}");
|
||||
const ZOTERO_PROTOCOL_CONTRACTID = "@mozilla.org/network/protocol;1?name=" + ZOTERO_SCHEME;
|
||||
|
@ -44,9 +46,7 @@ const ios = Services.io;
|
|||
// Dummy chrome URL used to obtain a valid chrome channel
|
||||
const DUMMY_CHROME_URL = "chrome://zotero/content/zoteroPane.xul";
|
||||
|
||||
var Zotero = Components.classes["@zotero.org/Zotero;1"]
|
||||
.getService(Components.interfaces.nsISupports)
|
||||
.wrappedJSObject;
|
||||
var { Zotero } = ChromeUtils.importESModule("chrome://zotero/content/zotero.mjs");
|
||||
|
||||
function ZoteroProtocolHandler() {
|
||||
this.wrappedJSObject = this;
|
||||
|
@ -1261,22 +1261,14 @@ ZoteroProtocolHandler.prototype = {
|
|||
get scheme() {
|
||||
return ZOTERO_SCHEME;
|
||||
},
|
||||
get protocolFlags() {
|
||||
/*Components.interfaces.nsIProtocolHandler.URI_NORELATIVE |
|
||||
Components.interfaces.nsIProtocolHandler.URI_NOAUTH |
|
||||
// DEBUG: This should be URI_IS_LOCAL_FILE, and MUST be if any
|
||||
// extensions that modify data are added
|
||||
// - https://www.zotero.org/trac/ticket/1156
|
||||
//
|
||||
Components.interfaces.nsIProtocolHandler.URI_IS_LOCAL_FILE,
|
||||
//Components.interfaces.nsIProtocolHandler.URI_LOADABLE_BY_ANYONE,*/
|
||||
|
||||
return Ci.nsIProtocolHandler.URI_NORELATIVE
|
||||
protocolFlags:
|
||||
Ci.nsIProtocolHandler.URI_NORELATIVE
|
||||
| Ci.nsIProtocolHandler.URI_NOAUTH
|
||||
| Ci.nsIProtocolHandler.URI_INHERITS_SECURITY_CONTEXT
|
||||
| Ci.nsIProtocolHandler.URI_LOADABLE_BY_ANYONE
|
||||
| Ci.nsIProtocolHandler.URI_NON_PERSISTABLE
|
||||
| Ci.nsIProtocolHandler.URI_IS_LOCAL_RESOURCE
|
||||
// URI_IS_UI_RESOURCE: more secure than URI_LOADABLE_BY_ANYONE, less secure than URI_DANGEROUS_TO_LOAD
|
||||
// This is the security level used by the chrome:// protocol
|
||||
| Ci.nsIProtocolHandler.URI_IS_UI_RESOURCE;
|
||||
},
|
||||
| Ci.nsIProtocolHandler.URI_SYNC_LOAD_IS_OK,
|
||||
get defaultPort() {
|
||||
return -1;
|
||||
},
|
||||
|
@ -1370,6 +1362,18 @@ ZoteroProtocolHandler.prototype = {
|
|||
QueryInterface: ChromeUtils.generateQI([Ci.nsISupportsWeakReference, Ci.nsIProtocolHandler]),
|
||||
};
|
||||
|
||||
/**
|
||||
* @static
|
||||
*/
|
||||
ZoteroProtocolHandler.init = function () {
|
||||
Services.io.registerProtocolHandler(
|
||||
'zotero',
|
||||
new ZoteroProtocolHandler(),
|
||||
ZoteroProtocolHandler.prototype.protocolFlags,
|
||||
ZoteroProtocolHandler.prototype.defaultPort
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* nsIChannel implementation that takes a promise-yielding generator that returns a
|
||||
|
@ -1569,6 +1573,3 @@ AsyncChannel.prototype = {
|
|||
/*pdf.js wants this
|
||||
|| iid.equals(Components.interfaces.nsIWritablePropertyBag)) {*/
|
||||
};
|
||||
|
||||
|
||||
var NSGetFactory = ComponentUtils.generateNSGetFactory([ZoteroProtocolHandler]);
|
|
@ -669,6 +669,11 @@ Services.scriptloader.loadSubScript("resource://zotero/polyfill.js");
|
|||
throw e;
|
||||
}
|
||||
|
||||
const { ZoteroProtocolHandler } = ChromeUtils.import(
|
||||
`chrome://zotero/content/ZoteroProtocolHandler.jsm`
|
||||
);
|
||||
ZoteroProtocolHandler.init();
|
||||
|
||||
yield Zotero.Users.init();
|
||||
yield Zotero.Libraries.init();
|
||||
|
||||
|
|
Loading…
Reference in a new issue