2003-03-22 04:24:51 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2001-03-29 06:11:48 +04:00
|
|
|
|
2003-03-22 04:24:51 +03:00
|
|
|
/**
|
|
|
|
* This file contains an interface to the Permission Manager,
|
2003-07-09 04:20:57 +04:00
|
|
|
* used to persistenly store permissions for different object types (cookies,
|
|
|
|
* images etc) on a site-by-site basis.
|
2003-03-22 04:24:51 +03:00
|
|
|
*
|
2003-10-22 10:53:19 +04:00
|
|
|
* This service broadcasts the following notification when the permission list
|
|
|
|
* is changed:
|
|
|
|
*
|
|
|
|
* topic : "perm-changed" (PERM_CHANGE_NOTIFICATION)
|
|
|
|
* broadcast whenever the permission list changes in some way. there
|
|
|
|
* are four possible data strings for this notification; one
|
|
|
|
* notification will be broadcast for each change, and will involve
|
|
|
|
* a single permission.
|
|
|
|
* subject: an nsIPermission interface pointer representing the permission object
|
|
|
|
* that changed.
|
|
|
|
* data : "deleted"
|
|
|
|
* a permission was deleted. the subject is the deleted permission.
|
|
|
|
* "added"
|
|
|
|
* a permission was added. the subject is the added permission.
|
|
|
|
* "changed"
|
|
|
|
* a permission was changed. the subject is the new permission.
|
|
|
|
* "cleared"
|
|
|
|
* the entire permission list was cleared. the subject is null.
|
2001-03-29 06:11:48 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "nsISupports.idl"
|
|
|
|
|
2012-07-09 14:26:12 +04:00
|
|
|
interface nsIPrincipal;
|
2013-06-06 23:59:31 +04:00
|
|
|
interface nsIPermission;
|
2017-03-03 00:53:33 +03:00
|
|
|
|
|
|
|
[scriptable, builtinclass, uuid(4dcb3851-eba2-4e42-b236-82d2596fca22)]
|
2001-03-29 06:11:48 +04:00
|
|
|
interface nsIPermissionManager : nsISupports
|
|
|
|
{
|
2003-03-22 04:24:51 +03:00
|
|
|
/**
|
2003-07-09 04:20:57 +04:00
|
|
|
* Predefined return values for the testPermission method and for
|
|
|
|
* the permission param of the add method
|
2007-12-05 09:37:36 +03:00
|
|
|
* NOTE: UNKNOWN_ACTION (0) is reserved to represent the
|
|
|
|
* default permission when no entry is found for a host, and
|
|
|
|
* should not be used by consumers to indicate otherwise.
|
2003-03-22 04:24:51 +03:00
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
const uint32_t UNKNOWN_ACTION = 0;
|
|
|
|
const uint32_t ALLOW_ACTION = 1;
|
|
|
|
const uint32_t DENY_ACTION = 2;
|
2012-09-19 22:19:00 +04:00
|
|
|
const uint32_t PROMPT_ACTION = 3;
|
2003-03-22 04:24:51 +03:00
|
|
|
|
2009-10-17 01:01:04 +04:00
|
|
|
/**
|
|
|
|
* Predefined expiration types for permissions. Permissions can be permanent
|
|
|
|
* (never expire), expire at the end of the session, or expire at a specified
|
2013-06-06 23:59:32 +04:00
|
|
|
* time. Permissions that expire at the end of a session may also have a
|
|
|
|
* specified expiration time.
|
2018-01-24 06:07:10 +03:00
|
|
|
*
|
|
|
|
* EXPIRE_POLICY is a special expiration status. It is set when the permission
|
|
|
|
* is set by reading an enterprise policy. These permissions cannot be overridden.
|
2009-10-17 01:01:04 +04:00
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
const uint32_t EXPIRE_NEVER = 0;
|
|
|
|
const uint32_t EXPIRE_SESSION = 1;
|
|
|
|
const uint32_t EXPIRE_TIME = 2;
|
2018-01-24 06:07:10 +03:00
|
|
|
const uint32_t EXPIRE_POLICY = 3;
|
2009-10-17 01:01:04 +04:00
|
|
|
|
2016-07-07 17:27:10 +03:00
|
|
|
|
2018-07-10 11:09:59 +03:00
|
|
|
/**
|
|
|
|
* Get all custom permissions for a given nsIPrincipal. This will return an
|
|
|
|
* enumerator of all permissions which are not set to default and which
|
|
|
|
* belong to the matching principal of the given nsIPrincipal.
|
|
|
|
*
|
|
|
|
* @param principal the URI to get all permissions for
|
|
|
|
*/
|
2019-10-29 04:13:57 +03:00
|
|
|
Array<nsIPermission> getAllForPrincipal(in nsIPrincipal principal);
|
2018-07-10 11:09:59 +03:00
|
|
|
|
2018-11-27 19:50:39 +03:00
|
|
|
/**
|
|
|
|
* Get all custom permissions of a specific type, specified with a prefix
|
|
|
|
* string. This will return an array of all permissions which are not set to
|
|
|
|
* default. Also the passed type argument is either equal to or a prefix of
|
|
|
|
* the type of the returned permissions.
|
|
|
|
*
|
|
|
|
* @param prefix the type prefix string
|
|
|
|
*/
|
|
|
|
Array<nsIPermission> getAllWithTypePrefix(in ACString prefix);
|
|
|
|
|
2012-07-09 14:26:12 +04:00
|
|
|
/**
|
|
|
|
* Add permission information for a given principal.
|
|
|
|
* It is internally calling the other add() method using the nsIURI from the
|
|
|
|
* principal.
|
2012-07-18 19:24:01 +04:00
|
|
|
* Passing a system principal will be a no-op because they will always be
|
|
|
|
* granted permissions.
|
2012-07-09 14:26:12 +04:00
|
|
|
*/
|
2019-02-22 01:54:28 +03:00
|
|
|
void addFromPrincipal(in nsIPrincipal principal, in ACString type,
|
2012-08-22 19:56:38 +04:00
|
|
|
in uint32_t permission,
|
|
|
|
[optional] in uint32_t expireType,
|
|
|
|
[optional] in int64_t expireTime);
|
2012-07-09 14:26:12 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove permission information for a given principal.
|
|
|
|
* This is internally calling remove() with the host from the principal's URI.
|
2012-07-18 19:24:01 +04:00
|
|
|
* Passing system principal will be a no-op because we never add them to the
|
|
|
|
* database.
|
2012-07-09 14:26:12 +04:00
|
|
|
*/
|
2019-02-22 01:54:28 +03:00
|
|
|
void removeFromPrincipal(in nsIPrincipal principal, in ACString type);
|
2012-07-09 14:26:12 +04:00
|
|
|
|
2015-05-29 22:34:26 +03:00
|
|
|
/**
|
|
|
|
* Remove the given permission from the permission manager.
|
|
|
|
*
|
|
|
|
* @param perm a permission obtained from the permission manager.
|
|
|
|
*/
|
|
|
|
void removePermission(in nsIPermission perm);
|
|
|
|
|
2003-03-22 04:24:51 +03:00
|
|
|
/**
|
|
|
|
* Clear permission information for all websites.
|
|
|
|
*/
|
2001-03-29 06:11:48 +04:00
|
|
|
void removeAll();
|
2003-03-22 04:24:51 +03:00
|
|
|
|
2014-09-15 05:33:12 +04:00
|
|
|
/**
|
|
|
|
* Clear all permission information added since the specified time.
|
|
|
|
*/
|
|
|
|
void removeAllSince(in int64_t since);
|
|
|
|
|
2018-08-21 02:15:06 +03:00
|
|
|
/**
|
|
|
|
* Clear all permissions of the passed type.
|
|
|
|
*/
|
2019-02-22 01:54:28 +03:00
|
|
|
void removeByType(in ACString type);
|
2018-08-21 02:15:06 +03:00
|
|
|
|
2019-03-28 21:44:08 +03:00
|
|
|
/**
|
|
|
|
* Clear all permissions of the passed type added since the specified time.
|
|
|
|
* @param type a case-sensitive ASCII string, identifying the permission.
|
|
|
|
* @param since a unix timestamp representing the number of milliseconds from
|
|
|
|
* Jan 1, 1970 00:00:00 UTC.
|
|
|
|
*/
|
|
|
|
void removeByTypeSince(in ACString type, in int64_t since);
|
|
|
|
|
2012-07-09 14:26:12 +04:00
|
|
|
/**
|
|
|
|
* Test whether the principal has the permission to perform a given action.
|
2012-07-18 19:24:01 +04:00
|
|
|
* System principals will always have permissions granted.
|
2017-07-11 00:13:43 +03:00
|
|
|
* This function will perform a pref lookup to permissions.default.<type>
|
|
|
|
* if the specific permission type is part of the whitelist for that functionality.
|
2012-07-09 14:26:12 +04:00
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t testPermissionFromPrincipal(in nsIPrincipal principal,
|
2019-02-22 01:54:28 +03:00
|
|
|
in ACString type);
|
2012-07-09 14:26:12 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* See testExactPermission() above.
|
2012-07-18 19:24:01 +04:00
|
|
|
* System principals will always have permissions granted.
|
2017-07-11 00:13:43 +03:00
|
|
|
* This function will perform a pref lookup to permissions.default.<type>
|
|
|
|
* if the specific permission type is part of the whitelist for that functionality.
|
2012-07-09 14:26:12 +04:00
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t testExactPermissionFromPrincipal(in nsIPrincipal principal,
|
2019-02-22 01:54:28 +03:00
|
|
|
in ACString type);
|
2012-07-09 14:26:12 +04:00
|
|
|
|
2013-01-11 00:23:39 +04:00
|
|
|
/**
|
|
|
|
* Test whether a website has permission to perform the given action
|
|
|
|
* ignoring active sessions.
|
|
|
|
* System principals will always have permissions granted.
|
2017-07-11 00:13:43 +03:00
|
|
|
* This function will perform a pref lookup to permissions.default.<type>
|
|
|
|
* if the specific permission type is part of the whitelist for that functionality.
|
2013-01-11 00:23:39 +04:00
|
|
|
*
|
|
|
|
* @param principal the principal
|
|
|
|
* @param type a case-sensitive ASCII string, identifying the consumer
|
|
|
|
* @param return see add(), param permission. returns UNKNOWN_ACTION when
|
|
|
|
* there is no stored permission for this uri and / or type.
|
|
|
|
*/
|
|
|
|
uint32_t testExactPermanentPermission(in nsIPrincipal principal,
|
2019-02-22 01:54:28 +03:00
|
|
|
in ACString type);
|
2013-01-11 00:23:39 +04:00
|
|
|
|
2013-06-06 23:59:31 +04:00
|
|
|
/**
|
|
|
|
* Get the permission object associated with the given principal and action.
|
|
|
|
* @param principal The principal
|
|
|
|
* @param type A case-sensitive ASCII string identifying the consumer
|
|
|
|
* @param exactHost If true, only the specific host will be matched,
|
|
|
|
* @see testExactPermission. If false, subdomains will
|
|
|
|
* also be searched, @see testPermission.
|
|
|
|
* @returns The matching permission object, or null if no matching object
|
|
|
|
* was found. No matching object is equivalent to UNKNOWN_ACTION.
|
|
|
|
* @note Clients in general should prefer the test* methods unless they
|
|
|
|
* need to know the specific stored details.
|
|
|
|
* @note This method will always return null for the system principal.
|
|
|
|
*/
|
|
|
|
nsIPermission getPermissionObject(in nsIPrincipal principal,
|
2019-02-22 01:54:28 +03:00
|
|
|
in ACString type,
|
2013-06-06 23:59:31 +04:00
|
|
|
in boolean exactHost);
|
|
|
|
|
2003-03-22 04:24:51 +03:00
|
|
|
/**
|
2019-10-29 04:56:25 +03:00
|
|
|
* Returns all stored permissions.
|
|
|
|
* @return an array of nsIPermission objects
|
2003-03-22 04:24:51 +03:00
|
|
|
*/
|
2019-10-29 04:56:25 +03:00
|
|
|
readonly attribute Array<nsIPermission> all;
|
2012-08-31 18:34:28 +04:00
|
|
|
|
Bug 1474608 - P1 - Clear origin attributes directly for deleteDataFromOriginAttributesPattern if it's possible; r=asuth,baku
The idea of this patch is to try to not use oberver mechanism as possible. To
achieve that, it introduces deleteByOriginAttributes() to cleaners. Different
from other methods, it would only be executed if it's implemented from a
cleaner.
It doesn't remove oberver mechanism entirely since some cleaners are still using
that for other deleteByXXX() functions. So, it only applies removing stuff to
PushService, QuotaManagerService, ServiceWorkerManager, nsPermissionManager,
nsApplicationCacheService, and nsCookieService.
Since the original issue is related to QuotaManagerService, it adds xpcshell
test under the dom/quota/test/unit/ to ensure the behavior won't be changed
accidentally in the future.
Differential Revision: https://phabricator.services.mozilla.com/D33758
--HG--
extra : moz-landing-system : lando
2019-12-02 22:47:13 +03:00
|
|
|
/**
|
|
|
|
* Remove all permissions that will match the origin pattern.
|
|
|
|
*/
|
|
|
|
void removePermissionsWithAttributes(in AString patternAsJSON);
|
|
|
|
|
2017-04-08 00:27:13 +03:00
|
|
|
/**
|
|
|
|
* Broadcasts permissions for the given principal to all content processes.
|
|
|
|
*
|
|
|
|
* DO NOT USE THIS METHOD if you can avoid it. It was added in bug XXX to
|
|
|
|
* handle the current temporary implementation of ServiceWorker debugging. It
|
|
|
|
* will be removed when service worker debugging is fixed.
|
|
|
|
*
|
|
|
|
* @param aPrincipal The principal to broadcast permissions for.
|
|
|
|
*/
|
|
|
|
void broadcastPermissionsForPrincipalToAllContentProcesses(in nsIPrincipal aPrincipal);
|
2001-03-29 06:11:48 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
%{ C++
|
|
|
|
#define NS_PERMISSIONMANAGER_CONTRACTID "@mozilla.org/permissionmanager;1"
|
2003-03-22 04:24:51 +03:00
|
|
|
|
|
|
|
#define PERM_CHANGE_NOTIFICATION "perm-changed"
|
2001-03-29 06:11:48 +04:00
|
|
|
%}
|