webkit: Update documentation for onJsAlert callback method

Fix documentation to clearly indicate that the default behavior is to
show WebView's own default dialog.

Also, change some wording to avoid confusion.

Bug: 154014645
Test: m -j offline-sdk-docs seems unbroken
Change-Id: I3f6676094e5472aa99bb014cf2b489f59133d094
This commit is contained in:
Changwan Ryu
2020-04-14 14:15:28 -07:00
parent 0cd6d1cb70
commit 31e2db92ce

View File

@@ -189,14 +189,29 @@ public class WebChromeClient {
public void onCloseWindow(WebView window) {}
/**
* Tell the client to display a javascript alert dialog. If the client
* returns {@code true}, WebView will assume that the client will handle the
* dialog. If the client returns {@code false}, it will continue execution.
* Notify the host application that the web page wants to display a
* JavaScript {@code alert()} dialog.
* <p>The default behavior if this method returns {@code false} or is not
* overridden is to show a dialog containing the alert message and suspend
* JavaScript execution until the dialog is dismissed.
* <p>To show a custom dialog, the app should return {@code true} from this
* method, in which case the default dialog will not be shown and JavaScript
* execution will be suspended. The app should call
* {@code JsResult.confirm()} when the custom dialog is dismissed such that
* JavaScript execution can be resumed.
* <p>To suppress the dialog and allow JavaScript execution to
* continue, call {@code JsResult.confirm()} immediately and then return
* {@code true}.
* <p>Note that if the {@link WebChromeClient} is {@code null}, the default
* dialog will be suppressed and Javascript execution will continue
* immediately.
*
* @param view The WebView that initiated the callback.
* @param url The url of the page requesting the dialog.
* @param message Message to be displayed in the window.
* @param result A JsResult to confirm that the user hit enter.
* @return boolean Whether the client will handle the alert dialog.
* @param result A JsResult to confirm that the user closed the window.
* @return boolean {@code true} if the request is handled or ignored.
* {@code false} if WebView needs to show the default dialog.
*/
public boolean onJsAlert(WebView view, String url, String message,
JsResult result) {