This source file includes following definitions.
- JNINamespace
- dialogCancel
- dialogContinue
- onDestroy
- createDialog
- setDialogFactory
- create
- isDialogAllowed
- onDestroy
- nativeDialogCancel
- nativeDialogContinue
package org.chromium.chrome.browser.autofill;
import com.google.common.annotations.VisibleForTesting;
import org.chromium.base.CalledByNative;
import org.chromium.base.JNINamespace;
import org.chromium.ui.base.WindowAndroid;
@JNINamespace("autofill")
public class AutofillDialogControllerAndroid {
private static AutofillDialogFactory sDialogFactory;
private long mNativeDelegate;
private AutofillDialog mDialog;
public interface AutofillDialogDelegate {
void dialogCancel();
void dialogContinue(
AutofillDialogResult.ResultWallet fullWallet,
boolean lastUsedChoiceIsAutofill, String lastUsedAccountName,
String guidLastUsedBilling, String guidLastUsedShipping, String guidLastUsedCard);
}
public interface AutofillDialog {
void onDestroy();
}
public interface AutofillDialogFactory {
AutofillDialog createDialog(
final AutofillDialogDelegate delegate,
final WindowAndroid windowAndroid,
final boolean requestFullBillingAddress, final boolean requestShippingAddress,
final boolean requestPhoneNumbers,
final boolean incognitoMode,
final boolean initialChoiceIsAutofill, final String initialAccountName,
final String initialBillingGuid, final String initialShippingGuid,
final String initialCardGuid,
final String merchantDomain);
}
public static void setDialogFactory(AutofillDialogFactory factory) {
sDialogFactory = factory;
}
@VisibleForTesting
private AutofillDialogControllerAndroid(
final long nativeAutofillDialogControllerAndroid,
final WindowAndroid windowAndroid,
final boolean requestFullBillingAddress, final boolean requestShippingAddress,
final boolean requestPhoneNumbers,
final boolean incognitoMode,
final boolean initialChoiceIsAutofill, final String initialWalletAccountName,
final String initialBillingGuid, final String initialShippingGuid,
final String initialCardGuid,
final String merchantDomain) {
mNativeDelegate = nativeAutofillDialogControllerAndroid;
if (sDialogFactory == null) {
nativeDialogCancel(mNativeDelegate);
return;
}
AutofillDialogDelegate delegate = new AutofillDialogDelegate() {
@Override
public void dialogCancel() {
nativeDialogCancel(mNativeDelegate);
}
@Override
public void dialogContinue(
AutofillDialogResult.ResultWallet fullWallet,
boolean lastUsedChoiceIsAutofill, String lastUsedAccountName,
String guidLastUsedBilling, String guidLastUsedShipping,
String guidLastUsedCard) {
nativeDialogContinue(mNativeDelegate, fullWallet,
lastUsedChoiceIsAutofill, lastUsedAccountName,
guidLastUsedBilling, guidLastUsedShipping, guidLastUsedCard);
}
};
mDialog = sDialogFactory.createDialog(
delegate,
windowAndroid,
requestFullBillingAddress, requestShippingAddress,
requestPhoneNumbers,
incognitoMode,
initialChoiceIsAutofill, initialWalletAccountName,
initialBillingGuid, initialShippingGuid, initialCardGuid,
merchantDomain);
if (mDialog == null) {
nativeDialogCancel(mNativeDelegate);
return;
}
}
@CalledByNative
private static AutofillDialogControllerAndroid create(
final long nativeAutofillDialogControllerAndroid,
final WindowAndroid windowAndroid,
final boolean requestFullBillingAddress, final boolean requestShippingAddress,
final boolean requestPhoneNumbers,
final boolean incognitoMode,
final boolean initialChoiceIsAutofill, final String initialWalletAccountName,
final String initialBillingGuid, final String initialShippingGuid,
final String initialCreditCardGuid,
final String merchantDomain) {
return new AutofillDialogControllerAndroid(
nativeAutofillDialogControllerAndroid, windowAndroid,
requestFullBillingAddress, requestShippingAddress, requestPhoneNumbers,
incognitoMode,
initialChoiceIsAutofill, initialWalletAccountName,
initialBillingGuid, initialShippingGuid,
initialCreditCardGuid,
merchantDomain);
}
@CalledByNative
private static boolean isDialogAllowed(boolean isInvokedFromTheSameOrigin) {
return isInvokedFromTheSameOrigin;
}
@CalledByNative
private void onDestroy() {
if (mNativeDelegate == 0) return;
if (mDialog != null) mDialog.onDestroy();
mDialog = null;
mNativeDelegate = 0;
}
private native void nativeDialogCancel(long nativeAutofillDialogControllerAndroid);
private native void nativeDialogContinue(long nativeAutofillDialogControllerAndroid,
Object fullWallet,
boolean lastUsedChoiceIsAutofill, String lastUsedAccountName,
String guidLastUsedBilling, String guidLastUsedShipping, String guidLastUsedCard);
}