Interface nsIPrefServiceType

The nsIPrefService 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.

See

nsIPrefBranch

Hierarchy

Properties

dirty: boolean

The preference service is 'dirty' if there are changes to user preferences that have not been written to disk

Methods

  • Increases the reference count for this interface. The associated instance will not be deleted unless the reference count is returned to zero.

    Returns

    The resulting reference count.

    Returns number

  • Parameters

    • aIID: object
    • Optional aInstancePtr: object

    Returns any

  • A run time mechanism for interface discovery.

    Returns

    NS_OK if the interface is supported by the associated instance, NS_NOINTERFACE if it is not.

    aInstancePtr must not be null.

    Parameters

    • aIID: object

      [in] A requested interface IID

    • aInstancePtr: object

      [out] A pointer to an interface pointer to receive the result.

    Returns void

  • Decreases the reference count for this interface. Generally, if the reference count returns to zero, the associated instance is deleted.

    Returns

    The resulting reference count.

    Returns number

  • 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.

    Returns

    nsIPrefBranch The object representing the requested branch.

    See

    getDefaultBranch

    Parameters

    • aPrefRoot: string

      The preference "root" 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", or "browser.startup.homepage_override" by simply requesting "page", "homepage", or "homepage_override". nullptr or "" may be used to access to the entire preference "tree".

    Returns nsIPrefBranch

  • 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.

    Returns

    nsIPrefBranch The object representing the requested default branch.

    See

    getBranch

    Parameters

    • aPrefRoot: string

      The preference "root" 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", or "browser.startup.homepage_override" by simply requesting "page", "homepage", or "homepage_override". nullptr or "" may be used to access to the entire preference "tree".

    Returns nsIPrefBranch

  • Parse the given bytes, invoking callbacks on the given observer.

    This method does not modify any preferences.

    Parameters

    • bytes: invalid

      The data to parse. This data may be UTF-8 encoded, but is not required to be so: the prefs parser will determine the encoding automatically.

    • observer: nsIPrefObserver

      The observer to invoke callbacks on. Parsing errors will be reported via the onError callback.

    • pathLabel: string

      An optional string with which to label errors.

    Returns void

  • Read in the preferences specified in a default preference file. This method does not clear preferences that were already set, but it may overwrite existing preferences.

    Throws

    Error File failed to read or contained invalid data.

    Note

    This method is intended for internal unit testing only!

    Parameters

    • aFile: nsIFile

      The file to be read.

    Returns void

  • Usage statistics for performance tests. This function takes a function that is passed (preferenceName, accessCount) as arguments for every recorded preference. You can use this function to build e.g. a JS object holding that data.

    This is not implemented in non-debug builds and will throw an error.

    Parameters

    • callback: nsIPrefStatsCallback

    Returns void

  • Like readDefaultPrefsFromFile, but for a user prefs file.

    Parameters

    • aFile: nsIFile

    Returns void

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

    Throws

    Error The preference service failed to restart correctly.

    Returns void

  • Reset usage statistics for performance tests.

    This is not implemented in non-debug builds and will throw an error.

    Returns void

  • Called to write current preferences state to a file.

    Note

    If nullptr is passed in for the aFile parameter the preference data is written out to the current preferences file (usually prefs.js.)

    Throws

    Error File failed to write.

    See

    • readUserPrefsFromFile
    • nsIFile

    Parameters

    • aFile: nsIFile

      The file to be written.

    Returns void

Generated using TypeDoc