Chromium Code Reviews| 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..2e1bc1ebc198240fe1222b4d01885eda35062447 |
| --- /dev/null |
| +++ b/components/autofill/android/java/src/org/chromium/components/autofill/AutofillProvider.java |
| @@ -0,0 +1,120 @@ |
| +// 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; |
| +import org.chromium.content_public.browser.WebContents; |
| + |
| +/** |
| + * 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); |
| + |
| + public abstract void setWebContents(WebContents webContents); |
| + |
| + /** |
| + * Invoked when autofill value is available, AutofillProvider shall fill the |
| + * form with the provided values. |
| + * |
| + * @param values the array of autofill values, the key is virtual id of form |
| + * field. |
| + */ |
| + public abstract void autofill(final SparseArray<String> values); |
| + |
| + /** |
| + * Invoked when autofill service needs the form structure. |
| + * |
| + * @param structure see View.onProvideAutofillVirtualStructure() |
| + * @param flags see View.onProvideAutofillVirtualStructure() |
| + */ |
| + public abstract void onProvideAutoFillVirtualStructure(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 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( |
| + FormData formData, float focus, float x, float y, float width, float height); |
| + |
| + /** |
| + * Invoked when text field is changed. |
| + * |
| + * @param index index of field in current form. |
| + */ |
| + @CalledByNative |
| + protected abstract void onTextFieldDidChange(int index); |
| + |
| + /** |
| + * Invoked when current form will be submitted. |
| + * |
| + */ |
| + @CalledByNative |
| + protected abstract void onWillSubmitForm(); |
| + |
| + /** |
| + * Invoked when focus field changed. |
| + * |
| + * @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( |
| + 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. |
|
Mathieu
2017/05/24 18:02:02
can you mention in comments when this happens? The
michaelbai
2017/05/26 23:12:07
Done.
|
| + */ |
| + @CalledByNative |
| + protected abstract void reset(); |
| + |
| + @CalledByNative |
| + protected abstract void setNativeAutofillProvider(long nativeAutofillProvider); |
| + |
| + private native void nativeOnAutofillAvailable( |
| + long nativeAutofillProviderAndroid, FormData formData); |
| +} |