Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(308)

Unified Diff: components/autofill/android/java/src/org/chromium/components/autofill/AutofillProvider.java

Issue 2839023003: WebView autofill implementation (Closed)
Patch Set: fix coordinates Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/autofill/android/java/src/org/chromium/components/autofill/AutofillProvider.java
diff --git a/components/autofill/android/java/src/org/chromium/components/autofill/AutofillProvider.java b/components/autofill/android/java/src/org/chromium/components/autofill/AutofillProvider.java
new file mode 100644
index 0000000000000000000000000000000000000000..6c3959c3238d45766ea1e5b53b0590d4af9845ba
--- /dev/null
+++ b/components/autofill/android/java/src/org/chromium/components/autofill/AutofillProvider.java
@@ -0,0 +1,124 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.components.autofill;
+
+import android.util.SparseArray;
+import android.view.ViewGroup;
+import android.view.ViewStructure;
+
+import org.chromium.base.annotations.CalledByNative;
+import org.chromium.base.annotations.JNINamespace;
+
+/**
+ * This class defines interface of AutofillProvider, it doesn't use chrome's
+ * autofill service or suggestion UI, instead, uses third party autofill service
+ * by knowing of format structure and user's input.
+ *
+ * AutofillProvider handles one autofill session at time, each call of
+ * queryFormFieldAutofill cancels previous session and starts a new one, the
+ * calling of other methods shall associate with current session.
+ *
+ */
+@JNINamespace("autofill")
+public abstract class AutofillProvider {
+ public AutofillProvider() {}
+
+ /**
+ * Invoked when container view is changed.
+ *
+ * @param containerView new container view.
+ */
+ public abstract void onContainerViewChanged(ViewGroup containerView);
+
+ /**
+ * Invoked when autofill value is available, AutofillProvider shall fill the
+ * form by provided values.
Roger McFarlane (Chromium) 2017/05/05 21:19:43 nit: s/by/with the/
michaelbai 2017/05/09 00:27:03 Done.
+ *
+ * @param nativeAutofillProvider the native autofill provider.
+ * @param values the array of autofill values, the key is virtual id of form
+ * field.
+ */
+ public abstract void autofill(long nativeAutofillProvider, final SparseArray<String> values);
+
+ /**
+ * Invoked when autofill service needs the form structure.
+ *
+ * @param nativeAutofillProvider the native autofill provider.
+ * @param structure see View.onProvideAutofillVirtualStructure()
+ * @param flags
Roger McFarlane (Chromium) 2017/05/05 21:19:43 description of flags?
michaelbai 2017/05/09 00:27:03 This is coming from Android API, added see...
+ */
+ public abstract void onProvideAutoFillVirtualStructure(
+ long nativeAutofillProvider, ViewStructure structure, int flags);
+
+ /**
+ * Invoked when filling form is need. AutofillProvider shall ask autofill
+ * service for the value to fill the form.
Roger McFarlane (Chromium) 2017/05/05 21:19:43 nit: s/value/values with which/
michaelbai 2017/05/09 00:27:03 Done.
+ *
+ * @param nativeAutofillProvider the native autofill provider.
+ * @param formData the form needs to fill.
+ * @param focus the index of focus field in formData
+ * @param x the boundary of focus field.
+ * @param y the boundary of focus field.
+ * @param width the boundary of focus field.
+ * @param height the boundary of focus field.
+ */
+ @CalledByNative
+ protected abstract void startAutofillSession(long nativeAutofillProvider, Object webContents,
+ FormData formData, float focus, float x, float y, float width, float height);
+
+ /**
+ * Invoked when text field is changed.
+ *
+ * @param nativeAutofillProvider the native autofill provider.
+ * @param index index of field in current form.
+ */
+ @CalledByNative
+ protected abstract void onTextFieldDidChange(
+ long nativeAutofillProvider, Object webContents, int index);
+
+ /**
+ * Invoked when current form will be submitted.
+ *
+ * @param nativeAutofillProvider the native autofill provider.
+ */
+ @CalledByNative
+ protected abstract void onWillSubmitForm(long nativeAutofillProvider);
+
+ /**
+ * Invoked when focus field changed.
+ *
+ * @param nativeAutofillProvider the native autofill provider.
+ * @param focusOnForm whether focus is still on form.
+ * @param focusItem the index of field has focus
+ * @param x the boundary of focus field.
+ * @param y the boundary of focus field.
+ * @param width the boundary of focus field.
+ * @param height the boundary of focus field.
+ */
+ @CalledByNative
+ protected abstract void onFocusChanged(long nativeAutofillProvider, Object webContents,
+ boolean focusOnForm, int focusItem, float x, float y, float width, float height);
+
+ /**
+ * Send form to renderer for filling.
+ *
+ * @param nativeAutofillProvider the native autofill provider.
+ * @param formData the form to fill.
+ */
+ protected void autofill(long nativeAutofillProvider, FormData formData) {
+ nativeOnAutofillAvailable(nativeAutofillProvider, formData);
+ }
+
+ /**
+ * Invoked when AutofillManager reset cache.
Roger McFarlane (Chromium) 2017/05/05 21:19:43 nit: s/reset/resets its/ or "resets the"
michaelbai 2017/05/09 00:27:03 Done.
+ *
+ * @param nativeAutofillProvider the native autofill provider.
+ */
+ @CalledByNative
+ protected abstract void reset(long nativeAutofillProvider);
+
+ private native void nativeOnAutofillAvailable(
+ long nativeAutofillProviderAndroid, FormData formData);
+}

Powered by Google App Engine
This is Rietveld 408576698