OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package org.chromium.components.autofill; |
| 6 |
| 7 import org.chromium.base.annotations.CalledByNative; |
| 8 import org.chromium.base.annotations.JNINamespace; |
| 9 |
| 10 import java.util.ArrayList; |
| 11 |
| 12 /** |
| 13 * The wrap class of native autofill::FormDataAndroid. |
| 14 */ |
| 15 @JNINamespace("autofill") |
| 16 public class FormData { |
| 17 public final String mName; |
| 18 public final String mHost; |
| 19 public final ArrayList<FormFieldData> mFields; |
| 20 |
| 21 private long mNativeObj; |
| 22 |
| 23 @CalledByNative |
| 24 private static FormData createFormData( |
| 25 long nativeObj, String name, String origin, int fieldCount) { |
| 26 return new FormData(nativeObj, name, origin, fieldCount); |
| 27 } |
| 28 |
| 29 private FormData(long nativeObj, String name, String host, int fieldCount) { |
| 30 mNativeObj = nativeObj; |
| 31 mName = name; |
| 32 mHost = host; |
| 33 mFields = new ArrayList<FormFieldData>(fieldCount); |
| 34 popupFormFields(fieldCount); |
| 35 } |
| 36 |
| 37 private void popupFormFields(int fieldCount) { |
| 38 FormFieldData formFieldData = nativeGetNextFormFieldData(mNativeObj); |
| 39 while (formFieldData != null) { |
| 40 mFields.add(formFieldData); |
| 41 formFieldData = nativeGetNextFormFieldData(mNativeObj); |
| 42 } |
| 43 assert mFields.size() == fieldCount; |
| 44 } |
| 45 |
| 46 @CalledByNative |
| 47 private void onNativeDestroyed() { |
| 48 mNativeObj = 0; |
| 49 } |
| 50 |
| 51 private native FormFieldData nativeGetNextFormFieldData(long nativeFormDataA
ndroid); |
| 52 } |
OLD | NEW |