1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
39 * This file contains an interface to the Permission Manager,
40 * used to persistenly store permissions for different object types (cookies,
41 * images etc) on a site-by-site basis.
43 * This service broadcasts the following notification when the permission list
46 * topic : "perm-changed" (PERM_CHANGE_NOTIFICATION)
47 * broadcast whenever the permission list changes in some way. there
48 * are four possible data strings for this notification; one
49 * notification will be broadcast for each change, and will involve
50 * a single permission.
51 * subject: an nsIPermission interface pointer representing the permission object
54 * a permission was deleted. the subject is the deleted permission.
56 * a permission was added. the subject is the added permission.
58 * a permission was changed. the subject is the new permission.
60 * the entire permission list was cleared. the subject is null.
63 #include
"nsISupports.idl"
64 #include
"nsISimpleEnumerator.idl"
67 interface nsIObserver
;
69 [scriptable
, uuid(00708302-684c
-42d6
-a5a3
-995d51b1d17c
)]
70 interface nsIPermissionManager
: nsISupports
73 * Predefined return values for the testPermission method and for
74 * the permission param of the add method
75 * NOTE: UNKNOWN_ACTION (0) is reserved to represent the
76 * default permission when no entry is found for a host, and
77 * should not be used by consumers to indicate otherwise.
79 const PRUint32 UNKNOWN_ACTION
= 0;
80 const PRUint32 ALLOW_ACTION
= 1;
81 const PRUint32 DENY_ACTION
= 2;
84 * Add permission information for a given URI and permission type. This
85 * operation will cause the type string to be registered if it does not
86 * currently exist. If a permission already exists for a given type, it
89 * @param uri the uri to add the permission for
90 * @param type a case-sensitive ASCII string, identifying the consumer.
91 * Consumers should choose this string to be unique, with
92 * respect to other consumers.
93 * @param permission an integer representing the desired action (e.g. allow
94 * or deny). The interpretation of this number is up to the
95 * consumer, and may represent different actions for different
96 * types. Consumers may use one of the enumerated permission
97 * actions defined above, for convenience.
98 * NOTE: UNKNOWN_ACTION (0) is reserved to represent the
99 * default permission when no entry is found for a host, and
100 * should not be used by consumers to indicate otherwise.
102 void add
(in nsIURI uri
,
104 in PRUint32 permission
);
107 * Remove permission information for a given host string and permission type.
108 * The host string represents the exact entry in the permission list (such as
109 * obtained from the enumerator), not a URI which that permission might apply
112 * @param host the host to remove the permission for
113 * @param type a case-sensitive ASCII string, identifying the consumer.
114 * The type must have been previously registered using the
117 void remove
(in AUTF8String host
,
121 * Clear permission information for all websites.
126 * Test whether a website has permission to perform the given action.
127 * @param uri the uri to be tested
128 * @param type a case-sensitive ASCII string, identifying the consumer
129 * @param return see add(), param permission. returns UNKNOWN_ACTION when
130 * there is no stored permission for this uri and / or type.
132 PRUint32 testPermission
(in nsIURI uri
,
136 * Test whether a website has permission to perform the given action.
137 * This requires an exact hostname match, subdomains are not a match.
138 * @param uri the uri to be tested
139 * @param type a case-sensitive ASCII string, identifying the consumer
140 * @param return see add(), param permission. returns UNKNOWN_ACTION when
141 * there is no stored permission for this uri and / or type.
143 PRUint32 testExactPermission
(in nsIURI uri
,
147 * Allows enumeration of all stored permissions
148 * @return an nsISimpleEnumerator interface that allows access to
149 * nsIPermission objects
151 readonly attribute nsISimpleEnumerator enumerator
;
155 #define NS_PERMISSIONMANAGER_CONTRACTID
"@mozilla.org/permissionmanager;1"
157 #define PERM_CHANGE_NOTIFICATION
"perm-changed"