| Index: chrome/android/java/src/org/chromium/chrome/browser/autofill/CardUnmaskPrompt.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/autofill/CardUnmaskPrompt.java b/chrome/android/java/src/org/chromium/chrome/browser/autofill/CardUnmaskPrompt.java
|
| index 4230f6b02c6b7566e00e8227b720790342795830..2ba79ea64404d1204aab48d88344dcf5f90a99e2 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/autofill/CardUnmaskPrompt.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/autofill/CardUnmaskPrompt.java
|
| @@ -34,6 +34,7 @@ import android.widget.RelativeLayout;
|
| import android.widget.TextView;
|
|
|
| import org.chromium.base.ApiCompatibilityUtils;
|
| +import org.chromium.base.VisibleForTesting;
|
| import org.chromium.chrome.R;
|
|
|
| import java.util.Calendar;
|
| @@ -43,12 +44,17 @@ import java.util.Calendar;
|
| */
|
| public class CardUnmaskPrompt
|
| implements DialogInterface.OnDismissListener, TextWatcher, OnClickListener {
|
| + /**
|
| + * The number of milliseconds to display "Card verified" message.
|
| + */
|
| + private static final int SHOW_RESULT_DELAY_MS = 1000;
|
| +
|
| + private static CardUnmaskPrompt sCurrentPromptForTest;
|
| +
|
| private final CardUnmaskPromptDelegate mDelegate;
|
| private final AlertDialog mDialog;
|
| - private boolean mShouldRequestExpirationDate;
|
| private final int mThisYear;
|
| private final int mThisMonth;
|
| -
|
| private final View mMainView;
|
| private final TextView mInstructions;
|
| private final TextView mNoRetryErrorMessage;
|
| @@ -60,11 +66,15 @@ public class CardUnmaskPrompt
|
| private final TextView mErrorMessage;
|
| private final CheckBox mStoreLocallyCheckbox;
|
| private final ImageView mStoreLocallyTooltipIcon;
|
| - private PopupWindow mStoreLocallyTooltipPopup;
|
| private final ViewGroup mControlsContainer;
|
| private final View mVerificationOverlay;
|
| private final ProgressBar mVerificationProgressBar;
|
| private final TextView mVerificationView;
|
| + private final Runnable mDismissCallback;
|
| +
|
| + private boolean mShouldRequestExpirationDate;
|
| + private PopupWindow mStoreLocallyTooltipPopup;
|
| + private int mShowResultDelayMs = SHOW_RESULT_DELAY_MS;
|
|
|
| /**
|
| * An interface to handle the interaction with an CardUnmaskPrompt object.
|
| @@ -98,11 +108,29 @@ public class CardUnmaskPrompt
|
| void onNewCardLinkClicked();
|
| }
|
|
|
| - public CardUnmaskPrompt(Context context, CardUnmaskPromptDelegate delegate, String title,
|
| - String instructions, String confirmButtonLabel, int drawableId,
|
| + public static CardUnmaskPrompt create(Context context, CardUnmaskPromptDelegate delegate,
|
| + String title, String instructions, String confirmButtonLabel, int drawableId,
|
| boolean shouldRequestExpirationDate, boolean canStoreLocally,
|
| boolean defaultToStoringLocally) {
|
| + assert sCurrentPromptForTest == null;
|
| + CardUnmaskPrompt prompt = new CardUnmaskPrompt(context, delegate, title, instructions,
|
| + confirmButtonLabel, drawableId, shouldRequestExpirationDate, canStoreLocally,
|
| + defaultToStoringLocally, new Runnable() {
|
| + @Override
|
| + public void run() {
|
| + sCurrentPromptForTest = null;
|
| + }
|
| + });
|
| + sCurrentPromptForTest = prompt;
|
| + return prompt;
|
| + }
|
| +
|
| + private CardUnmaskPrompt(Context context, CardUnmaskPromptDelegate delegate, String title,
|
| + String instructions, String confirmButtonLabel, int drawableId,
|
| + boolean shouldRequestExpirationDate, boolean canStoreLocally,
|
| + boolean defaultToStoringLocally, Runnable dismissCallback) {
|
| mDelegate = delegate;
|
| + mDismissCallback = dismissCallback;
|
|
|
| LayoutInflater inflater = LayoutInflater.from(context);
|
| View v = inflater.inflate(R.layout.autofill_card_unmask_prompt, null);
|
| @@ -215,12 +243,13 @@ public class CardUnmaskPrompt
|
| public void run() {
|
| dismiss();
|
| }
|
| - }, 1000);
|
| + }, mShowResultDelayMs);
|
| }
|
| }
|
|
|
| @Override
|
| public void onDismiss(DialogInterface dialog) {
|
| + mDismissCallback.run();
|
| mDelegate.dismissed();
|
| }
|
|
|
| @@ -439,4 +468,19 @@ public class CardUnmaskPrompt
|
| return -1;
|
| }
|
| }
|
| +
|
| + @VisibleForTesting
|
| + public static CardUnmaskPrompt getCurrentPromptForTest() {
|
| + return sCurrentPromptForTest;
|
| + }
|
| +
|
| + @VisibleForTesting
|
| + public AlertDialog getDialogForTest() {
|
| + return mDialog;
|
| + }
|
| +
|
| + @VisibleForTesting
|
| + public void setShowResultDelayForTest(int ms) {
|
| + mShowResultDelayMs = ms;
|
| + }
|
| }
|
|
|