nsIComponentManager 编辑

xpcom/components/nsIComponentManager.idlScriptable 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 nsILocalFile aLocation);
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 nsILocalFile aLocation);

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:112 次

字数:10025

最后编辑:6 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文