addresses #1690, Modify all XPCOM components for Firefox 4.0b2+
This commit is contained in:
parent
59817af546
commit
63e08cd714
|
@ -50,3 +50,16 @@ overlay chrome://browser/content/browser.xul chrome://zotero/content/itemPane.xu
|
||||||
|
|
||||||
style chrome://browser/content/browser.xul chrome://zotero/skin/zotero.css
|
style chrome://browser/content/browser.xul chrome://zotero/skin/zotero.css
|
||||||
style chrome://global/content/customizeToolbar.xul chrome://zotero/skin/zotero.css
|
style chrome://global/content/customizeToolbar.xul chrome://zotero/skin/zotero.css
|
||||||
|
|
||||||
|
component {e4c61080-ec2d-11da-8ad9-0800200c9a66} components/zotero-service.js
|
||||||
|
contract @zotero.org/Zotero;1 {e4c61080-ec2d-11da-8ad9-0800200c9a66}
|
||||||
|
|
||||||
|
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
|
||||||
|
contract @mozilla.org/network/protocol;1?name=Zotero {9BC3D762-9038-486A-9D70-C997AF848A7C}
|
||||||
|
|
||||||
|
component {531828f8-a16c-46be-b9aa-14845c3b010f} components/zotero-integration-service.js
|
||||||
|
contract @mozilla.org/commandlinehandler/general-startup;1?type=zotero-integration {531828f8-a16c-46be-b9aa-14845c3b010f}
|
||||||
|
category command-line-handler m-zotero-integration @mozilla.org/commandlinehandler/general-startup;1?type=zotero-integration
|
||||||
|
|
|
@ -188,30 +188,33 @@ var Zotero = new function(){
|
||||||
|
|
||||||
var appInfo =
|
var appInfo =
|
||||||
Components.classes["@mozilla.org/xre/app-info;1"].
|
Components.classes["@mozilla.org/xre/app-info;1"].
|
||||||
getService(Components.interfaces.nsIXULAppInfo)
|
getService(Components.interfaces.nsIXULAppInfo);
|
||||||
|
this.appName = appInfo.name;
|
||||||
|
this.isFx2 = appInfo.platformVersion.indexOf('1.8') === 0; // TODO: remove
|
||||||
|
this.isFx3 = appInfo.platformVersion.indexOf('1.9') === 0;
|
||||||
|
this.isFx30 = appInfo.platformVersion == '1.9'
|
||||||
|
|| appInfo.platformVersion.indexOf('1.9.0') === 0;
|
||||||
|
this.isFx35 = appInfo.platformVersion.indexOf('1.9.1') === 0;
|
||||||
|
this.isFx31 = this.isFx35;
|
||||||
|
this.isFx36 = appInfo.platformVersion.indexOf('1.9.2') === 0;
|
||||||
|
this.isFx4 = appInfo.platformVersion[0] == 2;
|
||||||
|
|
||||||
this.isStandalone = appInfo.ID == ZOTERO_CONFIG['GUID'];
|
this.isStandalone = appInfo.ID == ZOTERO_CONFIG['GUID'];
|
||||||
Zotero.debug(this.isStandalone);
|
|
||||||
if(this.isStandalone) {
|
if(this.isStandalone) {
|
||||||
this.isFx35 = true;
|
|
||||||
this.version = appInfo.version;
|
this.version = appInfo.version;
|
||||||
} else {
|
} else {
|
||||||
this.appName = appInfo.name;
|
|
||||||
this.isFx2 = appInfo.platformVersion.indexOf('1.8') === 0; // TODO: remove
|
|
||||||
this.isFx3 = appInfo.platformVersion.indexOf('1.9') === 0;
|
|
||||||
this.isFx30 = appInfo.platformVersion == '1.9'
|
|
||||||
|| appInfo.platformVersion.indexOf('1.9.0') === 0;
|
|
||||||
this.isFx35 = appInfo.platformVersion.indexOf('1.9.1') === 0;
|
|
||||||
this.isFx31 = this.isFx35;
|
|
||||||
|
|
||||||
// Load in the extension version from the extension manager
|
// Load in the extension version from the extension manager
|
||||||
var nsIUpdateItem = Components.interfaces.nsIUpdateItem;
|
if(this.isFx4) {
|
||||||
var gExtensionManager =
|
AddonManager.getAddonByID(ZOTERO_CONFIG['GUID'],
|
||||||
Components.classes["@mozilla.org/extensions/manager;1"]
|
function(addon) { Zotero.version = addon.version });
|
||||||
.getService(Components.interfaces.nsIExtensionManager);
|
} else {
|
||||||
this.version
|
var gExtensionManager =
|
||||||
= gExtensionManager.getItemForID(ZOTERO_CONFIG['GUID']).version;
|
Components.classes["@mozilla.org/extensions/manager;1"]
|
||||||
|
.getService(Components.interfaces.nsIExtensionManager);
|
||||||
|
this.version
|
||||||
|
= gExtensionManager.getItemForID(ZOTERO_CONFIG['GUID']).version;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.isFx36 = appInfo.platformVersion.indexOf('1.9.2') === 0;
|
|
||||||
|
|
||||||
// OS platform
|
// OS platform
|
||||||
var win = Components.classes["@mozilla.org/appshell/appShellService;1"]
|
var win = Components.classes["@mozilla.org/appshell/appShellService;1"]
|
||||||
|
@ -223,6 +226,13 @@ var Zotero = new function(){
|
||||||
this.isLinux = (this.platform.substr(0, 5) == "Linux");
|
this.isLinux = (this.platform.substr(0, 5) == "Linux");
|
||||||
this.oscpu = win.navigator.oscpu;
|
this.oscpu = win.navigator.oscpu;
|
||||||
|
|
||||||
|
// Installed extensions (Fx4 only)
|
||||||
|
if(this.isFx4) {
|
||||||
|
AddonManager.getAllAddons(function(addonList) {
|
||||||
|
Zotero.addons = addonList;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Locale
|
// Locale
|
||||||
var ph = Components.classes["@mozilla.org/network/protocol;1?name=http"].
|
var ph = Components.classes["@mozilla.org/network/protocol;1?name=http"].
|
||||||
getService(Components.interfaces.nsIHttpProtocolHandler);
|
getService(Components.interfaces.nsIHttpProtocolHandler);
|
||||||
|
@ -398,11 +408,10 @@ var Zotero = new function(){
|
||||||
Zotero.Schema.updateCustomTables();
|
Zotero.Schema.updateCustomTables();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize integration web server
|
// Initialize various services
|
||||||
Zotero.Integration.init();
|
Zotero.Integration.init();
|
||||||
|
Zotero.Connector.init();
|
||||||
|
|
||||||
// Initialize data web server
|
|
||||||
Zotero.DataServer.init();
|
|
||||||
Zotero.Zeroconf.init();
|
Zotero.Zeroconf.init();
|
||||||
|
|
||||||
Zotero.Sync.init();
|
Zotero.Sync.init();
|
||||||
|
@ -457,10 +466,25 @@ var Zotero = new function(){
|
||||||
Zotero.debug(dir.path);
|
Zotero.debug(dir.path);
|
||||||
return dir;
|
return dir;
|
||||||
} else {
|
} else {
|
||||||
var id = ZOTERO_CONFIG.GUID;
|
if(this.isFx4) {
|
||||||
var em = Components.classes["@mozilla.org/extensions/manager;1"].
|
/* TODO:
|
||||||
getService(Components.interfaces.nsIExtensionManager);
|
From https://developer.mozilla.org/en/Firefox_4_for_developers:
|
||||||
return em.getInstallLocation(id).getItemLocation(id);
|
nsIExtensionManager has been replaced by AddonManager. Since there is
|
||||||
|
apparently no way at present to obtain the install location from a given
|
||||||
|
extension ID, the closest workaround is to use the directory service to
|
||||||
|
find the profile directory and append "extensions" to it (though this
|
||||||
|
approach will not catch extensions outside of the profile directory or
|
||||||
|
those which are aliased to another location). */
|
||||||
|
var profDir = getProfileDirectory();
|
||||||
|
profDir.append("extensions");
|
||||||
|
profDir.append(ZOTERO_CONFIG.GUID);
|
||||||
|
return profDir;
|
||||||
|
} else {
|
||||||
|
var id = ZOTERO_CONFIG.GUID;
|
||||||
|
var em = Components.classes["@mozilla.org/extensions/manager;1"].
|
||||||
|
getService(Components.interfaces.nsIExtensionManager);
|
||||||
|
return em.getInstallLocation(id).getItemLocation(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -782,11 +806,15 @@ var Zotero = new function(){
|
||||||
* @return {String[]} Array of extension names and versions
|
* @return {String[]} Array of extension names and versions
|
||||||
*/
|
*/
|
||||||
this.getInstalledExtensions = function () {
|
this.getInstalledExtensions = function () {
|
||||||
var em = Components.classes["@mozilla.org/extensions/manager;1"].
|
if(this.isFx4) {
|
||||||
getService(Components.interfaces.nsIExtensionManager);
|
var installed = Zotero.addons;
|
||||||
var installed = em.getItemList(
|
} else {
|
||||||
Components.interfaces.nsIUpdateItem.TYPE_ANY, {}
|
var em = Components.classes["@mozilla.org/extensions/manager;1"].
|
||||||
);
|
getService(Components.interfaces.nsIExtensionManager);
|
||||||
|
var installed = em.getItemList(
|
||||||
|
Components.interfaces.nsIUpdateItem.TYPE_ANY, {}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
var addons = [];
|
var addons = [];
|
||||||
for each(var addon in installed) {
|
for each(var addon in installed) {
|
||||||
|
|
|
@ -31,6 +31,7 @@ const Cc = Components.classes;
|
||||||
const Ci = Components.interfaces;
|
const Ci = Components.interfaces;
|
||||||
const Cr = Components.results;
|
const Cr = Components.results;
|
||||||
|
|
||||||
|
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Implements nsIAutoCompleteSearch
|
* Implements nsIAutoCompleteSearch
|
||||||
|
@ -335,68 +336,24 @@ ZoteroAutoComplete.prototype.stopSearch = function(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ZoteroAutoComplete.prototype.QueryInterface = function(iid){
|
|
||||||
if (!iid.equals(Ci.nsIAutoCompleteSearch) &&
|
|
||||||
!iid.equals(Ci.nsIAutoCompleteObserver) &&
|
|
||||||
!iid.equals(Ci.nsISupports)){
|
|
||||||
throw Cr.NS_ERROR_NO_INTERFACE;
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// XPCOM goop
|
// XPCOM goop
|
||||||
//
|
//
|
||||||
var ZoteroAutoCompleteFactory = {
|
|
||||||
createInstance: function(outer, iid){
|
|
||||||
if (outer != null){
|
|
||||||
throw Components.results.NS_ERROR_NO_AGGREGATION;
|
|
||||||
}
|
|
||||||
return new ZoteroAutoComplete().QueryInterface(iid);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
ZoteroAutoComplete.prototype.classDescription = ZOTERO_AC_CLASSNAME;
|
||||||
|
ZoteroAutoComplete.prototype.classID = ZOTERO_AC_CID;
|
||||||
|
ZoteroAutoComplete.prototype.contractID = ZOTERO_AC_CONTRACTID;
|
||||||
|
ZoteroAutoComplete.prototype.QueryInterface = XPCOMUtils.generateQI([
|
||||||
|
Components.interfaces.nsIAutoCompleteSearch,
|
||||||
|
Components.interfaces.nsIAutoCompleteObserver,
|
||||||
|
Components.interfaces.nsISupports]);
|
||||||
|
|
||||||
var ZoteroAutoCompleteModule = {
|
/**
|
||||||
_firstTime: true,
|
* XPCOMUtils.generateNSGetFactory was introduced in Mozilla 2 (Firefox 4).
|
||||||
|
* XPCOMUtils.generateNSGetModule is for Mozilla 1.9.2 (Firefox 3.6).
|
||||||
registerSelf: function(compMgr, fileSpec, location, type){
|
*/
|
||||||
if (!this._firstTime){
|
if (XPCOMUtils.generateNSGetFactory) {
|
||||||
throw Components.results.NS_ERROR_FACTORY_REGISTER_AGAIN;
|
var NSGetFactory = XPCOMUtils.generateNSGetFactory([ZoteroAutoComplete]);
|
||||||
}
|
} else {
|
||||||
this._firstTime = false;
|
var NSGetModule = XPCOMUtils.generateNSGetModule([ZoteroAutoComplete]);
|
||||||
|
}
|
||||||
compMgr =
|
|
||||||
compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
|
|
||||||
|
|
||||||
compMgr.registerFactoryLocation(ZOTERO_AC_CID,
|
|
||||||
ZOTERO_AC_CLASSNAME,
|
|
||||||
ZOTERO_AC_CONTRACTID,
|
|
||||||
fileSpec,
|
|
||||||
location,
|
|
||||||
type);
|
|
||||||
},
|
|
||||||
|
|
||||||
unregisterSelf: function(compMgr, location, type){
|
|
||||||
compMgr =
|
|
||||||
compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
|
|
||||||
compMgr.unregisterFactoryLocation(ZOTERO_AC_CID, location);
|
|
||||||
},
|
|
||||||
|
|
||||||
getClassObject: function(compMgr, cid, iid){
|
|
||||||
if (!cid.equals(ZOTERO_AC_CID)){
|
|
||||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
|
||||||
}
|
|
||||||
if (!iid.equals(Components.interfaces.nsIFactory)){
|
|
||||||
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
|
|
||||||
}
|
|
||||||
return ZoteroAutoCompleteFactory;
|
|
||||||
},
|
|
||||||
|
|
||||||
canUnload: function(compMgr){ return true; }
|
|
||||||
};
|
|
||||||
|
|
||||||
function NSGetModule(comMgr, fileSpec){ return ZoteroAutoCompleteModule; }
|
|
|
@ -1,3 +1,32 @@
|
||||||
|
/*
|
||||||
|
***** BEGIN LICENSE BLOCK *****
|
||||||
|
|
||||||
|
Copyright © 2009 Center for History and New Media
|
||||||
|
George Mason University, Fairfax, Virginia, USA
|
||||||
|
http://zotero.org
|
||||||
|
|
||||||
|
This file is part of Zotero.
|
||||||
|
|
||||||
|
Zotero is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Zotero is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
|
Based on nsChromeExtensionHandler example code by Ed Anuff at
|
||||||
|
http://kb.mozillazine.org/Dev_:_Extending_the_Chrome_Protocol
|
||||||
|
|
||||||
|
***** END LICENSE BLOCK *****
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Based on nsICommandLineHandler example code at
|
Based on nsICommandLineHandler example code at
|
||||||
https://developer.mozilla.org/en/Chrome/Command_Line
|
https://developer.mozilla.org/en/Chrome/Command_Line
|
||||||
|
@ -15,12 +44,15 @@ const nsIWindowWatcher = Components.interfaces.nsIWindowWatcher;
|
||||||
const clh_contractID = "@mozilla.org/commandlinehandler/general-startup;1?type=zotero-integration";
|
const clh_contractID = "@mozilla.org/commandlinehandler/general-startup;1?type=zotero-integration";
|
||||||
const clh_CID = Components.ID("{531828f8-a16c-46be-b9aa-14845c3b010f}");
|
const clh_CID = Components.ID("{531828f8-a16c-46be-b9aa-14845c3b010f}");
|
||||||
const clh_category = "m-zotero-integration";
|
const clh_category = "m-zotero-integration";
|
||||||
|
const clh_description = "Zotero Integration Command Line Handler";
|
||||||
|
|
||||||
|
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The XPCOM component that implements nsICommandLineHandler.
|
* The XPCOM component that implements nsICommandLineHandler.
|
||||||
* It also implements nsIFactory to serve as its own singleton factory.
|
|
||||||
*/
|
*/
|
||||||
const ZoteroIntegrationCommandLineHandler = {
|
function ZoteroIntegrationCommandLineHandler() {}
|
||||||
|
ZoteroIntegrationCommandLineHandler.prototype = {
|
||||||
Zotero : null,
|
Zotero : null,
|
||||||
|
|
||||||
/* nsISupports */
|
/* nsISupports */
|
||||||
|
@ -47,65 +79,21 @@ const ZoteroIntegrationCommandLineHandler = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/* nsIFactory */
|
classDescription: clh_description,
|
||||||
createInstance : function(outer, iid) {
|
classID: clh_CID,
|
||||||
if (outer != null) throw Components.results.NS_ERROR_NO_AGGREGATION;
|
contractID: clh_contractID,
|
||||||
return this.QueryInterface(iid);
|
service: true,
|
||||||
},
|
_xpcom_categories: [{category:"command-line-handler", entry:clh_category}],
|
||||||
|
QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsICommandLineHandler,
|
||||||
lockFactory : function(lock) {
|
Components.interfaces.nsISupports])
|
||||||
/* no-op */
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The XPCOM glue that implements nsIModule
|
* XPCOMUtils.generateNSGetFactory was introduced in Mozilla 2 (Firefox 4).
|
||||||
*/
|
* XPCOMUtils.generateNSGetModule is for Mozilla 1.9.2 (Firefox 3.6).
|
||||||
const ZoteroIntegrationModule = {
|
*/
|
||||||
/* nsISupports */
|
if (XPCOMUtils.generateNSGetFactory) {
|
||||||
QueryInterface : function(iid) {
|
var NSGetFactory = XPCOMUtils.generateNSGetFactory([ZoteroIntegrationCommandLineHandler]);
|
||||||
if(iid.equals(nsIModule) || iid.equals(nsISupports)) return this;
|
} else {
|
||||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
var NSGetModule = XPCOMUtils.generateNSGetModule([ZoteroIntegrationCommandLineHandler]);
|
||||||
},
|
}
|
||||||
|
|
||||||
/* nsIModule */
|
|
||||||
getClassObject : function(compMgr, cid, iid) {
|
|
||||||
if(cid.equals(clh_CID)) return ZoteroIntegrationCommandLineHandler.QueryInterface(iid);
|
|
||||||
throw Components.results.NS_ERROR_NOT_REGISTERED;
|
|
||||||
},
|
|
||||||
|
|
||||||
registerSelf : function(compMgr, fileSpec, location, type) {
|
|
||||||
compMgr.QueryInterface(nsIComponentRegistrar);
|
|
||||||
|
|
||||||
compMgr.registerFactoryLocation(clh_CID,
|
|
||||||
"myAppHandler",
|
|
||||||
clh_contractID,
|
|
||||||
fileSpec,
|
|
||||||
location,
|
|
||||||
type);
|
|
||||||
|
|
||||||
var catMan = Components.classes["@mozilla.org/categorymanager;1"].
|
|
||||||
getService(nsICategoryManager);
|
|
||||||
catMan.addCategoryEntry("command-line-handler",
|
|
||||||
clh_category,
|
|
||||||
clh_contractID, true, true);
|
|
||||||
},
|
|
||||||
|
|
||||||
unregisterSelf : function(compMgr, location, type) {
|
|
||||||
compMgr.QueryInterface(nsIComponentRegistrar);
|
|
||||||
compMgr.unregisterFactoryLocation(clh_CID, location);
|
|
||||||
|
|
||||||
var catMan = Components.classes["@mozilla.org/categorymanager;1"].
|
|
||||||
getService(nsICategoryManager);
|
|
||||||
catMan.deleteCategoryEntry("command-line-handler", clh_category);
|
|
||||||
},
|
|
||||||
|
|
||||||
canUnload : function (compMgr) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/* The NSGetModule function is the magic entry point that XPCOM uses to find what XPCOM objects
|
|
||||||
* this component provides
|
|
||||||
*/
|
|
||||||
function NSGetModule(comMgr, fileSpec){ return ZoteroIntegrationModule; }
|
|
|
@ -27,12 +27,13 @@
|
||||||
***** END LICENSE BLOCK *****
|
***** END LICENSE BLOCK *****
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
const ZOTERO_SCHEME = "zotero";
|
const ZOTERO_SCHEME = "zotero";
|
||||||
const ZOTERO_PROTOCOL_CID = Components.ID("{9BC3D762-9038-486A-9D70-C997AF848A7C}");
|
const ZOTERO_PROTOCOL_CID = Components.ID("{9BC3D762-9038-486A-9D70-C997AF848A7C}");
|
||||||
const ZOTERO_PROTOCOL_CONTRACTID = "@mozilla.org/network/protocol;1?name=" + ZOTERO_SCHEME;
|
const ZOTERO_PROTOCOL_CONTRACTID = "@mozilla.org/network/protocol;1?name=" + ZOTERO_SCHEME;
|
||||||
const ZOTERO_PROTOCOL_NAME = "Zotero Chrome Extension Protocol";
|
const ZOTERO_PROTOCOL_NAME = "Zotero Chrome Extension Protocol";
|
||||||
|
|
||||||
|
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||||
|
|
||||||
// Dummy chrome URL used to obtain a valid chrome channel
|
// Dummy chrome URL used to obtain a valid chrome channel
|
||||||
// This one was chosen at random and should be able to be substituted
|
// This one was chosen at random and should be able to be substituted
|
||||||
// for any other well known chrome URL in the browser installation
|
// for any other well known chrome URL in the browser installation
|
||||||
|
@ -943,7 +944,6 @@ function ChromeExtensionHandler() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
var ReportExtensionSpec = ZOTERO_SCHEME + "://report"
|
var ReportExtensionSpec = ZOTERO_SCHEME + "://report"
|
||||||
this._extensions[ReportExtensionSpec] = ReportExtension;
|
this._extensions[ReportExtensionSpec] = ReportExtension;
|
||||||
|
|
||||||
|
@ -1035,7 +1035,7 @@ ChromeExtensionHandler.prototype = {
|
||||||
extChannel.owner = this._systemPrincipal;
|
extChannel.owner = this._systemPrincipal;
|
||||||
}
|
}
|
||||||
|
|
||||||
extChannel.originalURI = uri;
|
if(!extChannel.originalURI) extChannel.originalURI = uri;
|
||||||
|
|
||||||
return extChannel;
|
return extChannel;
|
||||||
}
|
}
|
||||||
|
@ -1057,62 +1057,23 @@ ChromeExtensionHandler.prototype = {
|
||||||
return newChannel;
|
return newChannel;
|
||||||
},
|
},
|
||||||
|
|
||||||
QueryInterface : function(iid) {
|
contractID: ZOTERO_PROTOCOL_CONTRACTID,
|
||||||
if (!iid.equals(Components.interfaces.nsIProtocolHandler) &&
|
classDescription: ZOTERO_PROTOCOL_NAME,
|
||||||
!iid.equals(Components.interfaces.nsISupports)) {
|
classID: ZOTERO_PROTOCOL_CID,
|
||||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsISupports,
|
||||||
}
|
Components.interfaces.nsIProtocolHandler])
|
||||||
return this;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// XPCOM goop
|
// XPCOM goop
|
||||||
//
|
//
|
||||||
|
|
||||||
var ChromeExtensionModule = {
|
/**
|
||||||
cid: ZOTERO_PROTOCOL_CID,
|
* XPCOMUtils.generateNSGetFactory was introduced in Mozilla 2 (Firefox 4).
|
||||||
|
* XPCOMUtils.generateNSGetModule is for Mozilla 1.9.2 (Firefox 3.6).
|
||||||
contractId: ZOTERO_PROTOCOL_CONTRACTID,
|
*/
|
||||||
|
if (XPCOMUtils.generateNSGetFactory) {
|
||||||
registerSelf : function(compMgr, fileSpec, location, type) {
|
var NSGetFactory = XPCOMUtils.generateNSGetFactory([ChromeExtensionHandler]);
|
||||||
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
|
} else {
|
||||||
compMgr.registerFactoryLocation(
|
var NSGetModule = XPCOMUtils.generateNSGetModule([ChromeExtensionHandler]);
|
||||||
ZOTERO_PROTOCOL_CID,
|
|
||||||
ZOTERO_PROTOCOL_NAME,
|
|
||||||
ZOTERO_PROTOCOL_CONTRACTID,
|
|
||||||
fileSpec,
|
|
||||||
location,
|
|
||||||
type
|
|
||||||
);
|
|
||||||
},
|
|
||||||
|
|
||||||
getClassObject : function(compMgr, cid, iid) {
|
|
||||||
if (!cid.equals(ZOTERO_PROTOCOL_CID)) {
|
|
||||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
|
||||||
}
|
|
||||||
if (!iid.equals(Components.interfaces.nsIFactory)) {
|
|
||||||
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
|
|
||||||
}
|
|
||||||
return this.myFactory;
|
|
||||||
},
|
|
||||||
|
|
||||||
canUnload : function(compMgr) {
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
|
|
||||||
myFactory : {
|
|
||||||
createInstance : function(outer, iid) {
|
|
||||||
if (outer != null) {
|
|
||||||
throw Components.results.NS_ERROR_NO_AGGREGATION;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new ChromeExtensionHandler().QueryInterface(iid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
function NSGetModule(compMgr, fileSpec) {
|
|
||||||
return ChromeExtensionModule;
|
|
||||||
}
|
}
|
|
@ -1,3 +1,32 @@
|
||||||
|
/*
|
||||||
|
***** BEGIN LICENSE BLOCK *****
|
||||||
|
|
||||||
|
Copyright © 2009 Center for History and New Media
|
||||||
|
George Mason University, Fairfax, Virginia, USA
|
||||||
|
http://zotero.org
|
||||||
|
|
||||||
|
This file is part of Zotero.
|
||||||
|
|
||||||
|
Zotero is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Zotero is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
|
Based on nsChromeExtensionHandler example code by Ed Anuff at
|
||||||
|
http://kb.mozillazine.org/Dev_:_Extending_the_Chrome_Protocol
|
||||||
|
|
||||||
|
***** END LICENSE BLOCK *****
|
||||||
|
*/
|
||||||
|
|
||||||
const ZOTERO_CONTRACTID = '@zotero.org/Zotero;1';
|
const ZOTERO_CONTRACTID = '@zotero.org/Zotero;1';
|
||||||
const ZOTERO_CLASSNAME = 'Zotero';
|
const ZOTERO_CLASSNAME = 'Zotero';
|
||||||
const ZOTERO_CID = Components.ID('{e4c61080-ec2d-11da-8ad9-0800200c9a66}');
|
const ZOTERO_CID = Components.ID('{e4c61080-ec2d-11da-8ad9-0800200c9a66}');
|
||||||
|
@ -6,10 +35,17 @@ const ZOTERO_IID = Components.interfaces.chnmIZoteroService; //unused
|
||||||
const Cc = Components.classes;
|
const Cc = Components.classes;
|
||||||
const Ci = Components.interfaces;
|
const Ci = Components.interfaces;
|
||||||
|
|
||||||
|
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||||
|
|
||||||
|
var appInfo = Components.classes["@mozilla.org/xre/app-info;1"].
|
||||||
|
getService(Components.interfaces.nsIXULAppInfo);
|
||||||
|
if(appInfo.platformVersion[0] == 2) {
|
||||||
|
Components.utils.import("resource://gre/modules/AddonManager.jsm");
|
||||||
|
}
|
||||||
|
|
||||||
// Assign the global scope to a variable to passed via wrappedJSObject
|
// Assign the global scope to a variable to passed via wrappedJSObject
|
||||||
var ZoteroWrapped = this;
|
var ZoteroWrapped = this;
|
||||||
|
|
||||||
|
|
||||||
/********************************************************************
|
/********************************************************************
|
||||||
* Include the core objects to be stored within XPCOM
|
* Include the core objects to be stored within XPCOM
|
||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
|
@ -154,6 +190,7 @@ function ZoteroService(){
|
||||||
/**
|
/**
|
||||||
* Convenience method to replicate window.alert()
|
* Convenience method to replicate window.alert()
|
||||||
**/
|
**/
|
||||||
|
// TODO: is this still used? if so, move to zotero.js
|
||||||
function alert(msg){
|
function alert(msg){
|
||||||
Cc["@mozilla.org/embedcomp/prompt-service;1"]
|
Cc["@mozilla.org/embedcomp/prompt-service;1"]
|
||||||
.getService(Ci.nsIPromptService)
|
.getService(Ci.nsIPromptService)
|
||||||
|
@ -163,6 +200,7 @@ function alert(msg){
|
||||||
/**
|
/**
|
||||||
* Convenience method to replicate window.confirm()
|
* Convenience method to replicate window.confirm()
|
||||||
**/
|
**/
|
||||||
|
// TODO: is this still used? if so, move to zotero.js
|
||||||
function confirm(msg){
|
function confirm(msg){
|
||||||
return Cc["@mozilla.org/embedcomp/prompt-service;1"]
|
return Cc["@mozilla.org/embedcomp/prompt-service;1"]
|
||||||
.getService(Ci.nsIPromptService)
|
.getService(Ci.nsIPromptService)
|
||||||
|
@ -173,6 +211,7 @@ function confirm(msg){
|
||||||
/**
|
/**
|
||||||
* Convenience method to replicate window.setTimeout()
|
* Convenience method to replicate window.setTimeout()
|
||||||
**/
|
**/
|
||||||
|
// TODO: is this still used? if so, move to zotero.js
|
||||||
function setTimeout(func, ms){
|
function setTimeout(func, ms){
|
||||||
var timer = Components.classes["@mozilla.org/timer;1"].
|
var timer = Components.classes["@mozilla.org/timer;1"].
|
||||||
createInstance(Components.interfaces.nsITimer);
|
createInstance(Components.interfaces.nsITimer);
|
||||||
|
@ -186,64 +225,21 @@ function setTimeout(func, ms){
|
||||||
//
|
//
|
||||||
// XPCOM goop
|
// XPCOM goop
|
||||||
//
|
//
|
||||||
|
|
||||||
ZoteroService.prototype = {
|
ZoteroService.prototype = {
|
||||||
QueryInterface: function(iid){
|
contractID: ZOTERO_CONTRACTID,
|
||||||
if (!iid.equals(Components.interfaces.nsISupports) &&
|
classDescription: ZOTERO_CLASSNAME,
|
||||||
!iid.equals(ZOTERO_IID)){ // interface unused
|
classID: ZOTERO_CID,
|
||||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
service: true,
|
||||||
}
|
QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsISupports, ZOTERO_IID])
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
/**
|
||||||
var ZoteroFactory = {
|
* XPCOMUtils.generateNSGetFactory was introduced in Mozilla 2 (Firefox 4).
|
||||||
createInstance: function(outer, iid){
|
* XPCOMUtils.generateNSGetModule is for Mozilla 1.9.2 (Firefox 3.6).
|
||||||
if (outer != null){
|
*/
|
||||||
throw Components.results.NS_ERROR_NO_AGGREGATION;
|
if (XPCOMUtils.generateNSGetFactory) {
|
||||||
}
|
var NSGetFactory = XPCOMUtils.generateNSGetFactory([ZoteroService]);
|
||||||
return new ZoteroService().QueryInterface(iid);
|
} else {
|
||||||
}
|
var NSGetModule = XPCOMUtils.generateNSGetModule([ZoteroService]);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
var ZoteroModule = {
|
|
||||||
_firstTime: true,
|
|
||||||
|
|
||||||
registerSelf: function(compMgr, fileSpec, location, type){
|
|
||||||
if (!this._firstTime){
|
|
||||||
throw Components.results.NS_ERROR_FACTORY_REGISTER_AGAIN;
|
|
||||||
}
|
|
||||||
this._firstTime = false;
|
|
||||||
|
|
||||||
compMgr =
|
|
||||||
compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
|
|
||||||
|
|
||||||
compMgr.registerFactoryLocation(ZOTERO_CID,
|
|
||||||
ZOTERO_CLASSNAME,
|
|
||||||
ZOTERO_CONTRACTID,
|
|
||||||
fileSpec,
|
|
||||||
location,
|
|
||||||
type);
|
|
||||||
},
|
|
||||||
|
|
||||||
unregisterSelf: function(compMgr, location, type){
|
|
||||||
compMgr =
|
|
||||||
compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
|
|
||||||
compMgr.unregisterFactoryLocation(ZOTERO_CID, location);
|
|
||||||
},
|
|
||||||
|
|
||||||
getClassObject: function(compMgr, cid, iid){
|
|
||||||
if (!cid.equals(ZOTERO_CID)){
|
|
||||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
|
||||||
}
|
|
||||||
if (!iid.equals(Components.interfaces.nsIFactory)){
|
|
||||||
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
|
|
||||||
}
|
|
||||||
return ZoteroFactory;
|
|
||||||
},
|
|
||||||
|
|
||||||
canUnload: function(compMgr){ return true; }
|
|
||||||
};
|
|
||||||
|
|
||||||
function NSGetModule(comMgr, fileSpec){ return ZoteroModule; }
|
|
Loading…
Reference in New Issue
Block a user