diff options
| author | Changwan Ryu <changwan@google.com> | 2020-04-14 14:15:28 -0700 |
|---|---|---|
| committer | Changwan Ryu <changwan@google.com> | 2020-05-13 16:52:24 +0000 |
| commit | 31e2db92ce047cc242fe87425a84c8b3bc9582cb (patch) | |
| tree | c213a41c4e0626a627c859222bb0cec0b03a4951 /core/java/android/webkit | |
| parent | 0cd6d1cb70e9babc6a5a65940ee5e1f615e46395 (diff) | |
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
Diffstat (limited to 'core/java/android/webkit')
| -rw-r--r-- | core/java/android/webkit/WebChromeClient.java | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/core/java/android/webkit/WebChromeClient.java b/core/java/android/webkit/WebChromeClient.java index f8522edb7dcd..f78ec7c439a1 100644 --- a/core/java/android/webkit/WebChromeClient.java +++ b/core/java/android/webkit/WebChromeClient.java @@ -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) { |
