From 58390fe9aef3f7a18fcd8a108d5d6f22d8790572 Mon Sep 17 00:00:00 2001 From: Felipe Leme Date: Fri, 15 Sep 2017 15:16:28 -0700 Subject: [PATCH] Minor fixes on WebView.onProvideAutofillVirtualStructure() javadoc. Test: mmm -j108 frameworks/base/:doc-comment-check-docs Bug: 65751159 Change-Id: Ie60b1f32e4d9acc675c6e25b7d3e606049b6a3c3 --- core/java/android/webkit/WebView.java | 43 ++++++----------------------------- 1 file changed, 7 insertions(+), 36 deletions(-) diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index f918cadde87c..637b60e2dcb4 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -2723,25 +2723,20 @@ public class WebView extends AbsoluteLayout * {@code IFRAME}, in which case it would be treated the same way as multiple forms described * above, except that the {@link ViewStructure#setWebDomain(String) web domain} of the * {@code FORM} contains the {@code src} attribute from the {@code IFRAME} node. - *
  • If the Android SDK provides a similar View, then should be set with the - * fully-qualified class name of such view. *
  • The W3C autofill field ({@code autocomplete} tag attribute) maps to - * {@link ViewStructure#setAutofillHints(String[])}. - *
  • The {@code type} attribute of {@code INPUT} tags maps to - * {@link ViewStructure#setInputType(int)}. - *
  • The {@code value} attribute of {@code INPUT} tags maps to - * {@link ViewStructure#setText(CharSequence)}. - *
  • If the view is editalbe, the {@link ViewStructure#setAutofillType(int)} and + * {@link ViewStructure#setAutofillHints(String[])}. + *
  • If the view is editable, the {@link ViewStructure#setAutofillType(int)} and * {@link ViewStructure#setAutofillValue(AutofillValue)} must be set. *
  • The {@code placeholder} attribute maps to {@link ViewStructure#setHint(CharSequence)}. *
  • Other HTML attributes can be represented through * {@link ViewStructure#setHtmlInfo(android.view.ViewStructure.HtmlInfo)}. * * - *

    It should also call {@code structure.setDataIsSensitive(false)} for fields whose value - * were not dynamically changed (for example, through Javascript). + *

    If the WebView implementation can determine that the value of a field was set statically + * (for example, not through Javascript), it should also call + * {@code structure.setDataIsSensitive(false)}. * - *

    Example1: an HTML form with 2 fields for username and password. + *

    For example, an HTML form with 2 fields for username and password: * *

          *    <input type="text" name="username" id="user" value="Type your username" autocomplete="username" placeholder="Email or username">
    @@ -2754,51 +2749,27 @@ public class WebView extends AbsoluteLayout
          *     int index = structure.addChildCount(2);
          *     ViewStructure username = structure.newChild(index);
          *     username.setAutofillId(structure.getAutofillId(), 1); // id 1 - first child
    -     *     username.setClassName("input");
    -     *     username.setInputType("android.widget.EditText");
          *     username.setAutofillHints("username");
          *     username.setHtmlInfo(username.newHtmlInfoBuilder("input")
          *         .addAttribute("type", "text")
          *         .addAttribute("name", "username")
    -     *         .addAttribute("id", "user")
          *         .build());
          *     username.setHint("Email or username");
          *     username.setAutofillType(View.AUTOFILL_TYPE_TEXT);
          *     username.setAutofillValue(AutofillValue.forText("Type your username"));
    -     *     username.setText("Type your username");
    -     *     // Value of the field is not sensitive because it was not dynamically changed:
    +     *     // Value of the field is not sensitive because it was created statically and not changed.
          *     username.setDataIsSensitive(false);
          *
          *     ViewStructure password = structure.newChild(index + 1);
          *     username.setAutofillId(structure, 2); // id 2 - second child
    -     *     password.setInputType("android.widget.EditText");
    -     *     password.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);
          *     password.setAutofillHints("current-password");
          *     password.setHtmlInfo(password.newHtmlInfoBuilder("input")
          *         .addAttribute("type", "password")
          *         .addAttribute("name", "password")
    -     *         .addAttribute("id", "pass")
          *         .build());
          *     password.setHint("Password");
          *     password.setAutofillType(View.AUTOFILL_TYPE_TEXT);
          * 
    - * - *

    Example2: an IFRAME tag. - * - *

    -     *    <iframe src="https://example.com/login"/>
    -     * 
    - * - *

    Would map to: - * - *

    -     *     int index = structure.addChildCount(1);
    -     *     ViewStructure iframe = structure.newChildFor(index);
    -     *     iframe.setAutofillId(structure.getAutofillId(), 1);
    -     *     iframe.setHtmlInfo(iframe.newHtmlInfoBuilder("iframe")
    -     *         .addAttribute("src", "https://example.com/login")
    -     *         .build());
    -     * 
    */ @Override public void onProvideAutofillVirtualStructure(ViewStructure structure, int flags) { -- 2.11.0