dom/interfaces/base/nsIContentPrefService.idl

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 #include "nsISupports.idl"
michael@0 6
michael@0 7 interface nsIVariant;
michael@0 8 interface nsIPropertyBag2;
michael@0 9 interface nsIContentURIGrouper;
michael@0 10 interface nsILoadContext;
michael@0 11 interface mozIStorageConnection;
michael@0 12
michael@0 13 [scriptable, uuid(746c7a02-f6c1-4869-b434-7c8b86e60e61)]
michael@0 14 interface nsIContentPrefObserver : nsISupports
michael@0 15 {
michael@0 16 /**
michael@0 17 * Called when a content pref is set to a different value.
michael@0 18 *
michael@0 19 * @param aGroup the group to which the pref belongs, or null
michael@0 20 * if it's a global pref (applies to all sites)
michael@0 21 * @param aName the name of the pref that was set
michael@0 22 * @param aValue the new value of the pref
michael@0 23 */
michael@0 24 void onContentPrefSet(in AString aGroup, in AString aName, in nsIVariant aValue);
michael@0 25
michael@0 26 /**
michael@0 27 * Called when a content pref is removed.
michael@0 28 *
michael@0 29 * @param aGroup the group to which the pref belongs, or null
michael@0 30 * if it's a global pref (applies to all sites)
michael@0 31 * @param aName the name of the pref that was removed
michael@0 32 */
michael@0 33 void onContentPrefRemoved(in AString aGroup, in AString aName);
michael@0 34 };
michael@0 35
michael@0 36 [scriptable, function, uuid(c1b3d6df-5373-4606-8494-8bcf14a7fc62)]
michael@0 37 interface nsIContentPrefCallback : nsISupports
michael@0 38 {
michael@0 39 void onResult(in nsIVariant aResult);
michael@0 40 };
michael@0 41
michael@0 42 /**
michael@0 43 * @deprecated Please use nsIContentPrefService2 instead.
michael@0 44 */
michael@0 45 [scriptable, uuid(e3f772f3-023f-4b32-b074-36cf0fd5d414)]
michael@0 46 interface nsIContentPrefService : nsISupports
michael@0 47 {
michael@0 48 /**
michael@0 49 * Get a pref.
michael@0 50 *
michael@0 51 * Besides the regular string, integer, boolean, etc. values, this method
michael@0 52 * may return null (nsIDataType::VTYPE_EMPTY), which means the pref is set
michael@0 53 * to NULL in the database, as well as undefined (nsIDataType::VTYPE_VOID),
michael@0 54 * which means there is no record for this pref in the database.
michael@0 55 *
michael@0 56 * This method can be called from content processes in electrolysis builds.
michael@0 57 * We have a whitelist of values that can be read in such a way.
michael@0 58 *
michael@0 59 * @param aGroup the group for which to get the pref, as an nsIURI
michael@0 60 * from which the hostname will be used, a string
michael@0 61 * (typically in the format of a hostname), or null
michael@0 62 * to get the global pref (applies to all sites)
michael@0 63 * @param aName the name of the pref to get
michael@0 64 * @param aPrivacyContext
michael@0 65 * a context from which to determine the privacy status
michael@0 66 * of the pref (ie. whether to search in memory or in
michael@0 67 * permanent storage for it), obtained from a relevant
michael@0 68 * window or channel.
michael@0 69 * @param aCallback an optional nsIContentPrefCallback to receive the
michael@0 70 * result. If desired, JavaScript callers can instead
michael@0 71 * provide a function to call upon completion
michael@0 72 *
michael@0 73 * @returns the value of the pref
michael@0 74 * @throws NS_ERROR_ILLEGAL_VALUE if aGroup is not a string, nsIURI, or null
michael@0 75 * @throws NS_ERROR_ILLEGAL_VALUE if aName is null or an empty string
michael@0 76 */
michael@0 77 nsIVariant getPref(in nsIVariant aGroup, in AString aName,
michael@0 78 in nsILoadContext aPrivacyContext,
michael@0 79 [optional] in nsIContentPrefCallback aCallback);
michael@0 80
michael@0 81 /**
michael@0 82 * Set a pref.
michael@0 83 *
michael@0 84 * This method can be called from content processes in electrolysis builds.
michael@0 85 * We have a whitelist of values that can be set in such a way.
michael@0 86 *
michael@0 87 * @param aGroup the group for which to set the pref, as an nsIURI
michael@0 88 * from which the hostname will be used, a string
michael@0 89 * (typically in the format of a hostname), or null
michael@0 90 * to set the global pref (applies to all sites)
michael@0 91 * @param aName the name of the pref to set
michael@0 92 * @param aValue the new value of the pref
michael@0 93 * @param aPrivacyContext
michael@0 94 * a context from which to determine the privacy status
michael@0 95 * of the pref (ie. whether to store it in memory or in
michael@0 96 * permanent storage), obtained from a relevant
michael@0 97 * window or channel.
michael@0 98 * @throws NS_ERROR_ILLEGAL_VALUE if aGroup is not a string, nsIURI, or null
michael@0 99 * @throws NS_ERROR_ILLEGAL_VALUE if aName is null or an empty string
michael@0 100 */
michael@0 101 void setPref(in nsIVariant aGroup, in AString aName, in nsIVariant aValue, in nsILoadContext aPrivacyContext);
michael@0 102
michael@0 103 /**
michael@0 104 * Check whether or not a pref exists.
michael@0 105 *
michael@0 106 * @param aGroup the group for which to check for the pref, as an nsIURI
michael@0 107 * from which the hostname will be used, a string
michael@0 108 * (typically in the format of a hostname), or null
michael@0 109 * to check for the global pref (applies to all sites)
michael@0 110 * @param aName the name of the pref to check for
michael@0 111 * @param aPrivacyContext
michael@0 112 * a context from which to determine the privacy status
michael@0 113 * of the pref (ie. whether to search in memory or in
michael@0 114 * permanent storage for it), obtained from a relevant
michael@0 115 * window or channel.
michael@0 116 * @throws NS_ERROR_ILLEGAL_VALUE if aGroup is not a string, nsIURI, or null
michael@0 117 * @throws NS_ERROR_ILLEGAL_VALUE if aName is null or an empty string
michael@0 118 */
michael@0 119 boolean hasPref(in nsIVariant aGroup, in AString aName, in nsILoadContext aContext);
michael@0 120
michael@0 121 /**
michael@0 122 * Check whether or not the value of a pref (or its non-existance) is cached.
michael@0 123 *
michael@0 124 * @param aGroup the group for which to check for the pref, as an nsIURI
michael@0 125 * from which the hostname will be used, a string
michael@0 126 * (typically in the format of a hostname), or null
michael@0 127 * to check for the global pref (applies to all sites)
michael@0 128 * @param aName the name of the pref to check for
michael@0 129 * @param aPrivacyContext
michael@0 130 * a context from which to determine the privacy status
michael@0 131 * of the pref (ie. whether to search in memory or in
michael@0 132 * permanent storage for it), obtained from a relevant
michael@0 133 * window or channel.
michael@0 134 * @throws NS_ERROR_ILLEGAL_VALUE if aGroup is not a string, nsIURI, or null
michael@0 135 * @throws NS_ERROR_ILLEGAL_VALUE if aName is null or an empty string
michael@0 136 */
michael@0 137 boolean hasCachedPref(in nsIVariant aGroup, in AString aName, in nsILoadContext aContext);
michael@0 138
michael@0 139 /**
michael@0 140 * Remove a pref.
michael@0 141 *
michael@0 142 * @param aGroup the group for which to remove the pref, as an nsIURI
michael@0 143 * from which the hostname will be used, a string
michael@0 144 * (typically in the format of a hostname), or null
michael@0 145 * to remove the global pref (applies to all sites)
michael@0 146 * @param aName the name of the pref to remove
michael@0 147 * @param aPrivacyContext
michael@0 148 * a context from which to determine the privacy status
michael@0 149 * of the pref (ie. whether to search in memory or in
michael@0 150 * permanent storage for it), obtained from a relevant
michael@0 151 * window or channel.
michael@0 152 * @throws NS_ERROR_ILLEGAL_VALUE if aGroup is not a string, nsIURI, or null
michael@0 153 * @throws NS_ERROR_ILLEGAL_VALUE if aName is null or an empty string
michael@0 154 */
michael@0 155 void removePref(in nsIVariant aGroup, in AString aName, in nsILoadContext aContext);
michael@0 156
michael@0 157 /**
michael@0 158 * Remove all grouped prefs. Useful for removing references to the sites
michael@0 159 * the user has visited when the user clears their private data.
michael@0 160 *
michael@0 161 * @param aPrivacyContext
michael@0 162 * a context from which to determine the privacy status
michael@0 163 * of the pref (ie. whether to remove prefs in memory or
michael@0 164 * in permanent storage), obtained from a relevant
michael@0 165 * window or channel.
michael@0 166 */
michael@0 167 void removeGroupedPrefs(in nsILoadContext aContext);
michael@0 168
michael@0 169 /**
michael@0 170 * Remove all prefs with the given name.
michael@0 171 *
michael@0 172 * @param aName the setting name for which to remove prefs
michael@0 173 * @param aPrivacyContext
michael@0 174 * a context from which to determine the privacy status
michael@0 175 * of the prefs (ie. whether to remove prefs in memory or
michael@0 176 * in permanent storage), obtained from a relevant
michael@0 177 * window or channel.
michael@0 178 * @throws NS_ERROR_ILLEGAL_VALUE if aName is null or an empty string
michael@0 179 */
michael@0 180 void removePrefsByName(in AString aName, in nsILoadContext aContext);
michael@0 181
michael@0 182 /**
michael@0 183 * Get the prefs that apply to the given site.
michael@0 184 *
michael@0 185 * @param aGroup the group for which to retrieve prefs, as an nsIURI
michael@0 186 * from which the hostname will be used, a string
michael@0 187 * (typically in the format of a hostname), or null
michael@0 188 * to get the global prefs (apply to all sites)
michael@0 189 * @param aPrivacyContext
michael@0 190 * a context from which to determine the privacy status
michael@0 191 * of the pref (ie. whether to search for prefs in memory
michael@0 192 * or in permanent storage), obtained from a relevant
michael@0 193 * window or channel.
michael@0 194 *
michael@0 195 * @returns a property bag of prefs
michael@0 196 * @throws NS_ERROR_ILLEGAL_VALUE if aGroup is not a string, nsIURI, or null
michael@0 197 */
michael@0 198 nsIPropertyBag2 getPrefs(in nsIVariant aGroup, in nsILoadContext aContext);
michael@0 199
michael@0 200 /**
michael@0 201 * Get the prefs with the given name.
michael@0 202 *
michael@0 203 * @param aName the setting name for which to retrieve prefs
michael@0 204 * @param aPrivacyContext
michael@0 205 * a context from which to determine the privacy status
michael@0 206 * of the pref (ie. whether to search for prefs in memory
michael@0 207 * or in permanent storage), obtained from a relevant
michael@0 208 * window or channel.
michael@0 209 *
michael@0 210 * @returns a property bag of prefs
michael@0 211 * @throws NS_ERROR_ILLEGAL_VALUE if aName is null or an empty string
michael@0 212 */
michael@0 213 nsIPropertyBag2 getPrefsByName(in AString aName, in nsILoadContext aContext);
michael@0 214
michael@0 215 /**
michael@0 216 * Add an observer.
michael@0 217 *
michael@0 218 * @param aName the setting to observe, or null to add
michael@0 219 * a generic observer that observes all settings
michael@0 220 * @param aObserver the observer to add
michael@0 221 */
michael@0 222 void addObserver(in AString aName, in nsIContentPrefObserver aObserver);
michael@0 223
michael@0 224 /**
michael@0 225 * Remove an observer.
michael@0 226 *
michael@0 227 * @param aName the setting being observed, or null to remove
michael@0 228 * a generic observer that observes all settings
michael@0 229 * @param aObserver the observer to remove
michael@0 230 */
michael@0 231 void removeObserver(in AString aName, in nsIContentPrefObserver aObserver);
michael@0 232
michael@0 233 /**
michael@0 234 * The component that the service uses to determine the groups to which
michael@0 235 * URIs belong. By default this is the "hostname grouper", which groups
michael@0 236 * URIs by full hostname (a.k.a. site).
michael@0 237 */
michael@0 238 readonly attribute nsIContentURIGrouper grouper;
michael@0 239
michael@0 240 /**
michael@0 241 * The database connection to the content preferences database.
michael@0 242 * Useful for accessing and manipulating preferences in ways that are caller-
michael@0 243 * specific or for which there is not yet a generic method, although generic
michael@0 244 * functionality useful to multiple callers should generally be added to this
michael@0 245 * unfrozen interface. Also useful for testing the database creation
michael@0 246 * and migration code.
michael@0 247 */
michael@0 248 readonly attribute mozIStorageConnection DBConnection;
michael@0 249 };
michael@0 250
michael@0 251 %{C++
michael@0 252 // The contractID for the generic implementation built in to xpcom.
michael@0 253 #define NS_CONTENT_PREF_SERVICE_CONTRACTID "@mozilla.org/content-pref/service;1"
michael@0 254 %}

mercurial