public class WebChromeClient extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
WebChromeClient.CustomViewCallback
A callback interface used by the host application to notify
the current page that its custom view has been dismissed.
|
static class |
WebChromeClient.FileChooserParams
|
Constructor and Description |
---|
WebChromeClient() |
Modifier and Type | Method and Description |
---|---|
Bitmap |
getDefaultVideoPoster()
When not playing, video elements are represented by a 'poster' image.
|
View |
getVideoLoadingProgressView()
Obtains a View to be displayed while buffering of full screen video is taking
place.
|
void |
getVisitedHistory(ValueCallback<String[]> callback)
Obtains a list of all visited history items, used for link coloring
|
void |
onCloseWindow(WebView window)
Notify the host application to close the given WebView and remove it
from the view system if necessary.
|
boolean |
onConsoleMessage(ConsoleMessage consoleMessage)
Report a JavaScript console message to the host application.
|
void |
onConsoleMessage(String message,
int lineNumber,
String sourceID)
Deprecated.
Use
onConsoleMessage(ConsoleMessage)
instead. |
boolean |
onCreateWindow(WebView view,
boolean isDialog,
boolean isUserGesture,
Message resultMsg)
Request the host application to create a new window.
|
void |
onExceededDatabaseQuota(String url,
String databaseIdentifier,
long quota,
long estimatedDatabaseSize,
long totalQuota,
WebStorage.QuotaUpdater quotaUpdater)
Deprecated.
This method is no longer called; WebView now uses the HTML5 / JavaScript Quota
Management API.
|
void |
onGeolocationPermissionsHidePrompt()
Notify the host application that a request for Geolocation permissions,
made with a previous call to
onGeolocationPermissionsShowPrompt()
has been canceled. |
void |
onGeolocationPermissionsShowPrompt(String origin,
GeolocationPermissions.Callback callback)
Notify the host application that web content from the specified origin
is attempting to use the Geolocation API, but no permission state is
currently set for that origin.
|
void |
onHideCustomView()
Notify the host application that the current page has exited full
screen mode.
|
boolean |
onJsAlert(WebView view,
String url,
String message,
JsResult result)
Tell the client to display a javascript alert dialog.
|
boolean |
onJsBeforeUnload(WebView view,
String url,
String message,
JsResult result)
Tell the client to display a dialog to confirm navigation away from the
current page.
|
boolean |
onJsConfirm(WebView view,
String url,
String message,
JsResult result)
Tell the client to display a confirm dialog to the user.
|
boolean |
onJsPrompt(WebView view,
String url,
String message,
String defaultValue,
JsPromptResult result)
Tell the client to display a prompt dialog to the user.
|
boolean |
onJsTimeout()
Deprecated.
This method is no longer supported and will not be invoked.
|
void |
onPermissionRequest(PermissionRequest request)
Notify the host application that web content is requesting permission to
access the specified resources and the permission currently isn't granted
or denied.
|
void |
onPermissionRequestCanceled(PermissionRequest request)
Notify the host application that the given permission request
has been canceled.
|
void |
onProgressChanged(WebView view,
int newProgress)
Tell the host application the current progress of loading a page.
|
void |
onReachedMaxAppCacheSize(long requiredStorage,
long quota,
WebStorage.QuotaUpdater quotaUpdater)
Deprecated.
This method is no longer called; WebView now uses the HTML5 / JavaScript Quota
Management API.
|
void |
onReceivedIcon(WebView view,
Bitmap icon)
Notify the host application of a new favicon for the current page.
|
void |
onReceivedTitle(WebView view,
String title)
Notify the host application of a change in the document title.
|
void |
onReceivedTouchIconUrl(WebView view,
String url,
boolean precomposed)
Notify the host application of the url for an apple-touch-icon.
|
void |
onRequestFocus(WebView view)
Request display and focus for this WebView.
|
void |
onShowCustomView(View view,
int requestedOrientation,
WebChromeClient.CustomViewCallback callback)
Deprecated.
This method supports the obsolete plugin mechanism,
and will not be invoked in future
|
void |
onShowCustomView(View view,
WebChromeClient.CustomViewCallback callback)
Notify the host application that the current page has entered full
screen mode.
|
boolean |
onShowFileChooser(WebView webView,
ValueCallback<Uri[]> filePathCallback,
WebChromeClient.FileChooserParams fileChooserParams)
Tell the client to show a file chooser.
|
void |
openFileChooser(ValueCallback<Uri> uploadFile,
String acceptType,
String capture)
Deprecated.
Use
#showFileChooser instead. |
void |
setupAutoFill(Message msg)
Tell the client that the page being viewed has an autofillable
form and the user would like to set a profile up.
|
public void onProgressChanged(WebView view, int newProgress)
view
- The WebView that initiated the callback.newProgress
- Current page loading progress, represented by
an integer between 0 and 100.public void onReceivedTitle(WebView view, String title)
view
- The WebView that initiated the callback.title
- A String containing the new title of the document.public void onReceivedIcon(WebView view, Bitmap icon)
view
- The WebView that initiated the callback.icon
- A Bitmap containing the favicon for the current page.public void onReceivedTouchIconUrl(WebView view, String url, boolean precomposed)
view
- The WebView that initiated the callback.url
- The icon url.precomposed
- True if the url is for a precomposed touch icon.public void onShowCustomView(View view, WebChromeClient.CustomViewCallback callback)
WebView
.view
- is the View object to be shown.callback
- invoke this callback to request the page to exit
full screen mode.@Deprecated public void onShowCustomView(View view, int requestedOrientation, WebChromeClient.CustomViewCallback callback)
view
- is the View object to be shown.requestedOrientation
- An orientation constant as used in
ActivityInfo.screenOrientation
.callback
- is the callback to be invoked if and when the view
is dismissed.public void onHideCustomView()
onShowCustomView(android.view.View, android.webkit.WebChromeClient.CustomViewCallback)
when the content entered fullscreen.
Also see "Full screen support" documentation on WebView
.public boolean onCreateWindow(WebView view, boolean isDialog, boolean isUserGesture, Message resultMsg)
view
- The WebView from which the request for a new window
originated.isDialog
- True if the new window should be a dialog, rather than
a full-size window.isUserGesture
- True if the request was initiated by a user gesture,
such as the user clicking a link.resultMsg
- The message to send when once a new WebView has been
created. resultMsg.obj is a
WebView.WebViewTransport
object. This should be
used to transport the new WebView, by calling
WebView.WebViewTransport.setWebView(WebView)
.public void onRequestFocus(WebView view)
view
- The WebView that needs to be focused.public void onCloseWindow(WebView window)
window
- The WebView that needs to be closed.public boolean onJsAlert(WebView view, String url, String message, JsResult result)
view
- The WebView that initiated the callback.url
- The url of the page requesting the dialog.message
- Message to be displayed in the window.result
- A JsResult to confirm that the user hit enter.public boolean onJsConfirm(WebView view, String url, String message, JsResult result)
view
- The WebView that initiated the callback.url
- The url of the page requesting the dialog.message
- Message to be displayed in the window.result
- A JsResult used to send the user's response to
javascript.public boolean onJsPrompt(WebView view, String url, String message, String defaultValue, JsPromptResult result)
view
- The WebView that initiated the callback.url
- The url of the page requesting the dialog.message
- Message to be displayed in the window.defaultValue
- The default value displayed in the prompt dialog.result
- A JsPromptResult used to send the user's reponse to
javascript.public boolean onJsBeforeUnload(WebView view, String url, String message, JsResult result)
view
- The WebView that initiated the callback.url
- The url of the page requesting the dialog.message
- Message to be displayed in the window.result
- A JsResult used to send the user's response to
javascript.@Deprecated public void onExceededDatabaseQuota(String url, String databaseIdentifier, long quota, long estimatedDatabaseSize, long totalQuota, WebStorage.QuotaUpdater quotaUpdater)
updateQuota(long)
method of the supplied WebStorage.QuotaUpdater
instance. The
minimum value that can be set for the new quota is the current quota. The
default implementation responds with the current quota, so the quota will
not be increased.url
- The URL of the page that triggered the notificationdatabaseIdentifier
- The identifier of the database where the quota
was exceeded.quota
- The quota for the origin, in bytesestimatedDatabaseSize
- The estimated size of the offending
database, in bytestotalQuota
- The total quota for all origins, in bytesquotaUpdater
- An instance of WebStorage.QuotaUpdater
which
must be used to inform the WebView of the new quota.@Deprecated public void onReachedMaxAppCacheSize(long requiredStorage, long quota, WebStorage.QuotaUpdater quotaUpdater)
updateQuota(long)
method of the supplied WebStorage.QuotaUpdater
instance. The
minimum value that can be set for the new quota is the current quota. The
default implementation responds with the current quota, so the quota will
not be increased.requiredStorage
- The amount of storage required by the Application
Cache operation that triggered this notification,
in bytes.quota
- the current maximum Application Cache size, in bytesquotaUpdater
- An instance of WebStorage.QuotaUpdater
which
must be used to inform the WebView of the new quota.public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback)
GeolocationPermissions
for details.
Note that for applications targeting Android N and later SDKs
(API level > Build.VERSION_CODES.M
)
this method is only called for requests originating from secure
origins such as https. On non-secure origins geolocation requests
are automatically denied.
origin
- The origin of the web content attempting to use the
Geolocation API.callback
- The callback to use to set the permission state for the
origin.public void onGeolocationPermissionsHidePrompt()
onGeolocationPermissionsShowPrompt()
has been canceled. Any related UI should therefore be hidden.public void onPermissionRequest(PermissionRequest request)
PermissionRequest.grant(String[])
or PermissionRequest.deny()
.
If this method isn't overridden, the permission is denied.request
- the PermissionRequest from current web content.public void onPermissionRequestCanceled(PermissionRequest request)
request
- the PermissionRequest that needs be canceled.public boolean onJsTimeout()
@Deprecated public void onConsoleMessage(String message, int lineNumber, String sourceID)
onConsoleMessage(ConsoleMessage)
instead.message
- The error message to report.lineNumber
- The line number of the error.sourceID
- The name of the source file that caused the error.public boolean onConsoleMessage(ConsoleMessage consoleMessage)
consoleMessage
- Object containing details of the console message.public Bitmap getDefaultVideoPoster()
public View getVideoLoadingProgressView()
public void getVisitedHistory(ValueCallback<String[]> callback)
public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, WebChromeClient.FileChooserParams fileChooserParams)
filePathCallback.onReceiveValue(null)
and
return true.webView
- The WebView instance that is initiating the request.filePathCallback
- Invoke this callback to supply the list of paths to files to upload,
or NULL to cancel. Must only be called if the
showFileChooser
implementations returns true.fileChooserParams
- Describes the mode of file chooser to be opened, and options to be
used with it.WebChromeClient.FileChooserParams
@Deprecated public void openFileChooser(ValueCallback<Uri> uploadFile, String acceptType, String capture)
#showFileChooser
instead.uploadFile
- A ValueCallback to set the URI of the file to upload.
onReceiveValue must be called to wake up the thread.aacceptType
- The value of the 'accept' attribute of the input tag
associated with this file picker.capture
- The value of the 'capture' attribute of the input tag
associated with this file picker.public void setupAutoFill(Message msg)
msg
- A Message to send once the user has successfully
set up a profile and to inform the WebTextView it should
now autofill using that new profile.