PySide6.QtWebEngineCore.QWebEnginePermission¶
- class QWebEnginePermission¶
A
QWebEnginePermission
is an object used to access and modify the state of a single permission that’s been granted or denied to a specific origin URL. More…Added in version 6.8.
Synopsis¶
Properties¶
isValidᅟ
- Indicates whether attempts to change the permission’s state will be successfuloriginᅟ
- URL of the permission’s associated originpermissionTypeᅟ
- Permission type associated with this permissionstateᅟ
- Current state of the permission
Methods¶
Static functions¶
def
isPersistent()
Note
This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
Detailed Description¶
The typical usage pattern is as follows:
A website requests a specific permission, triggering the
permissionRequested()
signal;The signal handler triggers a prompt asking the user whether they want to grant the permission;
When the user has made their decision, the application calls
grant()
ordeny()
;
Alternatively, an application interested in modifying already granted permissions may use
listAllPermissions()
to get a list of existing permissions associated with a profile, orqueryPermission()
to get aQWebEnginePermission
object for a specific permission.The
origin()
property can be used to query which origin theQWebEnginePermission
is associated with, while thepermissionType()
property describes the type of the requested permission. A website origin is the combination of its scheme, hostname, and port. Permissions are granted on a per-origin basis; thus, if the web pagehttps://www.example.com:12345/some/page.html
requests a permission, it will be granted to the originhttps://www.example.com:12345/
.PermissionType
describes all the permission types Qt WebEngine supports. Only some permission types are remembered between browsing sessions; they are persistent. Non-persistent permissions query the user every time a website requests them. You can check whether a permission type is persistent at runtime using the static methodisPersistent()
.Persistent permissions are stored inside the active
QWebEngineProfile
, and their lifetime depends on the value ofpersistentPermissionsPolicy()
. By default, named profiles store their permissions on disk, whereas off-the-record ones store them in memory (and destroy them when the profile is destroyed). A stored permission will not query the user the next time a website requests it; instead it will be automatically granted or denied, depending on the resolution the user picked initially. To erase a stored permission, callreset()
on it.A non-persistent permission, on the other hand, is only usable until the related
QWebEnginePage
performs a navigation to a different URL, or is destroyed.You can check whether a
QWebEnginePermission
is in a valid state using itsisValid()
property. For invalid objects, calls togrant()
,deny()
, orreset()
will do nothing, while calls tostate()
will always returnInvalid
.- class PermissionType¶
This enum type holds the type of the requested permission type:
Constant
Description
QWebEnginePermission.PermissionType.MediaAudioCapture
Access to a microphone, or another audio source. This permission is not persistent.
QWebEnginePermission.PermissionType.MediaVideoCapture
Access to a webcam, or another video source. This permission is not persistent.
QWebEnginePermission.PermissionType.MediaAudioVideoCapture
Combination of MediaAudioCapture and MediaVideoCapture. This permission is not persistent.
QWebEnginePermission.PermissionType.DesktopVideoCapture
Access to the contents of the user’s screen. This permission is not persistent.
QWebEnginePermission.PermissionType.DesktopAudioVideoCapture
Access to the contents of the user’s screen, and application audio. This permission is not persistent.
QWebEnginePermission.PermissionType.MouseLock
Locks the pointer inside an element on the web page. This permission is not persistent.
QWebEnginePermission.PermissionType.Notifications
Allows the website to send notifications to the user. This permission is persistent.
QWebEnginePermission.PermissionType.Geolocation
Access to the user’s physical location. This permission is persistent.
QWebEnginePermission.PermissionType.ClipboardReadWrite
Access to the user’s clipboard. This permission is persistent.
QWebEnginePermission.PermissionType.LocalFontsAccess
Access to the fonts installed on the user’s machine. Only available on desktops. This permission is persistent.
QWebEnginePermission.PermissionType.Unsupported
An unsupported permission type.
Note
Non-persistent permission types are ones that will never be remembered by the underlying storage, and will trigger a permission request every time a website tries to use them.
- class State¶
This enum type holds the current state of the requested permission:
Constant
Description
QWebEnginePermission.State.Invalid
Object is in an invalid state, and any attempts to modify the described permission will fail.
QWebEnginePermission.State.Ask
Either the permission has not been requested before, or the
permissionType()
is not persistent.QWebEnginePermission.State.Granted
Permission has already been granted.
QWebEnginePermission.State.Denied
Permission has already been denied.
Note
Properties can be used directly when
from __feature__ import true_property
is used or via accessor functions otherwise.- property isValidᅟ: bool¶
This property holds Indicates whether attempts to change the permission’s state will be successful..
An invalid
QWebEnginePermission
is either:One whose
permissionType()
is unsupported;One whose
origin()
is invalid;One whose associated profile has been destroyed
See also
- Access functions:
This property holds The URL of the permission’s associated origin..
A website origin is the combination of its scheme, hostname, and port. Permissions are granted on a per-origin basis; thus, if the web page
https://www.example.com:12345/some/page.html
requests a permission, it will be granted to the originhttps://www.example.com:12345/
.- Access functions:
- property permissionTypeᅟ: QWebEnginePermission.PermissionType¶
This property holds The permission type associated with this permission..
- Access functions:
- property stateᅟ: QWebEnginePermission.State¶
This property holds The current state of the permission..
If a permission for the specified
permissionType()
andorigin()
has already been granted or denied, the return value isGranted
, orDenied
, respectively. When this is the first time the permission is requested, the return value isAsk
. If the object is in an invalid state, the returned value isInvalid
.See also
- Access functions:
- __init__()¶
- __init__(other)
- Parameters:
other –
QWebEnginePermission
- deny()¶
Stops the associated origin from accessing the requested
permissionType
. Does nothing whenisValid()
evaluates to false.- grant()¶
Allows the associated origin to access the requested
permissionType
. Does nothing whenisValid()
evaluates to false.- static isPersistent(permissionType)¶
- Parameters:
permissionType –
PermissionType
- Return type:
bool
Returns whether a
permissionType
is persistent, meaning that a permission’s state will be remembered and the user will not be queried the next time the website requests the same permission.- isValid()¶
- Return type:
bool
Getter of property
isValidᅟ
.- __ne__(rhs)¶
- Parameters:
rhs –
QWebEnginePermission
- Return type:
bool
- __eq__(rhs)¶
- Parameters:
rhs –
QWebEnginePermission
- Return type:
bool
Getter of property
originᅟ
.- permissionType()¶
- Return type:
Getter of property
permissionTypeᅟ
.- reset()¶
Removes the permission from the profile’s underlying storage. By default, permissions are stored on disk (except for off-the-record profiles, where permissions are stored in memory and are destroyed with the profile). This means that an already granted/denied permission will not be requested twice, but will get automatically granted/denied every subsequent time a website requests it. Calling reset() allows the query to be displayed again the next time the website requests it.
Does nothing when
isValid()
evaluates to false.Getter of property
stateᅟ
.- swap(other)¶
- Parameters:
other –
QWebEnginePermission