mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Fix for bug 658632 (Provide easy way to add non-leaky classinfo to JS components). r=gavin.
--HG-- extra : rebase_source : 8463c6f8ba1f969278d4e33bfa08495fa3e36071
This commit is contained in:
parent
cede8382a6
commit
ae44770a16
@ -47,6 +47,9 @@ const Cu = Components.utils;
|
|||||||
|
|
||||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||||
|
|
||||||
|
const FEEDWRITER_CID = Components.ID("{49bb6593-3aff-4eb3-a068-2712c28bd58e}");
|
||||||
|
const FEEDWRITER_CONTRACTID = "@mozilla.org/browser/feeds/result-writer;1";
|
||||||
|
|
||||||
function LOG(str) {
|
function LOG(str) {
|
||||||
var prefB = Cc["@mozilla.org/preferences-service;1"].
|
var prefB = Cc["@mozilla.org/preferences-service;1"].
|
||||||
getService(Ci.nsIPrefBranch);
|
getService(Ci.nsIPrefBranch);
|
||||||
@ -1377,17 +1380,12 @@ FeedWriter.prototype = {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// nsIClassInfo
|
classID: FEEDWRITER_CID,
|
||||||
getInterfaces: function FW_getInterfaces(countRef) {
|
classInfo: XPCOMUtils.generateCI({classID: FEEDWRITER_CID,
|
||||||
var interfaces = [Ci.nsIFeedWriter, Ci.nsIClassInfo, Ci.nsISupports];
|
contractID: FEEDWRITER_CONTRACTID,
|
||||||
countRef.value = interfaces.length;
|
interfaces: [Ci.nsIFeedWriter],
|
||||||
return interfaces;
|
flags: Ci.nsIClassInfo.DOM_OBJECT}),
|
||||||
},
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIFeedWriter,
|
||||||
getHelperForLanguage: function FW_getHelperForLanguage(language) null,
|
|
||||||
classID: Components.ID("{49bb6593-3aff-4eb3-a068-2712c28bd58e}"),
|
|
||||||
implementationLanguage: Ci.nsIProgrammingLanguage.JAVASCRIPT,
|
|
||||||
flags: Ci.nsIClassInfo.DOM_OBJECT,
|
|
||||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIFeedWriter, Ci.nsIClassInfo,
|
|
||||||
Ci.nsIDOMEventListener, Ci.nsIObserver,
|
Ci.nsIDOMEventListener, Ci.nsIObserver,
|
||||||
Ci.nsINavHistoryObserver])
|
Ci.nsINavHistoryObserver])
|
||||||
};
|
};
|
||||||
|
@ -911,23 +911,14 @@ WebContentConverterRegistrar.prototype = {
|
|||||||
return this.QueryInterface(iid);
|
return this.QueryInterface(iid);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* See nsIClassInfo
|
|
||||||
*/
|
|
||||||
getInterfaces: function WCCR_getInterfaces(countRef) {
|
|
||||||
var interfaces =
|
|
||||||
[Ci.nsIWebContentConverterService, Ci.nsIWebContentHandlerRegistrar,
|
|
||||||
Ci.nsIObserver, Ci.nsIClassInfo, Ci.nsIFactory, Ci.nsISupports];
|
|
||||||
countRef.value = interfaces.length;
|
|
||||||
return interfaces;
|
|
||||||
},
|
|
||||||
getHelperForLanguage: function WCCR_getHelperForLanguage(language) {
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
classID: WCCR_CLASSID,
|
classID: WCCR_CLASSID,
|
||||||
implementationLanguage: Ci.nsIProgrammingLanguage.JAVASCRIPT,
|
classInfo: XPCOMUtils.generateCI({classID: WCCR_CLASSID,
|
||||||
flags: Ci.nsIClassInfo.DOM_OBJECT,
|
contractID: WCCR_CONTRACTID,
|
||||||
|
interfaces: [Ci.nsIWebContentConverterService,
|
||||||
|
Ci.nsIWebContentHandlerRegistrar,
|
||||||
|
Ci.nsIObserver, Ci.nsIFactory],
|
||||||
|
flags: Ci.nsIClassInfo.DOM_OBJECT}),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See nsISupports
|
* See nsISupports
|
||||||
*/
|
*/
|
||||||
@ -935,9 +926,7 @@ WebContentConverterRegistrar.prototype = {
|
|||||||
[Ci.nsIWebContentConverterService,
|
[Ci.nsIWebContentConverterService,
|
||||||
Ci.nsIWebContentHandlerRegistrar,
|
Ci.nsIWebContentHandlerRegistrar,
|
||||||
Ci.nsIObserver,
|
Ci.nsIObserver,
|
||||||
Ci.nsIClassInfo,
|
Ci.nsIFactory]),
|
||||||
Ci.nsIFactory,
|
|
||||||
Ci.nsISupports]),
|
|
||||||
|
|
||||||
_xpcom_categories: [{
|
_xpcom_categories: [{
|
||||||
category: "app-startup",
|
category: "app-startup",
|
||||||
|
@ -46,8 +46,8 @@ Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
|||||||
|
|
||||||
const DEBUG = false; /* set to false to suppress debug messages */
|
const DEBUG = false; /* set to false to suppress debug messages */
|
||||||
|
|
||||||
|
const SIDEBAR_CONTRACTID = "@mozilla.org/sidebar;1";
|
||||||
const SIDEBAR_CID = Components.ID("{22117140-9c6e-11d3-aaf1-00805f8a4905}");
|
const SIDEBAR_CID = Components.ID("{22117140-9c6e-11d3-aaf1-00805f8a4905}");
|
||||||
const nsISupports = Components.interfaces.nsISupports;
|
|
||||||
const nsISidebar = Components.interfaces.nsISidebar;
|
const nsISidebar = Components.interfaces.nsISidebar;
|
||||||
const nsISidebarExternal = Components.interfaces.nsISidebarExternal;
|
const nsISidebarExternal = Components.interfaces.nsISidebarExternal;
|
||||||
const nsIClassInfo = Components.interfaces.nsIClassInfo;
|
const nsIClassInfo = Components.interfaces.nsIClassInfo;
|
||||||
@ -214,32 +214,13 @@ function (aSearchURL)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// property of nsIClassInfo
|
nsSidebar.prototype.classInfo = XPCOMUtils.generateCI({classID: SIDEBAR_CID,
|
||||||
nsSidebar.prototype.flags = nsIClassInfo.DOM_OBJECT;
|
contractID: SIDEBAR_CONTRACTID,
|
||||||
|
classDescription: "Sidebar",
|
||||||
|
interfaces: [nsISidebar, nsISidebarExternal],
|
||||||
|
flags: nsIClassInfo.DOM_OBJECT});
|
||||||
|
|
||||||
// property of nsIClassInfo
|
nsSidebar.prototype.QueryInterface = XPCOMUtils.generateQI([nsISidebar, nsISidebarExternal]);
|
||||||
nsSidebar.prototype.classDescription = "Sidebar";
|
|
||||||
|
|
||||||
// method of nsIClassInfo
|
|
||||||
nsSidebar.prototype.getInterfaces = function(count) {
|
|
||||||
var interfaceList = [nsISidebar, nsISidebarExternal, nsIClassInfo];
|
|
||||||
count.value = interfaceList.length;
|
|
||||||
return interfaceList;
|
|
||||||
}
|
|
||||||
|
|
||||||
// method of nsIClassInfo
|
|
||||||
nsSidebar.prototype.getHelperForLanguage = function(count) {return null;}
|
|
||||||
|
|
||||||
nsSidebar.prototype.QueryInterface =
|
|
||||||
function (iid) {
|
|
||||||
if (iid.equals(nsISidebar) ||
|
|
||||||
iid.equals(nsISidebarExternal) ||
|
|
||||||
iid.equals(nsIClassInfo) ||
|
|
||||||
iid.equals(nsISupports))
|
|
||||||
return this;
|
|
||||||
|
|
||||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
|
||||||
};
|
|
||||||
|
|
||||||
var NSGetFactory = XPCOMUtils.generateNSGetFactory([nsSidebar]);
|
var NSGetFactory = XPCOMUtils.generateNSGetFactory([nsSidebar]);
|
||||||
|
|
||||||
|
@ -40,6 +40,9 @@ const Cc = Components.classes;
|
|||||||
|
|
||||||
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||||
|
|
||||||
|
const APPLICATION_CID = Components.ID("fe74cf80-aa2d-11db-abbd-0800200c9a66");
|
||||||
|
const APPLICATION_CONTRACTID = "@mozilla.org/fuel/application;1";
|
||||||
|
|
||||||
//=================================================
|
//=================================================
|
||||||
// Singleton that holds services and utilities
|
// Singleton that holds services and utilities
|
||||||
var Utilities = {
|
var Utilities = {
|
||||||
@ -668,21 +671,22 @@ function Application() {
|
|||||||
// Application implementation
|
// Application implementation
|
||||||
Application.prototype = {
|
Application.prototype = {
|
||||||
// for nsIClassInfo + XPCOMUtils
|
// for nsIClassInfo + XPCOMUtils
|
||||||
classID: Components.ID("fe74cf80-aa2d-11db-abbd-0800200c9a66"),
|
classID: APPLICATION_CID,
|
||||||
|
|
||||||
// redefine the default factory for XPCOMUtils
|
// redefine the default factory for XPCOMUtils
|
||||||
_xpcom_factory: ApplicationFactory,
|
_xpcom_factory: ApplicationFactory,
|
||||||
|
|
||||||
// for nsISupports
|
// for nsISupports
|
||||||
QueryInterface : XPCOMUtils.generateQI([Ci.fuelIApplication, Ci.extIApplication,
|
QueryInterface : XPCOMUtils.generateQI([Ci.fuelIApplication, Ci.extIApplication,
|
||||||
Ci.nsIObserver, Ci.nsIClassInfo]),
|
Ci.nsIObserver]),
|
||||||
|
|
||||||
getInterfaces : function app_gi(aCount) {
|
// for nsIClassInfo
|
||||||
var interfaces = [Ci.fuelIApplication, Ci.extIApplication, Ci.nsIObserver,
|
classInfo: XPCOMUtils.generateCI({classID: APPLICATION_CID,
|
||||||
Ci.nsIClassInfo];
|
contractID: APPLICATION_CONTRACTID,
|
||||||
aCount.value = interfaces.length;
|
interfaces: [Ci.fuelIApplication,
|
||||||
return interfaces;
|
Ci.extIApplication,
|
||||||
},
|
Ci.nsIObserver],
|
||||||
|
flags: Ci.nsIClassInfo.SINGLETON}),
|
||||||
|
|
||||||
// for nsIObserver
|
// for nsIObserver
|
||||||
observe: function app_observe(aSubject, aTopic, aData) {
|
observe: function app_observe(aSubject, aTopic, aData) {
|
||||||
|
@ -40,8 +40,8 @@
|
|||||||
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||||
|
|
||||||
const EXSLT_REGEXP_CID = Components.ID("{18a03189-067b-4978-b4f1-bafe35292ed6}");
|
const EXSLT_REGEXP_CID = Components.ID("{18a03189-067b-4978-b4f1-bafe35292ed6}");
|
||||||
|
const EXSLT_REGEXP_CONTRACTID = "@mozilla.org/exslt/regexp;1";
|
||||||
|
|
||||||
const CATMAN_CONTRACTID = "@mozilla.org/categorymanager;1";
|
|
||||||
const NODESET_CONTRACTID = "@mozilla.org/transformiix-nodeset;1";
|
const NODESET_CONTRACTID = "@mozilla.org/transformiix-nodeset;1";
|
||||||
|
|
||||||
const Ci = Components.interfaces;
|
const Ci = Components.interfaces;
|
||||||
@ -55,32 +55,11 @@ var SingletonInstance = null;
|
|||||||
txEXSLTRegExFunctions.prototype = {
|
txEXSLTRegExFunctions.prototype = {
|
||||||
classID: EXSLT_REGEXP_CID,
|
classID: EXSLT_REGEXP_CID,
|
||||||
|
|
||||||
QueryInterface: function(iid) {
|
QueryInterface: XPCOMUtils.generateQI([Ci.txIEXSLTRegExFunctions]),
|
||||||
if (iid.equals(Ci.nsISupports) ||
|
|
||||||
iid.equals(Ci.nsIClassInfo) ||
|
|
||||||
iid.equals(Ci.txIEXSLTRegExFunctions))
|
|
||||||
return this;
|
|
||||||
|
|
||||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
|
||||||
},
|
|
||||||
|
|
||||||
// nsIClassInfo
|
|
||||||
getInterfaces: function(countRef) {
|
|
||||||
var interfaces = [
|
|
||||||
Ci.txIEXSLTRegExFunctions
|
|
||||||
];
|
|
||||||
countRef.value = interfaces.length;
|
|
||||||
|
|
||||||
return interfaces;
|
|
||||||
},
|
|
||||||
|
|
||||||
getHelperForLanguage: function(language) {
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
|
|
||||||
implementationLanguage: Ci.nsIProgrammingLanguage.JAVASCRIPT,
|
|
||||||
flags: 0,
|
|
||||||
|
|
||||||
|
classInfo: XPCOMUtils.generateCI({classID: EXSLT_REGEXP_CID,
|
||||||
|
contractID: EXSLT_REGEXP_CONTRACTID,
|
||||||
|
interfaces: [Ci.txIEXSLTRegExFunctions]}),
|
||||||
|
|
||||||
// txIEXSLTRegExFunctions
|
// txIEXSLTRegExFunctions
|
||||||
match: function(context, str, regex, flags) {
|
match: function(context, str, regex, flags) {
|
||||||
|
@ -68,21 +68,12 @@ function GeoPositionCoordsObject(latitude, longitude, altitude, accuracy, altitu
|
|||||||
|
|
||||||
GeoPositionCoordsObject.prototype = {
|
GeoPositionCoordsObject.prototype = {
|
||||||
|
|
||||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMGeoPositionCoords, Ci.nsIClassInfo]),
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMGeoPositionCoords]),
|
||||||
|
|
||||||
// Class Info is required to be able to pass objects back into the DOM.
|
// Class Info is required to be able to pass objects back into the DOM.
|
||||||
getInterfaces: function(countRef) {
|
classInfo: XPCOMUtils.generateCI({interfaces: [Ci.nsIDOMGeoPositionCoords],
|
||||||
var interfaces = [Ci.nsIDOMGeoPositionCoords, Ci.nsIClassInfo, Ci.nsISupports];
|
flags: Ci.nsIClassInfo.DOM_OBJECT,
|
||||||
countRef.value = interfaces.length;
|
classDescription: "Geoposition Coordinate Object"}),
|
||||||
return interfaces;
|
|
||||||
},
|
|
||||||
|
|
||||||
getHelperForLanguage: function(language) null,
|
|
||||||
contractID: null,
|
|
||||||
classDescription: "Geoposition Coordinate Object",
|
|
||||||
classID: null,
|
|
||||||
implementationLanguage: Ci.nsIProgrammingLanguage.JAVASCRIPT,
|
|
||||||
flags: Ci.nsIClassInfo.DOM_OBJECT,
|
|
||||||
|
|
||||||
latitude: null,
|
latitude: null,
|
||||||
longitude: null,
|
longitude: null,
|
||||||
@ -101,21 +92,12 @@ function GeoPositionObject(latitude, longitude, altitude, accuracy, altitudeAccu
|
|||||||
|
|
||||||
GeoPositionObject.prototype = {
|
GeoPositionObject.prototype = {
|
||||||
|
|
||||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMGeoPosition, Ci.nsIClassInfo]),
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMGeoPosition]),
|
||||||
|
|
||||||
// Class Info is required to be able to pass objects back into the DOM.
|
// Class Info is required to be able to pass objects back into the DOM.
|
||||||
getInterfaces: function(countRef) {
|
classInfo: XPCOMUtils.generateCI({interfaces: [Ci.nsIDOMGeoPosition],
|
||||||
var interfaces = [Ci.nsIDOMGeoPosition, Ci.nsIClassInfo, Ci.nsISupports];
|
flags: Ci.nsIClassInfo.DOM_OBJECT,
|
||||||
countRef.value = interfaces.length;
|
classDescription: "Geoposition Object"}),
|
||||||
return interfaces;
|
|
||||||
},
|
|
||||||
|
|
||||||
getHelperForLanguage: function(language) null,
|
|
||||||
contractID: null,
|
|
||||||
classDescription: "Geoposition Object",
|
|
||||||
classID: null,
|
|
||||||
implementationLanguage: Ci.nsIProgrammingLanguage.JAVASCRIPT,
|
|
||||||
flags: Ci.nsIClassInfo.DOM_OBJECT,
|
|
||||||
|
|
||||||
coords: null,
|
coords: null,
|
||||||
timestamp: null,
|
timestamp: null,
|
||||||
|
@ -35,17 +35,10 @@ function WifiGeoAddressObject(streetNumber, street, premises, city, county, regi
|
|||||||
|
|
||||||
WifiGeoAddressObject.prototype = {
|
WifiGeoAddressObject.prototype = {
|
||||||
|
|
||||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMGeoPositionAddress, Ci.nsIClassInfo]),
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMGeoPositionAddress]),
|
||||||
|
|
||||||
getInterfaces: function(countRef) {
|
classInfo: XPCOMUtils.generateCI({interfaces: [Ci.nsIDOMGeoPositionAddress],
|
||||||
var interfaces = [Ci.nsIDOMGeoPositionAddress, Ci.nsIClassInfo, Ci.nsISupports];
|
flags: Ci.nsIClassInfo.DOM_OBJECT})
|
||||||
countRef.value = interfaces.length;
|
|
||||||
return interfaces;
|
|
||||||
},
|
|
||||||
|
|
||||||
getHelperForLanguage: function(language) null,
|
|
||||||
implementationLanguage: Ci.nsIProgrammingLanguage.JAVASCRIPT,
|
|
||||||
flags: Ci.nsIClassInfo.DOM_OBJECT,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function WifiGeoCoordsObject(lat, lon, acc, alt, altacc) {
|
function WifiGeoCoordsObject(lat, lon, acc, alt, altacc) {
|
||||||
@ -58,18 +51,11 @@ function WifiGeoCoordsObject(lat, lon, acc, alt, altacc) {
|
|||||||
|
|
||||||
WifiGeoCoordsObject.prototype = {
|
WifiGeoCoordsObject.prototype = {
|
||||||
|
|
||||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMGeoPositionCoords, Ci.nsIClassInfo]),
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMGeoPositionCoords]),
|
||||||
|
|
||||||
getInterfaces: function(countRef) {
|
classInfo: XPCOMUtils.generateCI({interfaces: [Ci.nsIDOMGeoPositionCoords],
|
||||||
var interfaces = [Ci.nsIDOMGeoPositionCoords, Ci.nsIClassInfo, Ci.nsISupports];
|
flags: Ci.nsIClassInfo.DOM_OBJECT,
|
||||||
countRef.value = interfaces.length;
|
classDescription: "wifi geo position coords object"}),
|
||||||
return interfaces;
|
|
||||||
},
|
|
||||||
|
|
||||||
getHelperForLanguage: function(language) null,
|
|
||||||
classDescription: "wifi geo position coords object",
|
|
||||||
implementationLanguage: Ci.nsIProgrammingLanguage.JAVASCRIPT,
|
|
||||||
flags: Ci.nsIClassInfo.DOM_OBJECT,
|
|
||||||
|
|
||||||
latitude: 0,
|
latitude: 0,
|
||||||
longitude: 0,
|
longitude: 0,
|
||||||
@ -107,19 +93,12 @@ function WifiGeoPositionObject(location) {
|
|||||||
|
|
||||||
WifiGeoPositionObject.prototype = {
|
WifiGeoPositionObject.prototype = {
|
||||||
|
|
||||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMGeoPosition, Ci.nsIClassInfo]),
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMGeoPosition]),
|
||||||
|
|
||||||
// Class Info is required to be able to pass objects back into the DOM.
|
// Class Info is required to be able to pass objects back into the DOM.
|
||||||
getInterfaces: function(countRef) {
|
classInfo: XPCOMUtils.generateCI({interfaces: [Ci.nsIDOMGeoPosition],
|
||||||
var interfaces = [Ci.nsIDOMGeoPosition, Ci.nsIClassInfo, Ci.nsISupports];
|
flags: Ci.nsIClassInfo.DOM_OBJECT,
|
||||||
countRef.value = interfaces.length;
|
classDescription: "wifi geo location position object"}),
|
||||||
return interfaces;
|
|
||||||
},
|
|
||||||
|
|
||||||
getHelperForLanguage: function(language) null,
|
|
||||||
classDescription: "wifi geo location position object",
|
|
||||||
implementationLanguage: Ci.nsIProgrammingLanguage.JAVASCRIPT,
|
|
||||||
flags: Ci.nsIClassInfo.DOM_OBJECT,
|
|
||||||
|
|
||||||
coords: null,
|
coords: null,
|
||||||
timestamp: 0,
|
timestamp: 0,
|
||||||
|
@ -68,6 +68,19 @@
|
|||||||
* "nsIFoo",
|
* "nsIFoo",
|
||||||
* "nsIBar" ]),
|
* "nsIBar" ]),
|
||||||
*
|
*
|
||||||
|
* // [optional] classInfo implementation, e.g. using the generateCI helper.
|
||||||
|
* // Will be automatically returned from QueryInterface if that was
|
||||||
|
* // generated with the generateQI helper.
|
||||||
|
* classInfo: XPCOMUtils.generateCI(
|
||||||
|
* {classID: Components.ID("{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}"),
|
||||||
|
* contractID: "@example.com/xxx;1",
|
||||||
|
* classDescription: "unique text description",
|
||||||
|
* interfaces: [Components.interfaces.nsIObserver,
|
||||||
|
* Components.interfaces.nsIMyInterface,
|
||||||
|
* "nsIFoo",
|
||||||
|
* "nsIBar"],
|
||||||
|
* flags: Ci.nsIClassInfo.SINGLETON}),
|
||||||
|
*
|
||||||
* // The following properties were used prior to Mozilla 2, but are no
|
* // The following properties were used prior to Mozilla 2, but are no
|
||||||
* // longer supported. They may still be included for compatibility with
|
* // longer supported. They may still be included for compatibility with
|
||||||
* // prior versions of XPCOMUtils. In Mozilla 2, this information is
|
* // prior versions of XPCOMUtils. In Mozilla 2, this information is
|
||||||
@ -122,12 +135,44 @@ var XPCOMUtils = {
|
|||||||
* assigned to the 'QueryInterface' property of a JS object. When invoked on
|
* assigned to the 'QueryInterface' property of a JS object. When invoked on
|
||||||
* that object, it checks if the given iid is listed in the |interfaces|
|
* that object, it checks if the given iid is listed in the |interfaces|
|
||||||
* param, and if it is, returns |this| (the object it was called on).
|
* param, and if it is, returns |this| (the object it was called on).
|
||||||
|
* If the JS object has a classInfo property it'll be returned for the
|
||||||
|
* nsIClassInfo IID, generateCI can be used to generate the classInfo
|
||||||
|
* property.
|
||||||
*/
|
*/
|
||||||
generateQI: function XPCU_generateQI(interfaces) {
|
generateQI: function XPCU_generateQI(interfaces) {
|
||||||
/* Note that Ci[Ci.x] == Ci.x for all x */
|
/* Note that Ci[Ci.x] == Ci.x for all x */
|
||||||
return makeQI([Ci[i].name for each (i in interfaces) if (Ci[i])]);
|
return makeQI([Ci[i].name for each (i in interfaces) if (Ci[i])]);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate a ClassInfo implementation for a component. The returned object
|
||||||
|
* must be assigned to the 'classInfo' property of a JS object. The first and
|
||||||
|
* only argument should be an object that contains a number of optional
|
||||||
|
* properties: "interfaces", "contractID", "classDescription", "classID" and
|
||||||
|
* "flags". The values of the properties will be returned as the values of the
|
||||||
|
* various properties of the nsIClassInfo implementation.
|
||||||
|
*/
|
||||||
|
generateCI: function XPCU_generateCI(classInfo)
|
||||||
|
{
|
||||||
|
if (QueryInterface in classInfo)
|
||||||
|
throw Error("In generateCI, don't use a component for generating classInfo");
|
||||||
|
/* Note that Ci[Ci.x] == Ci.x for all x */
|
||||||
|
var _interfaces = [Ci[i] for each (i in classInfo.interfaces) if (Ci[i])];
|
||||||
|
return {
|
||||||
|
getInterfaces: function XPCU_getInterfaces(countRef) {
|
||||||
|
countRef.value = _interfaces.length;
|
||||||
|
return _interfaces;
|
||||||
|
},
|
||||||
|
getHelperForLanguage: function XPCU_getHelperForLanguage(language) null,
|
||||||
|
contractID: classInfo.contractID,
|
||||||
|
classDescription: classInfo.classDescription,
|
||||||
|
classID: classInfo.classID,
|
||||||
|
implementationLanguage: Ci.nsIProgrammingLanguage.JAVASCRIPT,
|
||||||
|
flags: classInfo.flags,
|
||||||
|
QueryInterface: this.generateQI([Ci.nsIClassInfo])
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate a NSGetFactory function given an array of components.
|
* Generate a NSGetFactory function given an array of components.
|
||||||
*/
|
*/
|
||||||
@ -281,6 +326,8 @@ function makeQI(interfaceNames) {
|
|||||||
return function XPCOMUtils_QueryInterface(iid) {
|
return function XPCOMUtils_QueryInterface(iid) {
|
||||||
if (iid.equals(Ci.nsISupports))
|
if (iid.equals(Ci.nsISupports))
|
||||||
return this;
|
return this;
|
||||||
|
if (iid.equals(Ci.nsIClassInfo) && "classInfo" in this)
|
||||||
|
return this.classInfo;
|
||||||
for each(let interfaceName in interfaceNames) {
|
for each(let interfaceName in interfaceNames) {
|
||||||
if (Ci[interfaceName].equals(iid))
|
if (Ci[interfaceName].equals(iid))
|
||||||
return this;
|
return this;
|
||||||
|
@ -76,6 +76,31 @@ function test_generateQI_string_names()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function test_generateCI()
|
||||||
|
{
|
||||||
|
const classID = Components.ID("562dae2e-7cff-432b-995b-3d4c03fa2b89");
|
||||||
|
const classDescription = "generateCI test component";
|
||||||
|
const flags = Components.interfaces.nsIClassInfo.DOM_OBJECT;
|
||||||
|
var x = {
|
||||||
|
QueryInterface: XPCOMUtils.generateQI([]),
|
||||||
|
classInfo: XPCOMUtils.generateCI({classID: classID,
|
||||||
|
interfaces: [],
|
||||||
|
flags: flags,
|
||||||
|
classDescription: classDescription})
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
var ci = x.QueryInterface(Components.interfaces.nsIClassInfo);
|
||||||
|
ci = ci.QueryInterface(Components.interfaces.nsISupports);
|
||||||
|
ci = ci.QueryInterface(Components.interfaces.nsIClassInfo);
|
||||||
|
do_check_eq(ci.classID, classID);
|
||||||
|
do_check_eq(ci.flags, flags);
|
||||||
|
do_check_eq(ci.classDescription, classDescription);
|
||||||
|
} catch(e) {
|
||||||
|
do_throw("Classinfo for x should not be missing or broken");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function test_defineLazyGetter()
|
function test_defineLazyGetter()
|
||||||
{
|
{
|
||||||
let accessCount = 0;
|
let accessCount = 0;
|
||||||
@ -186,6 +211,7 @@ function test_categoryRegistration()
|
|||||||
|
|
||||||
let tests = [
|
let tests = [
|
||||||
test_generateQI_string_names,
|
test_generateQI_string_names,
|
||||||
|
test_generateCI,
|
||||||
test_defineLazyGetter,
|
test_defineLazyGetter,
|
||||||
test_defineLazyServiceGetter,
|
test_defineLazyServiceGetter,
|
||||||
test_categoryRegistration,
|
test_categoryRegistration,
|
||||||
|
@ -48,6 +48,9 @@ const Cu = Components.utils;
|
|||||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||||
Cu.import("resource://gre/modules/Services.jsm");
|
Cu.import("resource://gre/modules/Services.jsm");
|
||||||
|
|
||||||
|
const SIDEBAR_CID = Components.ID("{22117140-9c6e-11d3-aaf1-00805f8a4905}");
|
||||||
|
const SIDEBAR_CONTRACTID = "@mozilla.org/sidebar;1";
|
||||||
|
|
||||||
function Sidebar() {
|
function Sidebar() {
|
||||||
// Depending on if we are in the parent or child, prepare to remote
|
// Depending on if we are in the parent or child, prepare to remote
|
||||||
// certain calls
|
// certain calls
|
||||||
@ -167,24 +170,19 @@ Sidebar.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
// =========================== nsIClassInfo ===========================
|
// =========================== nsIClassInfo ===========================
|
||||||
flags: Ci.nsIClassInfo.DOM_OBJECT,
|
classInfo: XPCOMUtils.generateCI({classID: SIDEBAR_CID,
|
||||||
classDescription: "Sidebar",
|
contractID: SIDEBAR_CONTRACTID,
|
||||||
getInterfaces: function getInterfaces(count) {
|
interfaces: [Ci.nsISidebar,
|
||||||
var interfaceList = [Ci.nsISidebar, Ci.nsISidebarExternal, Ci.nsIClassInfo];
|
Ci.nsISidebarExternal],
|
||||||
count.value = interfaceList.length;
|
flags: Ci.nsIClassInfo.DOM_OBJECT,
|
||||||
return interfaceList;
|
classDescription: "Sidebar"}),
|
||||||
},
|
|
||||||
getHelperForLanguage: function getHelperForLanguage(count) {
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
|
|
||||||
// =========================== nsISupports ===========================
|
// =========================== nsISupports ===========================
|
||||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsISidebar,
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsISidebar,
|
||||||
Ci.nsISidebarExternal,
|
Ci.nsISidebarExternal]),
|
||||||
Ci.nsIClassInfo]),
|
|
||||||
|
|
||||||
// XPCOMUtils stuff
|
// XPCOMUtils stuff
|
||||||
classID: Components.ID("{22117140-9c6e-11d3-aaf1-00805f8a4905}"),
|
classID: SIDEBAR_CID,
|
||||||
};
|
};
|
||||||
|
|
||||||
const NSGetFactory = XPCOMUtils.generateNSGetFactory([Sidebar]);
|
const NSGetFactory = XPCOMUtils.generateNSGetFactory([Sidebar]);
|
||||||
|
@ -556,19 +556,9 @@ extApplication.prototype = {
|
|||||||
this._registered = {"unload": true};
|
this._registered = {"unload": true};
|
||||||
},
|
},
|
||||||
|
|
||||||
// for nsIClassInfo
|
classInfo: XPCOMUtils.generateCI({interfaces: [Ci.extIApplication,
|
||||||
flags : Ci.nsIClassInfo.SINGLETON,
|
Ci.nsIObserver],
|
||||||
implementationLanguage : Ci.nsIProgrammingLanguage.JAVASCRIPT,
|
flags: Ci.nsIClassInfo.SINGLETON}),
|
||||||
|
|
||||||
getInterfaces : function app_gi(aCount) {
|
|
||||||
var interfaces = [Ci.extIApplication, Ci.nsIObserver, Ci.nsIClassInfo];
|
|
||||||
aCount.value = interfaces.length;
|
|
||||||
return interfaces;
|
|
||||||
},
|
|
||||||
|
|
||||||
getHelperForLanguage : function app_ghfl(aCount) {
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
|
|
||||||
// extIApplication
|
// extIApplication
|
||||||
get id() {
|
get id() {
|
||||||
|
@ -51,6 +51,9 @@ const Cc = Components.classes;
|
|||||||
const Ci = Components.interfaces;
|
const Ci = Components.interfaces;
|
||||||
const Cr = Components.results;
|
const Cr = Components.results;
|
||||||
|
|
||||||
|
const UPDATESERVICE_CID = Components.ID("{B3C290A6-3943-4B89-8BBE-C01EB7B3B311}");
|
||||||
|
const UPDATESERVICE_CONTRACTID = "@mozilla.org/updates/update-service;1";
|
||||||
|
|
||||||
const PREF_APP_UPDATE_ALTWINDOWTYPE = "app.update.altwindowtype";
|
const PREF_APP_UPDATE_ALTWINDOWTYPE = "app.update.altwindowtype";
|
||||||
const PREF_APP_UPDATE_AUTO = "app.update.auto";
|
const PREF_APP_UPDATE_AUTO = "app.update.auto";
|
||||||
const PREF_APP_UPDATE_BACKGROUND_INTERVAL = "app.update.download.backgroundInterval";
|
const PREF_APP_UPDATE_BACKGROUND_INTERVAL = "app.update.download.backgroundInterval";
|
||||||
@ -1778,19 +1781,14 @@ UpdateService.prototype = {
|
|||||||
return this._downloader && this._downloader.isBusy;
|
return this._downloader && this._downloader.isBusy;
|
||||||
},
|
},
|
||||||
|
|
||||||
// nsIClassInfo
|
classID: UPDATESERVICE_CID,
|
||||||
flags: Ci.nsIClassInfo.SINGLETON,
|
classInfo: XPCOMUtils.generateCI({classID: UPDATESERVICE_CID,
|
||||||
implementationLanguage: Ci.nsIProgrammingLanguage.JAVASCRIPT,
|
contractID: UPDATESERVICE_CONTRACTID,
|
||||||
getHelperForLanguage: function(language) null,
|
interfaces: [Ci.nsIApplicationUpdateService,
|
||||||
getInterfaces: function AUS_getInterfaces(count) {
|
Ci.nsITimerCallback,
|
||||||
var interfaces = [Ci.nsIApplicationUpdateService,
|
Ci.nsIObserver],
|
||||||
Ci.nsITimerCallback,
|
flags: Ci.nsIClassInfo.SINGLETON}),
|
||||||
Ci.nsIObserver];
|
|
||||||
count.value = interfaces.length;
|
|
||||||
return interfaces;
|
|
||||||
},
|
|
||||||
|
|
||||||
classID: Components.ID("{B3C290A6-3943-4B89-8BBE-C01EB7B3B311}"),
|
|
||||||
_xpcom_factory: UpdateServiceFactory,
|
_xpcom_factory: UpdateServiceFactory,
|
||||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIApplicationUpdateService,
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIApplicationUpdateService,
|
||||||
Ci.nsIAddonUpdateCheckListener,
|
Ci.nsIAddonUpdateCheckListener,
|
||||||
|
Loading…
Reference in New Issue
Block a user