michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsISupports.idl" michael@0: michael@0: interface nsIVariant; michael@0: interface nsIPropertyBag2; michael@0: interface nsIContentURIGrouper; michael@0: interface nsILoadContext; michael@0: interface mozIStorageConnection; michael@0: michael@0: [scriptable, uuid(746c7a02-f6c1-4869-b434-7c8b86e60e61)] michael@0: interface nsIContentPrefObserver : nsISupports michael@0: { michael@0: /** michael@0: * Called when a content pref is set to a different value. michael@0: * michael@0: * @param aGroup the group to which the pref belongs, or null michael@0: * if it's a global pref (applies to all sites) michael@0: * @param aName the name of the pref that was set michael@0: * @param aValue the new value of the pref michael@0: */ michael@0: void onContentPrefSet(in AString aGroup, in AString aName, in nsIVariant aValue); michael@0: michael@0: /** michael@0: * Called when a content pref is removed. michael@0: * michael@0: * @param aGroup the group to which the pref belongs, or null michael@0: * if it's a global pref (applies to all sites) michael@0: * @param aName the name of the pref that was removed michael@0: */ michael@0: void onContentPrefRemoved(in AString aGroup, in AString aName); michael@0: }; michael@0: michael@0: [scriptable, function, uuid(c1b3d6df-5373-4606-8494-8bcf14a7fc62)] michael@0: interface nsIContentPrefCallback : nsISupports michael@0: { michael@0: void onResult(in nsIVariant aResult); michael@0: }; michael@0: michael@0: /** michael@0: * @deprecated Please use nsIContentPrefService2 instead. michael@0: */ michael@0: [scriptable, uuid(e3f772f3-023f-4b32-b074-36cf0fd5d414)] michael@0: interface nsIContentPrefService : nsISupports michael@0: { michael@0: /** michael@0: * Get a pref. michael@0: * michael@0: * Besides the regular string, integer, boolean, etc. values, this method michael@0: * may return null (nsIDataType::VTYPE_EMPTY), which means the pref is set michael@0: * to NULL in the database, as well as undefined (nsIDataType::VTYPE_VOID), michael@0: * which means there is no record for this pref in the database. michael@0: * michael@0: * This method can be called from content processes in electrolysis builds. michael@0: * We have a whitelist of values that can be read in such a way. michael@0: * michael@0: * @param aGroup the group for which to get the pref, as an nsIURI michael@0: * from which the hostname will be used, a string michael@0: * (typically in the format of a hostname), or null michael@0: * to get the global pref (applies to all sites) michael@0: * @param aName the name of the pref to get michael@0: * @param aPrivacyContext michael@0: * a context from which to determine the privacy status michael@0: * of the pref (ie. whether to search in memory or in michael@0: * permanent storage for it), obtained from a relevant michael@0: * window or channel. michael@0: * @param aCallback an optional nsIContentPrefCallback to receive the michael@0: * result. If desired, JavaScript callers can instead michael@0: * provide a function to call upon completion michael@0: * michael@0: * @returns the value of the pref michael@0: * @throws NS_ERROR_ILLEGAL_VALUE if aGroup is not a string, nsIURI, or null michael@0: * @throws NS_ERROR_ILLEGAL_VALUE if aName is null or an empty string michael@0: */ michael@0: nsIVariant getPref(in nsIVariant aGroup, in AString aName, michael@0: in nsILoadContext aPrivacyContext, michael@0: [optional] in nsIContentPrefCallback aCallback); michael@0: michael@0: /** michael@0: * Set a pref. michael@0: * michael@0: * This method can be called from content processes in electrolysis builds. michael@0: * We have a whitelist of values that can be set in such a way. michael@0: * michael@0: * @param aGroup the group for which to set the pref, as an nsIURI michael@0: * from which the hostname will be used, a string michael@0: * (typically in the format of a hostname), or null michael@0: * to set the global pref (applies to all sites) michael@0: * @param aName the name of the pref to set michael@0: * @param aValue the new value of the pref michael@0: * @param aPrivacyContext michael@0: * a context from which to determine the privacy status michael@0: * of the pref (ie. whether to store it in memory or in michael@0: * permanent storage), obtained from a relevant michael@0: * window or channel. michael@0: * @throws NS_ERROR_ILLEGAL_VALUE if aGroup is not a string, nsIURI, or null michael@0: * @throws NS_ERROR_ILLEGAL_VALUE if aName is null or an empty string michael@0: */ michael@0: void setPref(in nsIVariant aGroup, in AString aName, in nsIVariant aValue, in nsILoadContext aPrivacyContext); michael@0: michael@0: /** michael@0: * Check whether or not a pref exists. michael@0: * michael@0: * @param aGroup the group for which to check for the pref, as an nsIURI michael@0: * from which the hostname will be used, a string michael@0: * (typically in the format of a hostname), or null michael@0: * to check for the global pref (applies to all sites) michael@0: * @param aName the name of the pref to check for michael@0: * @param aPrivacyContext michael@0: * a context from which to determine the privacy status michael@0: * of the pref (ie. whether to search in memory or in michael@0: * permanent storage for it), obtained from a relevant michael@0: * window or channel. michael@0: * @throws NS_ERROR_ILLEGAL_VALUE if aGroup is not a string, nsIURI, or null michael@0: * @throws NS_ERROR_ILLEGAL_VALUE if aName is null or an empty string michael@0: */ michael@0: boolean hasPref(in nsIVariant aGroup, in AString aName, in nsILoadContext aContext); michael@0: michael@0: /** michael@0: * Check whether or not the value of a pref (or its non-existance) is cached. michael@0: * michael@0: * @param aGroup the group for which to check for the pref, as an nsIURI michael@0: * from which the hostname will be used, a string michael@0: * (typically in the format of a hostname), or null michael@0: * to check for the global pref (applies to all sites) michael@0: * @param aName the name of the pref to check for michael@0: * @param aPrivacyContext michael@0: * a context from which to determine the privacy status michael@0: * of the pref (ie. whether to search in memory or in michael@0: * permanent storage for it), obtained from a relevant michael@0: * window or channel. michael@0: * @throws NS_ERROR_ILLEGAL_VALUE if aGroup is not a string, nsIURI, or null michael@0: * @throws NS_ERROR_ILLEGAL_VALUE if aName is null or an empty string michael@0: */ michael@0: boolean hasCachedPref(in nsIVariant aGroup, in AString aName, in nsILoadContext aContext); michael@0: michael@0: /** michael@0: * Remove a pref. michael@0: * michael@0: * @param aGroup the group for which to remove the pref, as an nsIURI michael@0: * from which the hostname will be used, a string michael@0: * (typically in the format of a hostname), or null michael@0: * to remove the global pref (applies to all sites) michael@0: * @param aName the name of the pref to remove michael@0: * @param aPrivacyContext michael@0: * a context from which to determine the privacy status michael@0: * of the pref (ie. whether to search in memory or in michael@0: * permanent storage for it), obtained from a relevant michael@0: * window or channel. michael@0: * @throws NS_ERROR_ILLEGAL_VALUE if aGroup is not a string, nsIURI, or null michael@0: * @throws NS_ERROR_ILLEGAL_VALUE if aName is null or an empty string michael@0: */ michael@0: void removePref(in nsIVariant aGroup, in AString aName, in nsILoadContext aContext); michael@0: michael@0: /** michael@0: * Remove all grouped prefs. Useful for removing references to the sites michael@0: * the user has visited when the user clears their private data. michael@0: * michael@0: * @param aPrivacyContext michael@0: * a context from which to determine the privacy status michael@0: * of the pref (ie. whether to remove prefs in memory or michael@0: * in permanent storage), obtained from a relevant michael@0: * window or channel. michael@0: */ michael@0: void removeGroupedPrefs(in nsILoadContext aContext); michael@0: michael@0: /** michael@0: * Remove all prefs with the given name. michael@0: * michael@0: * @param aName the setting name for which to remove prefs michael@0: * @param aPrivacyContext michael@0: * a context from which to determine the privacy status michael@0: * of the prefs (ie. whether to remove prefs in memory or michael@0: * in permanent storage), obtained from a relevant michael@0: * window or channel. michael@0: * @throws NS_ERROR_ILLEGAL_VALUE if aName is null or an empty string michael@0: */ michael@0: void removePrefsByName(in AString aName, in nsILoadContext aContext); michael@0: michael@0: /** michael@0: * Get the prefs that apply to the given site. michael@0: * michael@0: * @param aGroup the group for which to retrieve prefs, as an nsIURI michael@0: * from which the hostname will be used, a string michael@0: * (typically in the format of a hostname), or null michael@0: * to get the global prefs (apply to all sites) michael@0: * @param aPrivacyContext michael@0: * a context from which to determine the privacy status michael@0: * of the pref (ie. whether to search for prefs in memory michael@0: * or in permanent storage), obtained from a relevant michael@0: * window or channel. michael@0: * michael@0: * @returns a property bag of prefs michael@0: * @throws NS_ERROR_ILLEGAL_VALUE if aGroup is not a string, nsIURI, or null michael@0: */ michael@0: nsIPropertyBag2 getPrefs(in nsIVariant aGroup, in nsILoadContext aContext); michael@0: michael@0: /** michael@0: * Get the prefs with the given name. michael@0: * michael@0: * @param aName the setting name for which to retrieve prefs michael@0: * @param aPrivacyContext michael@0: * a context from which to determine the privacy status michael@0: * of the pref (ie. whether to search for prefs in memory michael@0: * or in permanent storage), obtained from a relevant michael@0: * window or channel. michael@0: * michael@0: * @returns a property bag of prefs michael@0: * @throws NS_ERROR_ILLEGAL_VALUE if aName is null or an empty string michael@0: */ michael@0: nsIPropertyBag2 getPrefsByName(in AString aName, in nsILoadContext aContext); michael@0: michael@0: /** michael@0: * Add an observer. michael@0: * michael@0: * @param aName the setting to observe, or null to add michael@0: * a generic observer that observes all settings michael@0: * @param aObserver the observer to add michael@0: */ michael@0: void addObserver(in AString aName, in nsIContentPrefObserver aObserver); michael@0: michael@0: /** michael@0: * Remove an observer. michael@0: * michael@0: * @param aName the setting being observed, or null to remove michael@0: * a generic observer that observes all settings michael@0: * @param aObserver the observer to remove michael@0: */ michael@0: void removeObserver(in AString aName, in nsIContentPrefObserver aObserver); michael@0: michael@0: /** michael@0: * The component that the service uses to determine the groups to which michael@0: * URIs belong. By default this is the "hostname grouper", which groups michael@0: * URIs by full hostname (a.k.a. site). michael@0: */ michael@0: readonly attribute nsIContentURIGrouper grouper; michael@0: michael@0: /** michael@0: * The database connection to the content preferences database. michael@0: * Useful for accessing and manipulating preferences in ways that are caller- michael@0: * specific or for which there is not yet a generic method, although generic michael@0: * functionality useful to multiple callers should generally be added to this michael@0: * unfrozen interface. Also useful for testing the database creation michael@0: * and migration code. michael@0: */ michael@0: readonly attribute mozIStorageConnection DBConnection; michael@0: }; michael@0: michael@0: %{C++ michael@0: // The contractID for the generic implementation built in to xpcom. michael@0: #define NS_CONTENT_PREF_SERVICE_CONTRACTID "@mozilla.org/content-pref/service;1" michael@0: %}