This source file includes following definitions.
- JNINamespace
- create
- requestHide
- suggestionSelected
- hide
- show
- setAnchorRect
- createAutofillSuggestionArray
- addToAutofillSuggestionArray
- nativeRequestHide
- nativeSuggestionSelected
package org.chromium.chrome.browser.autofill;
import android.app.Activity;
import android.os.Handler;
import org.chromium.base.CalledByNative;
import org.chromium.base.JNINamespace;
import org.chromium.ui.autofill.AutofillPopup;
import org.chromium.ui.autofill.AutofillPopup.AutofillPopupDelegate;
import org.chromium.ui.autofill.AutofillSuggestion;
import org.chromium.ui.base.ViewAndroid;
import org.chromium.ui.base.ViewAndroidDelegate;
import org.chromium.ui.base.WindowAndroid;
@JNINamespace("autofill")
public class AutofillPopupBridge implements AutofillPopupDelegate{
private final long mNativeAutofillPopup;
private final AutofillPopup mAutofillPopup;
public AutofillPopupBridge(long nativeAutofillPopupViewAndroid, WindowAndroid windowAndroid,
ViewAndroidDelegate containerViewDelegate) {
mNativeAutofillPopup = nativeAutofillPopupViewAndroid;
Activity activity = windowAndroid.getActivity().get();
if (activity == null) {
mAutofillPopup = null;
new Handler().post(new Runnable() {
@Override
public void run() {
requestHide();
}
});
} else {
mAutofillPopup = new AutofillPopup(activity, containerViewDelegate, this);
}
}
@CalledByNative
private static AutofillPopupBridge create(long nativeAutofillPopupViewAndroid,
WindowAndroid windowAndroid, ViewAndroid viewAndroid) {
return new AutofillPopupBridge(nativeAutofillPopupViewAndroid, windowAndroid,
viewAndroid.getViewAndroidDelegate());
}
@Override
public void requestHide() {
nativeRequestHide(mNativeAutofillPopup);
}
@Override
public void suggestionSelected(int listIndex) {
nativeSuggestionSelected(mNativeAutofillPopup, listIndex);
}
@CalledByNative
private void hide() {
if (mAutofillPopup != null) mAutofillPopup.hide();
}
@CalledByNative
private void show(AutofillSuggestion[] suggestions) {
if (mAutofillPopup != null) mAutofillPopup.show(suggestions);
}
@CalledByNative
private void setAnchorRect(float x, float y, float width, float height) {
if (mAutofillPopup != null) mAutofillPopup.setAnchorRect(x, y, width, height);
}
@CalledByNative
private static AutofillSuggestion[] createAutofillSuggestionArray(int size) {
return new AutofillSuggestion[size];
}
@CalledByNative
private static void addToAutofillSuggestionArray(AutofillSuggestion[] array, int index,
String label, String sublabel, int uniqueId) {
array[index] = new AutofillSuggestion(label, sublabel, uniqueId);
}
private native void nativeRequestHide(long nativeAutofillPopupViewAndroid);
private native void nativeSuggestionSelected(long nativeAutofillPopupViewAndroid,
int listIndex);
}