public abstract class PermissionRequest extends Object
WebChromeClient.onPermissionRequest(android.webkit.PermissionRequest)
and
WebChromeClient.onPermissionRequestCanceled(android.webkit.PermissionRequest)
.
Either grant()
or deny()
must be called in UI
thread to respond to the request.
New protected resources whose names are not defined here may be requested in
future versions of WebView, even when running on an older Android release. To
avoid unintentionally granting requests for new permissions, you should pass the
specific permissions you intend to grant to grant()
,
and avoid writing code like this example:
permissionRequest.grant(permissionRequest.getResources()) // This is wrong!!!See the WebView's release notes for information about new protected resources.
Modifier and Type | Field and Description |
---|---|
static String |
RESOURCE_AUDIO_CAPTURE
Resource belongs to audio capture device, like microphone.
|
static String |
RESOURCE_MIDI_SYSEX
Resource will allow sysex messages to be sent to or received from MIDI devices.
|
static String |
RESOURCE_PROTECTED_MEDIA_ID
Resource belongs to protected media identifier.
|
static String |
RESOURCE_VIDEO_CAPTURE
Resource belongs to video capture device, like camera.
|
Constructor and Description |
---|
PermissionRequest() |
Modifier and Type | Method and Description |
---|---|
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.
|
public static final String RESOURCE_VIDEO_CAPTURE
public static final String RESOURCE_AUDIO_CAPTURE
public static final String RESOURCE_PROTECTED_MEDIA_ID
public static final String RESOURCE_MIDI_SYSEX
public abstract Uri getOrigin()
public abstract String[] getResources()
public abstract void grant(String[] resources)
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.public abstract void deny()