1 /* ***** BEGIN LICENSE BLOCK *****
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3 *
4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/MPL/
8 *
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
12 * License.
13 *
14 * The Original Code is Content Preferences (cpref).
15 *
16 * The Initial Developer of the Original Code is Mozilla.
17 * Portions created by the Initial Developer are Copyright (C) 2006
18 * the Initial Developer. All Rights Reserved.
19 *
20 * Contributor(s):
21 * Myk Melez <myk@mozilla.org>
22 *
23 * Alternatively, the contents of this file may be used under the terms of
24 * either the GNU General Public License Version 2 or later (the "GPL"), or
25 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26 * in which case the provisions of the GPL or the LGPL are applicable instead
27 * of those above. If you wish to allow use of your version of this file only
28 * under the terms of either the GPL or the LGPL, and not to allow others to
29 * use your version of this file under the terms of the MPL, indicate your
30 * decision by deleting the provisions above and replace them with the notice
31 * and other provisions required by the GPL or the LGPL. If you do not delete
32 * the provisions above, a recipient may use your version of this file under
33 * the terms of any one of the MPL, the GPL or the LGPL.
34 *
35 * ***** END LICENSE BLOCK ***** */
36
37 #include "nsISupports.idl"
38
39 interface nsIVariant;
40 interface nsIURI;
41 interface nsIPropertyBag2;
42 interface nsIContentURIGrouper;
43 interface mozIStorageConnection;
44
45 [scriptable, uuid(746c7a02-f6c1-4869-b434-7c8b86e60e61)]
46 interface nsIContentPrefObserver : nsISupports
47 {
48 /**
49 * Called when a content pref is set to a different value.
50 *
51 * @param aGroup the group to which the pref belongs, or null
52 * if it's a global pref (applies to all URIs)
53 * @param aName the name of the pref that was set
54 * @param aValue the new value of the pref
55 */
56 void onContentPrefSet(in AString aGroup, in AString aName, in nsIVariant aValue);
57
58 /**
59 * Called when a content pref is removed.
60 *
61 * @param aGroup the group to which the pref belongs, or null
62 * if it's a global pref (applies to all URIs)
63 * @param aName the name of the pref that was removed
64 */
65 void onContentPrefRemoved(in AString aGroup, in AString aName);
66 };
67
68 [scriptable, uuid(72c05ba2-9d92-4661-b053-f8f869973e6a)]
69 interface nsIContentPrefService : nsISupports
70 {
71 /**
72 * Get a pref.
73 *
74 * Besides the regular string, integer, boolean, etc. values, this method
75 * may return null (nsIDataType::VTYPE_EMPTY), which means the pref is set
76 * to NULL in the database, as well as undefined (nsIDataType::VTYPE_VOID),
77 * which means there is no record for this pref in the database.
78 *
79 * @param aURI the URI for which to get the pref, or null to get
80 * the global pref (applies to all URIs)
81 * @param aName the name of the pref to get
82 *
83 * @returns the value of the pref
84 */
85 nsIVariant getPref(in nsIURI aURI, in AString aName);
86
87 /**
88 * Set a pref.
89 *
90 * @param aURI the URI for which to set the pref, or null to set
91 * the global pref (applies to all URIs)
92 * @param aName the name of the pref to set
93 * @param aValue the new value of the pref
94 */
95 void setPref(in nsIURI aURI, in AString aName, in nsIVariant aValue);
96
97 /**
98 * Check whether or not a pref exists.
99 *
100 * @param aURI the URI for which to check for the pref
101 * @param aName the name of the pref to check for
102 */
103 boolean hasPref(in nsIURI aURI, in AString aName);
104
105 /**
106 * Remove a pref.
107 *
108 * @param aURI the URI for which to remove the pref
109 * @param aName the name of the pref to remove
110 */
111 void removePref(in nsIURI aURI, in AString aName);
112
113 /**
114 * Get the prefs that apply to the given URI.
115 *
116 * @param aURI the URI for which to retrieve prefs
117 *
118 * @returns a property bag of prefs
119 */
120 nsIPropertyBag2 getPrefs(in nsIURI aURI);
121
122 /**
123 * Add an observer.
124 *
125 * @param aName the setting to observe, or null to add
126 * a generic observer that observes all settings
127 * @param aObserver the observer to add
128 */
129 void addObserver(in AString aName, in nsIContentPrefObserver aObserver);
130
131 /**
132 * Remove an observer.
133 *
134 * @param aName the setting being observed, or null to remove
135 * a generic observer that observes all settings
136 * @param aObserver the observer to remove
137 */
138 void removeObserver(in AString aName, in nsIContentPrefObserver aObserver);
139
140 /**
141 * The component that the service uses to determine the groups to which
142 * URIs belong. By default this is the "hostname grouper", which groups
143 * URIs by full hostname (a.k.a. site).
144 */
145 readonly attribute nsIContentURIGrouper grouper;
146
147 /**
148 * The database connection to the content preferences database.
149 * Useful for accessing and manipulating preferences in ways that are caller-
150 * specific or for which there is not yet a generic method, although generic
151 * functionality useful to multiple callers should generally be added to this
152 * unfrozen interface. Also useful for testing the database creation
153 * and migration code.
154 */
155 readonly attribute mozIStorageConnection DBConnection;
156 };