public class BrowserAgent extends Object
WebView in processing web content callbacks, for example, processing JavaScript events and website
attribute change events.WebView.setBrowserAgent(ohos.agp.components.webengine.BrowserAgent)| 构造器 | 说明 |
|---|---|
BrowserAgent(Context context) |
A constructor used to create a
BrowserAgent instance. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
void |
onDownload(WebView webView,
String url,
String userAgent,
String contentDisposition,
String mimeType,
long length) |
Called when a download event is triggered.
|
boolean |
onJsMessageShow(WebView webView,
String url,
String message,
boolean isAlert,
JsMessageResult result) |
Called when the page receives a JavaScript message pop-up.
|
boolean |
onJsTextInput(WebView webView,
String url,
String message,
String defaultInput,
JsTextInputResult result) |
Called when the page receives a JavaScript text input pop-up.
|
void |
onLocationApiAccessCancel() |
Called when the web content cancels the request for using the geographical location API.
|
void |
onLocationApiAccessRequest(String origin,
LocationAccessController.Response response) |
Called when the web content initiates a request for using the geographical location API.
|
boolean |
onPickFiles(WebView webView,
AsyncCallback<Uri[]> urisCallback,
PickFilesParams params) |
Called when a file selection event is triggered.
|
void |
onProgressUpdated(WebView webView,
int newValue) |
Called when the page loading progress updates.
|
void |
onRequestAccessCanceled(WebRequestAccess requestAccess) |
Called when web content revokes a request for access.
|
void |
onRequestAccessFromWebContent(WebRequestAccess requestAccess) |
Called when a web content requests access.
|
void |
onTitleUpdated(WebView webView,
String value) |
Called when the page title changes.
|
public BrowserAgent(Context context)
BrowserAgent instance.context - Indicates the context to use.public void onTitleUpdated(WebView webView, String value)
webView - Indicates the WebView that initiates the callback.value - Indicates the new page title.public void onProgressUpdated(WebView webView, int newValue)
webView - Indicates the WebView that initiates the callback.newValue - Indicates the updated progress.public void onDownload(WebView webView, String url, String userAgent, String contentDisposition, String mimeType, long length)
webView - Indicates the WebView that initiates the callback.url - Indicates the URL of the object to be downloaded.userAgent - Indicates the UserAgent used for the download.contentDisposition - Indicates the value of the Content-disposition attribute in
HTTP header.mimeType - Indicates the MIME type of the object to be downloaded.length - Indicates the size of the object to be downloaded.public boolean onJsMessageShow(WebView webView, String url, String message, boolean isAlert, JsMessageResult result)
webView - Indicates the WebView that initiates the callback.url - Indicates the URL of the WebView.message - Indicates the message to be displayed in the pop-up.isAlert - Specifies whether the message is intended for alerting. true indicates an alert message,
and false indicates a confirmation message.result - Indicates a JsMessageResult object used to respond to callback processing.true if the application handles the callback result when the pop-up is confirmed or
cancelled; returns false if the WebView uses the default handling.public boolean onJsTextInput(WebView webView, String url, String message, String defaultInput, JsTextInputResult result)
webView - Indicates the WebView that initiates the callback.url - Indicates the URL of the WebView.message - Indicates the message to be displayed in the pop-up.defaultInput - Indicates the default content to be displayed in the pop-up.result - Indicates a JsTextInputResult object used to respond to callback processing.true if the application handles the callback result when the pop-up is confirmed or
cancelled; returns false if the WebView uses the default handling.public void onLocationApiAccessRequest(String origin, LocationAccessController.Response response)
origin - Indicates the origin of the web content.response - Indicates a LocationAccessController.Response object used to handle the callback result.public void onLocationApiAccessCancel()
public boolean onPickFiles(WebView webView, AsyncCallback<Uri[]> urisCallback, PickFilesParams params)
webView - Indicates the WebView that initiates the callback.urisCallback - Indicates an AsyncCallback object to asynchronously return the list of files to be
uploaded.params - Indicates the information about the files to be selected.true if the application responds to the callback result; returns false if the
WebView uses the default handling.public void onRequestAccessFromWebContent(WebRequestAccess requestAccess)
requestAccess - Indicates the WebRequestAccess that a web content request.public void onRequestAccessCanceled(WebRequestAccess requestAccess)
requestAccess - Indicates a request for revocation of access rights for web content.