nsIComponentManager 编辑
xpcom/components/nsIComponentManager.idl
Scriptable This interface provides methods to access factory objects and instantiate instances of classes. 66 Introduced Gecko 0.7 Inherits from: nsISupports
Last changed in Gecko 8.0 (Firefox 8.0 / Thunderbird 8.0 / SeaMonkey 2.5)Method overview
void addBootstrappedManifestLocation(in |
void createInstance(in nsCIDRef aClass, in nsISupports aDelegate, in nsIIDRef aIID, [iid_is(aIID),retval] out nsQIResult result); |
void createInstanceByContractID(in string aContractID, in nsISupports aDelegate, in nsIIDRef aIID, [iid_is(aIID),retval] out nsQIResult result); |
void getClassObject(in nsCIDRef aClass, in nsIIDRef aIID, [iid_is(aIID),retval] out nsQIResult result); |
void getClassObjectByContractID(in string aContractID, in nsIIDRef aIID, [iid_is(aIID),retval] out nsQIResult result); |
void removeBootstrappedManifestLocation(in |
Methods
addBootstrappedManifestLocation()
Loads a "bootstrapped" chrome.manifest
file from the specified directory or XPI file. A "bootstrapped" chrome manifest supports some of the instructions allowed in a regular chrome manifest, see the Chrome Registration documentation for details.
This method was introduced in Gecko 8 to let bootstrapped add-ons provide content at chrome://
URIs. Until Gecko 10 you had to call this method manually from within the add-on's startup()
method (with a matching removeBootstrappedManifestLocation()
call in the add-on's shutdown()
method).
If you're targeting Gecko 10 or higher there should be no need to call this method, since the bootstrapped add-on's chrome.manifest is loaded automatically now.
void addBootstrappedManifestLocation( in interface nsILocalFile aLocation );
Parameters
aLocation
- The directory or XPI from which to load the
chrome.manifest
.
createInstance()
Creates an instance of the class specified by ClassID. Unlike getService, this returns a new instance each time it is called. (See also nsIFactory.createInstance.)
void createInstance( in nsCIDRef aClass, in nsISupports aDelegate, in nsIIDRef aIID, [iid_is(aIID),retval] out nsQIResult result );
Parameters
aClass
- The ClassID of the object instance that is being requested.
aDelegate
- The outer object used for aggregation.
aIID
- The interface type to be returned.
result
- The resulting interface pointer.
Exceptions thrown
NS_ERROR_FACTORY_NOT_REGISTERED
- Indicates that the specified class is not registered.
createInstanceByContractID()
Creates an instance of the class specified by ContractID.
void createInstanceByContractID( in string aContractID, in nsISupports aDelegate, in nsIIDRef aIID, [iid_is(aIID),retval] out nsQIResult result );
Parameters
aContractID
- The ContractID of the object instance that is being requested.
aDelegate
- The outer object used for aggregation.
aIID
- The interface type to be returned.
result
- The resulting interface pointer.
Exceptions thrown
NS_ERROR_FACTORY_NOT_REGISTERED
- Indicates that the specified class is not registered.
getClassObject()
Returns the factory object for the class specified by ClassID.
void getClassObject( in nsCIDRef aClass, in nsIIDRef aIID, [iid_is(aIID),retval] out nsQIResult result );
Parameters
aClass
- The ClassID of the factory that is being requested.
aIID
- The interface type to be returned.
result
- The resulting interface pointer.
Exceptions thrown
NS_ERROR_FACTORY_NOT_REGISTERED
- Indicates that the specified class is not registered.
getClassObjectByContractID()
Returns the factory object for the class specified by ContractID.
void getClassObjectByContractID( in string aContractID, in nsIIDRef aIID, [iid_is(aIID),retval] out nsQIResult result );
Parameters
aContractID
- The ContractID of the factory that is being requested.
aIID
- The interface type to be returned.
result
- The resulting interface pointer.
Exceptions thrown
NS_ERROR_FACTORY_NOT_REGISTERED
- Indicates that the specified class is not registered.
removeBootstrappedManifestLocation()
Unregisters the chrome.manifest
file previously registered with the addBootstrappedManifestLocation()
method.
See addBootstrappedManifestLocation()
for details.
void removeBootstrappedManifestLocation( in interface nsILocalFile aLocation );
Parameters
Examples
Using addBootstrappedManifestLocation in a bootstrapped extension for Firefox 8 and 9:
aLocation
- The directory or XPI to stop reading the
chrome.manifest
from.
function startup(params, aReason) { if (Services.vc.compare(Services.appinfo.platformVersion, "10.0") < 0) Components.manager.addBootstrappedManifestLocation(params.installPath); } function shutdown(params, aReason) { if (Services.vc.compare(Services.appinfo.platformVersion, "10.0") < 0) Components.manager.removeBootstrappedManifestLocation(params.installPath); }
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论