nsIToolkitProfileService 编辑

toolkit/profile/public/nsIToolkitProfileService.idlScriptable The Profile Service manages user profiles. Inherits from: nsISupports Last changed in Gecko 1.9.1 (Firefox 3.5 / Thunderbird 3.0 / SeaMonkey 2.0)

Note: Starting in Gecko 1.9.1, this service is implemented by @mozilla.org/toolkit/profile-service;1. To access the service, you can use the following code:

var toolkitProfileService = Components.classes["@mozilla.org/toolkit/profile-service;1"]
                            .createInstance(Components.interfaces.nsIToolkitProfileService);

Prior to Gecko 1.9.1 only the built-in profile manager was able to access the toolkit profile service. To access the built-in profile manager in versions of Firefox up to 4.0 and Thunderbird up to 3.3 you can launch with the -profilemanager command line flag. Future versions will require the separate Profile Manager application.

Warning: This service is synchronous so it is recommended that you use OS.File to find the profile directory via OS.Constants.Path.profileDir. OS.File is available from Gecko 18 (Firefox 18.0 / Thunderbird 18.0 / SeaMonkey 2.15).

 

 

Method overview

nsIToolkitProfile createProfile(in nsILocalFile aRootDir, in AUTF8String aName);
void flush();
nsIToolkitProfile getProfileByName(in AUTF8String aName);
nsIProfileLock lockProfilePath(in nsILocalFile aDirectory, in nsILocalFile aTempDirectory);

Attributes

AttributeTypeDescription
profileCountunsigned longThe number of user profiles currently in existence. This will always return 0, 1, or 2; if there are more than 2 profiles, 2 is always returned. Read only.
profilesnsISimpleEnumeratorAn enumerator providing access to the list of profiles; each profile is an nsIToolkitProfile object (though you must first call aProfile.QueryInterface(Components.interfaces.nsIToolkitProfile) to get access to its attributes and methods).
selectedProfilensIToolkitProfileThe profile that is marked as "Default=1" in the Profiles.ini file. (NOT the profile currently in use.) Not sure what happens if you change this setting but someone said: You can change profiles by setting this attribute's value. This may throw an NS_ERROR_FAILURE (0x80004005) when trying to get the current profile if it's unavailable or if permissions restrict access.
startOfflineboolean
startWithLastProfileboolean 

Methods

createProfile()

Creates a new profile.

The profile temporary directory will be chosen based on where the profile directory is located.

nsIToolkitProfile createProfile(
  in nsILocalFile aRootDir,
  in AUTF8String aName
);
Parameters
aRootDir
The profile directory. May be null, in which case a suitable default will be chosen based on the profile name.
aName
The name to give the new profile.
Return value

An nsIToolkitProfile object representing the newly-created profile.

Exceptions thrown
NS_ERROR_UNEXPECTED
An unexpected error condition occurred.
NS_ERROR_FILE_NOT_DIRECTORY
One of the specified directory files is not actually a directory.
NS_ERROR_OUT_OF_MEMORY
Unable to allocate the new profile object.

flush()

Flushes the profile list to disk.

The profile list file is constructed in memory, then written out as one large chunk, in order to reduce the risk of the profile list file being corrupted by disk errors.

void flush();
Parameters

None.

Exceptions thrown
NS_ERROR_OUT_OF_MEMORY
An error occurred trying to allocate the memory buffer used to construct the profile list.
NS_ERROR_UNEXPECTED
An error occurred writing the profile list file to disk.

getProfileByName()

Gets a profile, given the profile's name.

nsIToolkitProfile getProfileByName(
  in AUTF8String aName
);
Parameters
aName
The profile name to find.
Return value

An nsIToolkitProfile object describing the specified profile.

Exceptions thrown
NS_ERROR_FAILURE
No matching profile was found.

lockProfilePath()

Locks an arbitrary path as a profile. If the path does not exist, it is created and the defaults copied from the application directory.

nsIProfileLock lockProfilePath(
  in nsILocalFile aDirectory,
  in nsILocalFile aTempDirectory
);
Parameters
aDirectory
The directory to lock as a profile directory.
aTempDirectory
The directory to lock as a profile temporary directory.
Return value

An nsIProfileLock object representing the locked directory.

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

词条统计

浏览:96 次

字数:9020

最后编辑:7 年前

编辑次数:0 次

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