Chromium Code Reviews| Index: components/autofill/android/java/src/org/chromium/components/autofill/FormData.java |
| diff --git a/components/autofill/android/java/src/org/chromium/components/autofill/FormData.java b/components/autofill/android/java/src/org/chromium/components/autofill/FormData.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..6399c35eeb065fd6daa08c57aa9c69f3ae2fb220 |
| --- /dev/null |
| +++ b/components/autofill/android/java/src/org/chromium/components/autofill/FormData.java |
| @@ -0,0 +1,52 @@ |
| +// 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 org.chromium.base.annotations.CalledByNative; |
| +import org.chromium.base.annotations.JNINamespace; |
| + |
| +import java.util.ArrayList; |
| + |
| +/** |
| + * The wrap class of native autofill::FormData. |
|
Mathieu
2017/05/24 18:02:02
*FormDataAndroid?
michaelbai
2017/05/26 23:12:07
Done.
|
| + */ |
| +@JNINamespace("autofill") |
| +public class FormData { |
| + public final String mName; |
| + public final String mHost; |
| + public final ArrayList<FormFieldData> mFields; |
| + |
| + private long mNativeObj; |
| + |
| + @CalledByNative |
| + private static FormData createFormData( |
| + long nativeObj, String name, String origin, int fieldCount) { |
| + return new FormData(nativeObj, name, origin, fieldCount); |
| + } |
| + |
| + private FormData(long nativeObj, String name, String host, int fieldCount) { |
| + mNativeObj = nativeObj; |
| + mName = name; |
| + mHost = host; |
| + mFields = new ArrayList<FormFieldData>(fieldCount); |
| + popupFormFields(fieldCount); |
| + } |
| + |
| + private void popupFormFields(int fieldCount) { |
| + FormFieldData formFieldData = nativeGetNextFormFieldData(mNativeObj); |
|
Mathieu
2017/05/24 18:02:02
should you check for !mNativeObj here?
michaelbai
2017/05/26 23:12:08
No, mNativeObj shouldn't be NULL in any case, if i
|
| + while (formFieldData != null) { |
| + mFields.add(formFieldData); |
| + formFieldData = nativeGetNextFormFieldData(mNativeObj); |
| + } |
| + assert mFields.size() == fieldCount; |
| + } |
| + |
| + @CalledByNative |
| + private void onNativeDestroyed() { |
| + mNativeObj = 0; |
| + } |
| + |
| + private native FormFieldData nativeGetNextFormFieldData(long nativeFormDataAndroid); |
| +} |