| 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..908497816d443717ba58d5f5417766db4d43d2df
|
| --- /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 with the provided values.
|
| + *
|
| + * @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 see View.onProvideAutofillVirtualStructure()
|
| + */
|
| + public abstract void onProvideAutoFillVirtualStructure(
|
| + long nativeAutofillProvider, ViewStructure structure, int flags);
|
| +
|
| + /**
|
| + * Invoked when filling form is need. AutofillProvider shall ask autofill
|
| + * service for the values with which to fill the form.
|
| + *
|
| + * @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 resets its cache.
|
| + *
|
| + * @param nativeAutofillProvider the native autofill provider.
|
| + */
|
| + @CalledByNative
|
| + protected abstract void reset(long nativeAutofillProvider);
|
| +
|
| + private native void nativeOnAutofillAvailable(
|
| + long nativeAutofillProviderAndroid, FormData formData);
|
| +}
|
|
|