Make sure to notify permissions-core@ when you plan to add a new permission.
PermissionType roughly matches the web-facing APIs for Permission Policy and Permissions API.
ContentSettingsType is a key used in HostContentSettingsMap to store per-type and per-origin JSON dictionaries. It contains all entries from PermissionType but additionally, it contains entries that are not permissions, e.g. Cookies, Images, Javascript, Sound, etc.
ContentSettingsType represents the Chrome-layer entity and is not available outside of Chrome. We use PermissionType as a Web Platform - layer list of permissions. That means we always need to have a pair of PermissionType ContentSettingsType. To improve clarity of the permissions API we’re trying to use PermissionType everywhere it is possible. Conceptually ContentSettingsType should be used only in HostContentSettingsMap. But there are still a few places where ContentSettingsType is presented.
We’re actively working on reducing ContentSettingsType footprint in the permissions code base.
We have a few utils methods in components/permissions/permission_util.h that convert PermissionType to ContentSettingsType and vice versa. We strongly encourage developers to use PermissionType.
PermissionContextBase provides default implementation for requesting/verifying and saving a permission state. Most of the methods in the class are virtual that allows for a newly added permission to customize how it can be requested, verified and stored. A custom implementation of the PermissionContextBase is the only way to init permission policy. For most of the cases you do not need to change the default implementation. A good example of the custom behavior is an integration with OS-level permissions. E.g. Notifications permission on Android has custom logic that verifies if Chrome has app-level permission and if a notification channel exists, additionally Notifications has custom logic for extensions. Similarly Geolocation has multiple implementations for different platforms GeolocationPermissionContext.
std::nullopt
. That means it will not block back-forward cache. If your feature needs to block it, make sure it is explicitly mentioned in a design doc as that needs to be reviewed.If you add a new ContentSettingsType which require no UI and no associated permission, then:
Some ContentSettingsType is displayed in chrome://settings/content
. To be able to display it there, you need to do:
IMPORTANT
: The order in the array is not random or organic. Please carefully read the comment.Most permissions allow sites to request a permission prompt where a user can grant or deny the permission.
name="PermissionType"
name="ContentType"
name="PermissionRequestType"
name="PermissionTypes"
name="PermissionRequestTypes"
<token key="ContentSettingsType">
To extend PermissionContextBase:
<PermissionName>PermissionContext
and extend permissions::PermissionContextBase.components/permissions/contexts/
or in a feature folder.Add new permissions for browser automation (e2e testing).
If you need to add a permission policy:
In permissions_policy_feature.mojom update enum PermissionsPolicyFeature
In permissions_policy_features.json5 update data
array with the new policy. Also update PermissionPolicyFeature enum in browser_protocol.pdl
In the <PermissionName>PermissionContext
, make sure to initialize the permission policy variable permissions_policy_feature_ in the class ctor.
Permissions infrastructure has its own provider for storing policies PolicyProvider. If you plan on allowing enterprise admins to control your newly added permission:
enum name="EnterprisePolicies"