Android APIs
public abstract class

PermissionRequest

extends Object
java.lang.Object
   ↳ android.webkit.PermissionRequest

Class Overview

This class defines a permission request and is used when web content requests access to protected resources. The permission request related events are delivered via onPermissionRequest(PermissionRequest) and onPermissionRequestCanceled(PermissionRequest). Either grant() or deny() must be called in UI thread to respond to the request.

Summary

Constants
String RESOURCE_AUDIO_CAPTURE Resource belongs to audio capture device, like microphone.
String RESOURCE_PROTECTED_MEDIA_ID Resource belongs to protected media identifier.
String RESOURCE_VIDEO_CAPTURE Resource belongs to video capture device, like camera.
Public Constructors
PermissionRequest()
Public Methods
abstract void deny()
Call this method to deny the request.
abstract Uri getOrigin()
Call this method to get the origin of the web page which is trying to access the restricted resources.
abstract String[] getResources()
Call this method to get the resources the web page is trying to access.
abstract void grant(String[] resources)
Call this method to grant origin the permission to access the given resources.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String RESOURCE_AUDIO_CAPTURE

Added in API level 21

Resource belongs to audio capture device, like microphone.

Constant Value: "android.webkit.resource.AUDIO_CAPTURE"

public static final String RESOURCE_PROTECTED_MEDIA_ID

Added in API level 21

Resource belongs to protected media identifier. After the user grants this resource, the origin can use EME APIs to generate the license requests.

Constant Value: "android.webkit.resource.PROTECTED_MEDIA_ID"

public static final String RESOURCE_VIDEO_CAPTURE

Added in API level 21

Resource belongs to video capture device, like camera.

Constant Value: "android.webkit.resource.VIDEO_CAPTURE"

Public Constructors

public PermissionRequest ()

Added in API level 21

Public Methods

public abstract void deny ()

Added in API level 21

Call this method to deny the request.

public abstract Uri getOrigin ()

Added in API level 21

Call this method to get the origin of the web page which is trying to access the restricted resources.

Returns
  • the origin of web content which attempt to access the restricted resources.

public abstract String[] getResources ()

Added in API level 21

Call this method to get the resources the web page is trying to access.

Returns
  • the array of resources the web content wants to access.

public abstract void grant (String[] resources)

Added in API level 21

Call this method to grant origin the permission to access the given resources. The granted permission is only valid for this WebView.

Parameters
resources the resources granted to be accessed by origin, to grant request, the requested resources returned by getResources() must be equals or a subset of granted resources. This parameter is designed to avoid granting permission by accident especially when new resources are requested by web content.