nsIPrefService 编辑

modules/libpref/public/nsIPrefService.idlScriptable This interface is the main entry point into the back end preferences management library. The preference service is directly responsible for the management of the preferences files and also facilitates access to the preference branch object which allows the direct manipulation of the preferences themselves. Inherits from: nsISupports Last changed in Gecko 1.7

Method overview

nsIPrefBranch getBranch(in string aPrefRoot);
nsIPrefBranch getDefaultBranch(in string aPrefRoot);
void readUserPrefs(in nsIFile aFile);
void resetPrefs();
void resetUserPrefs();
void savePrefFile(in nsIFile aFile);

Methods

getBranch()

Call to get a Preferences "Branch" which accesses user preference data. Using a Set method on this object will always create or set a user preference value. When using a Get method a user set value will be returned if one exists, otherwise a default value will be returned.

nsIPrefBranch getBranch(
  in string aPrefRoot
);
Parameters
aPrefRoot
The preference root tree on which to base this branch. For example, if the root browser.startup. is used, the branch will be able to easily access the preferences browser.startup.page, browser.startup.homepage, and browser.startup.homepage_override by simply requesting page, homepage, or homepage_override. nsnull or "" (empty string) may be used to access to the entire preference tree.
Return value

nsIPrefBranch - The object representing the requested branch.

getDefaultBranch()

Call to get a Preferences branch which accesses only the default preference data. Using a Set method on this object will always create or set a default preference value. When using a Get method a default value will always be returned.

Note: Few consumers will want to create default branch objects. Many of the branch methods do nothing on a default branch because the operations only make sense when applied to user set preferences.
nsIPrefBranch getDefaultBranch(
  in string aPrefRoot
);
Parameters
aPrefRoot
The preference root tree on which to base this branch. For example, if the root browser.startup. is used, the branch will be able to easily access the preferences browser.startup.page, browser.startup.homepage, and browser.startup.homepage_override by simply requesting page, homepage, or homepage_override. nsnull or "" (empty string) may be used to access to the entire preference tree.
Return value

nsIPrefBranch - The object representing the requested default branch.

readUserPrefs()

Called to read in the preferences specified in a user preference file.

Note: If nsnull is passed in for the aFile parameter the default preferences file(s) [prefs.js, user.js] will be read and processed.
void readUserPrefs(
  in nsIFile aFile
);
Parameters
aFile
The file to be read.

resetPrefs()

Called to completely flush and re-initialize the preferences system.

void resetPrefs();
Parameters

None.

resetUserPrefs()

Called to reset all preferences with user set values back to the application default values.

void resetUserPrefs();
Parameters

None.

savePrefFile()

Called to write current preferences state to a file.

Note: If nsnull is passed in for the aFile parameter the preference data is written out to the current preferences file (usually prefs.js.)
void savePrefFile(
  in nsIFile aFile
);
Parameters
aFile
The file to be written.

See also

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

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

发布评论

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

词条统计

浏览:49 次

字数:6694

最后编辑:7 年前

编辑次数:0 次

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